Skip to content

Commit

Permalink
CASSJAVA-57 Filter comment lines out when reading in comparison files
Browse files Browse the repository at this point in the history
patch by Bret McGuire; reviewed by Bret McGuire for CASSJAVA-57
  • Loading branch information
absurdfarce committed Dec 19, 2024
1 parent 657e470 commit 4914cf7
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import com.datastax.driver.core.schemabuilder.SchemaBuilder;
import com.datastax.driver.core.utils.CassandraVersion;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteStreams;
import com.google.common.io.Closer;
import java.io.ByteArrayOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -248,10 +248,19 @@ private String getExpectedCqlString() {
+ ")")
.isNotNull();
closer.register(is);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
ByteStreams.copy(is, ps);
return baos.toString().trim();

BufferedReader in = new BufferedReader(new InputStreamReader(is));
StringWriter out = new StringWriter();

String line;
while ((line = in.readLine()) != null) {

String trimmedLine = line.trim();
if (trimmedLine.startsWith("/*") || trimmedLine.startsWith("*")) continue;
out.write(line);
out.write(System.getProperty("line.separator"));
}
return out.toString().trim();
} catch (IOException e) {
logger.warn("Failure to read {}", resourceName, e);
fail("Unable to read " + resourceName + " is it defined?");
Expand Down

0 comments on commit 4914cf7

Please sign in to comment.