Skip to content
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
16 changes: 8 additions & 8 deletions bindings/java/src/org/sleuthkit/datamodel/LibraryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ private static boolean loadNativeLibFromTskJar(Lib library) {
}

// copy it
InputStream in = urlInJar.openStream();
OutputStream out = new FileOutputStream(tempLibFile);
try (
InputStream in = urlInJar.openStream();
OutputStream out = new FileOutputStream(tempLibFile);) {

byte[] buffer = new byte[1024];
int length;
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
byte[] buffer = new byte[1024];
int length;
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
}
in.close();
out.close();

// load it
System.load(tempLibFile.getAbsolutePath());
Expand Down
31 changes: 10 additions & 21 deletions bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1184,31 +1184,19 @@ public void copyCaseDB(String newDBPath) throws IOException {
if (dbPath.isEmpty()) {
throw new IOException("Copying case database files is not supported for this type of case database"); //NON-NLS
}
InputStream in = null;
OutputStream out = null;

acquireSingleUserCaseWriteLock();
try {
InputStream inFile = new FileInputStream(dbPath);
in = new BufferedInputStream(inFile);
try(InputStream inFile = new FileInputStream(dbPath);
InputStream in = new BufferedInputStream(inFile);
OutputStream outFile = new FileOutputStream(newDBPath);
out = new BufferedOutputStream(outFile);
OutputStream out = new BufferedOutputStream(outFile);) {

int bytesRead = in.read();
while (bytesRead != -1) {
out.write(bytesRead);
bytesRead = in.read();
}
} finally {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.flush();
out.close();
}
} catch (IOException e) {
logger.log(Level.WARNING, "Could not close streams after db copy", e); //NON-NLS
}
releaseSingleUserCaseWriteLock();
}
}
Expand Down Expand Up @@ -13994,7 +13982,7 @@ public void execute() throws SQLException {
* supported.
*
* NOTE: We run into deadlock risks when we start to lock multiple
* tables. If that need arrises, consider changing to opportunistic
* tables. If that need arises, consider changing to opportunistic
* locking and single-step transactions.
*/
private class AggregateScoreTablePostgreSQLWriteLock implements DbCommand {
Expand All @@ -14007,9 +13995,10 @@ private class AggregateScoreTablePostgreSQLWriteLock implements DbCommand {

@Override
public void execute() throws SQLException {
PreparedStatement preparedStatement = connection.prepareStatement("LOCK TABLE ONLY tsk_aggregate_score in SHARE ROW EXCLUSIVE MODE");
preparedStatement.execute();

try (PreparedStatement preparedStatement =
connection.prepareStatement("LOCK TABLE ONLY tsk_aggregate_score in SHARE ROW EXCLUSIVE MODE")) {
preparedStatement.execute();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ private Optional<TimelineEvent> addArtifactEvent(TimelineEventDescriptionWithTim
Long dataSourceObjectID = artifact.getDataSourceObjectID();

if(dataSourceObjectID == null) {
logger.log(Level.SEVERE, String.format("Failed to create timeline event for artifact (%d), artifact data source was null"), artifact.getId());
logger.log(Level.SEVERE, String.format("Failed to create timeline event for artifact (%d), artifact data source was null", artifact.getId()));
return Optional.empty();
}

Expand Down
Loading