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 #289, remove unnecessary isEbcdic check #294

Merged
merged 1 commit into from
Jul 20, 2015
Merged
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
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