Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
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
42 changes: 23 additions & 19 deletions 42 src/sqlancer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private FileWriter getLogFileWriter() {

public FileWriter getCurrentFileWriter() {
if (!logEachSelect) {
throw new UnsupportedOperationException();
return null; // Instead of throwing an exception
}
if (currentFileWriter == null) {
try {
Expand All @@ -177,7 +177,7 @@ public FileWriter getCurrentFileWriter() {
}
}
return currentFileWriter;
}
}

public FileWriter getQueryPlanFileWriter() {
if (!logQueryPlan) {
Expand Down Expand Up @@ -209,16 +209,18 @@ public FileWriter getReduceFileWriter() {

public void writeCurrent(StateToReproduce state) {
if (!logEachSelect) {
throw new UnsupportedOperationException();
return; // Skip logging if logEachSelect is false
}
printState(getCurrentFileWriter(), state);
try {
currentFileWriter.flush();

} catch (IOException e) {
e.printStackTrace();
FileWriter writer = getCurrentFileWriter();
if (writer != null) {
printState(writer, state);
try {
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

public void writeCurrent(String input) {
write(databaseProvider.getLoggableFactory().createLoggable(input));
Expand All @@ -230,16 +232,18 @@ public void writeCurrentNoLineBreak(String input) {

private void write(Loggable loggable) {
if (!logEachSelect) {
throw new UnsupportedOperationException();
return; // Skip writing if logging is disabled
}
try {
getCurrentFileWriter().write(loggable.getLogString());

currentFileWriter.flush();
} catch (IOException e) {
throw new AssertionError();
FileWriter writer = getCurrentFileWriter();
if (writer != null) {
try {
writer.write(loggable.getLogString());
writer.flush();
} catch (IOException e) {
throw new AssertionError(e);
}
}
}
}

public void writeQueryPlan(String queryPlan) {
if (!logQueryPlan) {
Expand Down Expand Up @@ -795,4 +799,4 @@ public void run() {
}, 5, 5, TimeUnit.SECONDS);
}

}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.