Skip to content

Commit c1c0416

Browse files
Merge pull request #294 from pfn/master
fix #289, remove unnecessary isEbcdic check
2 parents 479e20f + c26e12c commit c1c0416

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

src/main/java/org/acra/CrashReportPersister.java

+3-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* java.util.Properties.java modified by Kevin Gaudin to allow usage of enums as keys.
3-
*
3+
*
44
* Licensed to the Apache Software Foundation (ASF) under one or more
55
* contributor license agreements. See the NOTICE file distributed with
66
* this work for additional information regarding copyright ownership.
@@ -69,15 +69,7 @@ public CrashReportData load(String fileName) throws IOException {
6969

7070
try {
7171
final BufferedInputStream bis = new BufferedInputStream(in, ACRAConstants.DEFAULT_BUFFER_SIZE_IN_BYTES);
72-
bis.mark(Integer.MAX_VALUE);
73-
final boolean isEbcdic = isEbcdic(bis);
74-
bis.reset();
75-
76-
if (!isEbcdic) {
77-
return load(new InputStreamReader(bis, "ISO8859-1")); //$NON-NLS-1$
78-
} else {
79-
return load(new InputStreamReader(bis)); //$NON-NLS-1$
80-
}
72+
return load(new InputStreamReader(bis, "ISO8859-1")); //$NON-NLS-1$
8173
} finally {
8274
in.close();
8375
}
@@ -114,24 +106,6 @@ public void store(CrashReportData crashData, String fileName) throws IOException
114106
}
115107
}
116108

117-
private boolean isEbcdic(BufferedInputStream in) throws IOException {
118-
byte b;
119-
while ((b = (byte) in.read()) != -1) {
120-
if (b == 0x23 || b == 0x0a || b == 0x3d) {// ascii: newline/#/=
121-
return false;
122-
}
123-
if (b == 0x15) {// EBCDIC newline
124-
return true;
125-
}
126-
}
127-
// we found no ascii newline, '#', neither '=', relative safe to
128-
// consider it
129-
// as non-ascii, the only exception will be a single line with only
130-
// key(no value and '=')
131-
// in this case, it should be no harm to read it in default charset
132-
return false;
133-
}
134-
135109
/**
136110
* Loads properties from the specified InputStream. The properties are of
137111
* the form <code>key=value</code>, one property per line. It may be not
@@ -323,7 +297,7 @@ private synchronized CrashReportData load(Reader reader) throws IOException {
323297
}
324298
crashData.put(key, value);
325299
}
326-
300+
327301
CollectorUtil.safeClose(reader);
328302

329303
return crashData;

0 commit comments

Comments
 (0)