Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix more findbugs warnings #424

Merged
merged 1 commit into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions ksql-cli/src/main/java/io/confluent/ksql/util/CliUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import org.codehaus.jackson.JsonParseException;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -82,9 +84,8 @@ public String getAvroSchema(final String schemaFilePath) {

public String readQueryFile(final String queryFilePath) throws IOException {
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(queryFilePath));
try (final BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(queryFilePath), StandardCharsets.UTF_8))) {
String line = br.readLine();
while (line != null) {
sb.append(line);
Expand All @@ -93,10 +94,6 @@ public String readQueryFile(final String queryFilePath) throws IOException {
}
} catch (IOException e) {
throw new KsqlException("Could not read the query file. Details: " + e.getMessage(), e);
} finally {
if (br != null) {
br.close();
}
}
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ public IExpressionEvaluator getExpressionEvaluator() {
}

public int[] getIndexes() {
return indexes;
final int [] result = new int[indexes.length];
System.arraycopy(indexes, 0, result, 0, indexes.length);
return result;
}

public Kudf[] getUdfs() {
return udfs;
final Kudf[] result = new Kudf[udfs.length];
System.arraycopy(udfs, 0, result, 0, udfs.length);
return result;
}

public Schema getExpressionType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ private int mapSessionValueToSibling(String sessionisationValue, Schema.Field fi
LinkedHashMap properties = (LinkedHashMap) field.schema().getObjectProps().get("arg.properties");
Integer max = (Integer) ((LinkedHashMap) properties.get("range")).get("max");

int hash = Math.abs(sessionisationValue.hashCode());
int vvalue = hash % max.intValue();
int vvalue = Math.abs(sessionisationValue.hashCode() % max);

int foundValue = -1;
// used - search for another
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Map;
import java.util.Set;

public class MetaStoreImpl implements MetaStore {
public class MetaStoreImpl implements MetaStore, Cloneable {

private final Map<String, KsqlTopic> topicMap;
private final Map<String, StructuredDataSource> dataSourceMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class CommandStore implements Closeable {

private static final Logger log = LoggerFactory.getLogger(CommandStore.class);

public static long POLLING_TIMEOUT_FOR_COMMAND_TOPIC = 5000;
private static final long POLLING_TIMEOUT_FOR_COMMAND_TOPIC = 5000;

private final String commandTopic;
private final Consumer<CommandId, Command> commandConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void write(OutputStream out) throws IOException {

void write(OutputStream output, GenericRow row) throws IOException {
objectMapper.writeValue(output, new StreamedRow(row));
output.write("\n".getBytes());
output.write("\n".getBytes(StandardCharsets.UTF_8));
output.flush();
}

Expand Down