Skip to content

Commit

Permalink
Merge pull request #294 from pfn/master
Browse files Browse the repository at this point in the history
fix #289, remove unnecessary isEbcdic check
  • Loading branch information
william-ferguson-au committed Jul 20, 2015
2 parents 479e20f + c26e12c commit c1c0416
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions src/main/java/org/acra/CrashReportPersister.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* java.util.Properties.java modified by Kevin Gaudin to allow usage of enums as keys.
*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
Expand Down Expand Up @@ -69,15 +69,7 @@ public CrashReportData load(String fileName) throws IOException {

try {
final BufferedInputStream bis = new BufferedInputStream(in, ACRAConstants.DEFAULT_BUFFER_SIZE_IN_BYTES);
bis.mark(Integer.MAX_VALUE);
final boolean isEbcdic = isEbcdic(bis);
bis.reset();

if (!isEbcdic) {
return load(new InputStreamReader(bis, "ISO8859-1")); //$NON-NLS-1$
} else {
return load(new InputStreamReader(bis)); //$NON-NLS-1$
}
return load(new InputStreamReader(bis, "ISO8859-1")); //$NON-NLS-1$
} finally {
in.close();
}
Expand Down Expand Up @@ -114,24 +106,6 @@ public void store(CrashReportData crashData, String fileName) throws IOException
}
}

private boolean isEbcdic(BufferedInputStream in) throws IOException {
byte b;
while ((b = (byte) in.read()) != -1) {
if (b == 0x23 || b == 0x0a || b == 0x3d) {// ascii: newline/#/=
return false;
}
if (b == 0x15) {// EBCDIC newline
return true;
}
}
// we found no ascii newline, '#', neither '=', relative safe to
// consider it
// as non-ascii, the only exception will be a single line with only
// key(no value and '=')
// in this case, it should be no harm to read it in default charset
return false;
}

/**
* Loads properties from the specified InputStream. The properties are of
* the form <code>key=value</code>, one property per line. It may be not
Expand Down Expand Up @@ -323,7 +297,7 @@ private synchronized CrashReportData load(Reader reader) throws IOException {
}
crashData.put(key, value);
}

CollectorUtil.safeClose(reader);

return crashData;
Expand Down

0 comments on commit c1c0416

Please sign in to comment.