ASF Bugzilla – Attachment 29540 Details for
Bug 52628
[PATCH] Replace System.err calls with Logger call
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch against rev 1404603
patch_SysErr.patch (text/plain), 19.90 KB, created by
Jeremy
on 2012-11-01 18:55:44 UTC
(
hide
)
Description:
Patch against rev 1404603
Filename:
MIME Type:
Creator:
Jeremy
Created:
2012-11-01 18:55:44 UTC
Size:
19.90 KB
patch
obsolete
>Index: src/java/org/apache/poi/hpsf/HPSFRuntimeException.java >=================================================================== >--- src/java/org/apache/poi/hpsf/HPSFRuntimeException.java (revision 1404603) >+++ src/java/org/apache/poi/hpsf/HPSFRuntimeException.java (working copy) >@@ -17,8 +17,6 @@ > > package org.apache.poi.hpsf; > >-import java.io.PrintStream; >-import java.io.PrintWriter; > > /** > * <p>This exception is the superclass of all other unchecked >@@ -30,8 +28,8 @@ > */ > public class HPSFRuntimeException extends RuntimeException > { >- >- /** <p>The underlying reason for this exception - may be >+ private static final long serialVersionUID = -7804271670232727159L; >+ /** <p>The underlying reason for this exception - may be > * <code>null</code>.</p> */ > private Throwable reason; > >@@ -105,44 +103,44 @@ > > > >- /** >- * @see Throwable#printStackTrace() >- */ >- public void printStackTrace() >- { >- printStackTrace(System.err); >- } >+// /** >+// * @see Throwable#printStackTrace() >+// */ >+// public void printStackTrace() >+// { >+// printStackTrace(System.err); >+// } > > > >- /** >- * @see Throwable#printStackTrace(java.io.PrintStream) >- */ >- public void printStackTrace(final PrintStream p) >- { >- final Throwable reason = getReason(); >- super.printStackTrace(p); >- if (reason != null) >- { >- p.println("Caused by:"); >- reason.printStackTrace(p); >- } >- } >+// /** >+// * @see Throwable#printStackTrace(java.io.PrintStream) >+// */ >+// public void printStackTrace(final PrintStream p) >+// { >+// final Throwable reason = getReason(); >+// super.printStackTrace(p); >+// if (reason != null) >+// { >+// p.println("Caused by:"); >+// reason.printStackTrace(p); >+// } >+// } > > > >- /** >- * @see Throwable#printStackTrace(java.io.PrintWriter) >- */ >- public void printStackTrace(final PrintWriter p) >- { >- final Throwable reason = getReason(); >- super.printStackTrace(p); >- if (reason != null) >- { >- p.println("Caused by:"); >- reason.printStackTrace(p); >- } >- } >+// /** >+// * @see Throwable#printStackTrace(java.io.PrintWriter) >+// */ >+// public void printStackTrace(final PrintWriter p) >+// { >+// final Throwable reason = getReason(); >+// super.printStackTrace(p); >+// if (reason != null) >+// { >+// p.println("Caused by:"); >+// reason.printStackTrace(p); >+// } >+// } > > } >Index: src/java/org/apache/poi/hpsf/VariantSupport.java >=================================================================== >--- src/java/org/apache/poi/hpsf/VariantSupport.java (revision 1404603) >+++ src/java/org/apache/poi/hpsf/VariantSupport.java (working copy) >@@ -24,6 +24,9 @@ > import java.util.LinkedList; > import java.util.List; > >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; >+ > /** > * <p>Supports reading and writing of variant data.</p> > * >@@ -45,7 +48,7 @@ > */ > public class VariantSupport extends Variant > { >- >+ private static POILogger logger = POILogFactory.getLogger(VariantSupport.class); > private static boolean logUnsupportedTypes = false; > > /** >@@ -78,7 +81,7 @@ > * <p>Keeps a list of the variant types an "unsupported" message has already > * been issued for.</p> > */ >- protected static List unsupportedMessage; >+ protected static List<Long> unsupportedMessage; > > /** > * <p>Writes a warning to <code>System.err</code> that a variant type is >@@ -93,11 +96,11 @@ > if (isLogUnsupportedTypes()) > { > if (unsupportedMessage == null) >- unsupportedMessage = new LinkedList(); >+ unsupportedMessage = new LinkedList<Long>(); > Long vt = Long.valueOf(ex.getVariantType()); > if (!unsupportedMessage.contains(vt)) > { >- System.err.println(ex.getMessage()); >+ logger.log( POILogger.ERROR, ex.getMessage()); > unsupportedMessage.add(vt); > } > } >Index: src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java >=================================================================== >--- src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java (working copy) >@@ -31,6 +31,8 @@ > import org.apache.poi.hssf.record.Record; > import org.apache.poi.hssf.usermodel.HSSFDataFormat; > import org.apache.poi.hssf.usermodel.HSSFDataFormatter; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > > /** > * A proxy HSSFListener that keeps track of the document formatting records, and >@@ -38,6 +40,7 @@ > * ids. > */ > public class FormatTrackingHSSFListener implements HSSFListener { >+ private static POILogger logger = POILogFactory.getLogger(FormatTrackingHSSFListener.class); > private final HSSFListener _childListener; > private final HSSFDataFormatter _formatter; > private final NumberFormat _defaultFormat; >@@ -137,7 +140,7 @@ > if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) { > FormatRecord tfr = _customFormatRecords.get(Integer.valueOf(formatIndex)); > if (tfr == null) { >- System.err.println("Requested format at index " + formatIndex >+ logger.log( POILogger.ERROR, "Requested format at index " + formatIndex > + ", but it wasn't found"); > } else { > format = tfr.getFormatString(); >@@ -167,7 +170,7 @@ > public int getFormatIndex(CellValueRecordInterface cell) { > ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex()); > if (xfr == null) { >- System.err.println("Cell " + cell.getRow() + "," + cell.getColumn() >+ logger.log( POILogger.ERROR, "Cell " + cell.getRow() + "," + cell.getColumn() > + " uses XF with index " + cell.getXFIndex() + ", but we don't have that"); > return -1; > } >Index: src/java/org/apache/poi/hssf/record/common/UnicodeString.java >=================================================================== >--- src/java/org/apache/poi/hssf/record/common/UnicodeString.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/record/common/UnicodeString.java (working copy) >@@ -179,7 +179,7 @@ > > int extraDataLength = runData - (numRuns*6); > if(extraDataLength < 0) { >- System.err.println("Warning - ExtRst overran by " + (0-extraDataLength) + " bytes"); >+ _logger.log( POILogger.WARN, "Warning - ExtRst overran by " + (0-extraDataLength) + " bytes"); > extraDataLength = 0; > } > extraData = new byte[extraDataLength]; >Index: src/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java >=================================================================== >--- src/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java (working copy) >@@ -29,6 +29,8 @@ > import org.apache.poi.util.LittleEndianInput; > import org.apache.poi.util.LittleEndianInputStream; > import org.apache.poi.util.LittleEndianOutput; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > import org.apache.poi.util.StringUtil; > > /** >@@ -39,6 +41,7 @@ > * @author Daniel Noll > */ > public final class EmbeddedObjectRefSubRecord extends SubRecord { >+ private static POILogger logger = POILogFactory.getLogger(EmbeddedObjectRefSubRecord.class); > public static final short sid = 0x0009; > > private static final byte[] EMPTY_BYTE_ARRAY = { }; >@@ -137,7 +140,7 @@ > int nUnexpectedPadding = remaining - dataLenAfterFormula; > > if (nUnexpectedPadding > 0) { >- System.err.println("Discarding " + nUnexpectedPadding + " unexpected padding bytes "); >+ logger.log( POILogger.ERROR, "Discarding " + nUnexpectedPadding + " unexpected padding bytes "); > readRawData(in, nUnexpectedPadding); > remaining-=nUnexpectedPadding; > } >Index: src/java/org/apache/poi/hssf/record/FeatRecord.java >=================================================================== >--- src/java/org/apache/poi/hssf/record/FeatRecord.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/record/FeatRecord.java (working copy) >@@ -24,6 +24,8 @@ > import org.apache.poi.hssf.record.common.SharedFeature; > import org.apache.poi.ss.util.CellRangeAddress; > import org.apache.poi.util.LittleEndianOutput; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > > /** > * Title: Feat (Feature) Record >@@ -32,6 +34,7 @@ > * up with a {@link FeatHdrRecord}. > */ > public final class FeatRecord extends StandardRecord { >+ private static POILogger logger = POILogFactory.getLogger(FeatRecord.class); > public final static short sid = 0x0868; > > private FtrHeader futureHeader; >@@ -90,7 +93,7 @@ > sharedFeature = new FeatSmartTag(in); > break; > default: >- System.err.println("Unknown Shared Feature " + isf_sharedFeatureType + " found!"); >+ logger.log( POILogger.ERROR, "Unknown Shared Feature " + isf_sharedFeatureType + " found!"); > } > } > >Index: src/java/org/apache/poi/hssf/record/HyperlinkRecord.java >=================================================================== >--- src/java/org/apache/poi/hssf/record/HyperlinkRecord.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/record/HyperlinkRecord.java (working copy) >@@ -41,7 +41,7 @@ > */ > public final class HyperlinkRecord extends StandardRecord { > public final static short sid = 0x01B8; >- private POILogger logger = POILogFactory.getLogger(getClass()); >+ private static POILogger logger = POILogFactory.getLogger(HyperlinkRecord.class); > > static final class GUID { > /* >@@ -641,7 +641,7 @@ > if (false) { // Quite a few examples in the unit tests which don't have the exact expected tail > for (int i = 0; i < expectedTail.length; i++) { > if (expectedTail[i] != result[i]) { >- System.err.println("Mismatch in tail byte [" + i + "]" >+ logger.log( POILogger.ERROR, "Mismatch in tail byte [" + i + "]" > + "expected " + (expectedTail[i] & 0xFF) + " but got " + (result[i] & 0xFF)); > } > } >Index: src/java/org/apache/poi/hssf/record/SSTDeserializer.java >=================================================================== >--- src/java/org/apache/poi/hssf/record/SSTDeserializer.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/record/SSTDeserializer.java (working copy) >@@ -21,6 +21,8 @@ > > import org.apache.poi.hssf.record.common.UnicodeString; > import org.apache.poi.util.IntMapper; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > > /** > * Handles the task of deserializing a SST string. The two main entry points are >@@ -30,7 +32,7 @@ > */ > class SSTDeserializer > { >- >+ private static POILogger logger = POILogFactory.getLogger(SSTDeserializer.class); > private IntMapper<UnicodeString> strings; > > public SSTDeserializer( IntMapper<UnicodeString> strings ) >@@ -49,7 +51,7 @@ > // Extract exactly the count of strings from the SST record. > UnicodeString str; > if(in.available() == 0 && ! in.hasNextRecord()) { >- System.err.println("Ran out of data before creating all the strings! String at index " + i + ""); >+ logger.log( POILogger.ERROR, "Ran out of data before creating all the strings! String at index " + i + ""); > str = new UnicodeString(""); > } else { > str = new UnicodeString(in); >Index: src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java >=================================================================== >--- src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java (working copy) >@@ -34,6 +34,8 @@ > import org.apache.poi.ss.formula.FormulaRenderingWorkbook; > import org.apache.poi.ss.formula.FormulaType; > import org.apache.poi.ss.formula.udf.UDFFinder; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > > /** > * Internal POI use only >@@ -41,7 +43,7 @@ > * @author Josh Micich > */ > public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook { >- >+ private static POILogger logger = POILogFactory.getLogger(HSSFEvaluationWorkbook.class); > private final HSSFWorkbook _uBook; > private final InternalWorkbook _iBook; > >@@ -139,7 +141,7 @@ > // Note - as of Bugzilla 48036 (svn r828244, r828247) POI is capable of evaluating > // IntesectionPtg. However it is still not capable of parsing it. > // So FormulaEvalTestData.xls now contains a few formulas that produce errors here. >- System.err.println(e.getMessage()); >+ logger.log( POILogger.ERROR, e.getMessage()); > } > } > FormulaRecordAggregate fra = (FormulaRecordAggregate) cell.getCellValueRecord(); >Index: src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java >=================================================================== >--- src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java (working copy) >@@ -27,6 +27,8 @@ > import org.apache.poi.hssf.record.ObjRecord; > import org.apache.poi.ss.usermodel.Picture; > import org.apache.poi.ss.util.ImageUtils; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > import org.apache.poi.hssf.model.InternalWorkbook; > > /** >@@ -36,6 +38,8 @@ > * @author Yegor Kozlov (yegor at apache.org) > */ > public class HSSFPicture extends HSSFSimpleShape implements Picture { >+ private static POILogger logger = POILogFactory.getLogger(HSSFPicture.class); >+ > public static final int PICTURE_TYPE_EMF = HSSFWorkbook.PICTURE_TYPE_EMF; // Windows Enhanced Metafile > public static final int PICTURE_TYPE_WMF = HSSFWorkbook.PICTURE_TYPE_WMF; // Windows Metafile > public static final int PICTURE_TYPE_PICT = HSSFWorkbook.PICTURE_TYPE_PICT; // Macintosh PICT >@@ -283,7 +287,7 @@ > EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, true, data.getBytes("UTF-16LE")); > setPropertyValue(prop); > } catch (UnsupportedEncodingException e) { >- System.out.println("Unsupported encoding: UTF-16LE"); >+ logger.log( POILogger.ERROR, "Unsupported encoding: UTF-16LE"); > } > } > >Index: src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java >=================================================================== >--- src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java (revision 1404603) >+++ src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java (working copy) >@@ -20,12 +20,14 @@ > import org.apache.poi.ddf.*; > import org.apache.poi.hssf.record.*; > import org.apache.poi.util.LittleEndian; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > > /** > * @author Glen Stampoultzis (glens at superlinksoftware.com) > */ > public class HSSFPolygon extends HSSFSimpleShape { >- >+ private static POILogger logger = POILogFactory.getLogger(HSSFPolygon.class); > public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 0x1E; > > public HSSFPolygon(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord _textObjectRecord) { >@@ -157,11 +159,11 @@ > */ > public void setPoints(int[] xPoints, int[] yPoints) { > if (xPoints.length != yPoints.length){ >- System.out.println("xPoint.length must be equal to yPoints.length"); >+ logger.log( POILogger.ERROR, "xPoint.length must be equal to yPoints.length"); > return; > } > if (xPoints.length == 0){ >- System.out.println("HSSFPolygon must have at least one point"); >+ logger.log( POILogger.ERROR, "HSSFPolygon must have at least one point"); > } > EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] ); > verticesProp.setNumberOfElementsInArray(xPoints.length+1); >Index: src/java/org/apache/poi/POIDocument.java >=================================================================== >--- src/java/org/apache/poi/POIDocument.java (revision 1404603) >+++ src/java/org/apache/poi/POIDocument.java (working copy) >@@ -221,7 +221,7 @@ > > logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length); > } catch(org.apache.poi.hpsf.WritingNotSupportedException wnse) { >- System.err.println("Couldn't write property set with name " + name + " as not supported by HPSF yet"); >+ logger.log( POILogger.ERROR, "Couldn't write property set with name " + name + " as not supported by HPSF yet"); > } > } > >Index: src/java/org/apache/poi/poifs/filesystem/EntryUtils.java >=================================================================== >--- src/java/org/apache/poi/poifs/filesystem/EntryUtils.java (revision 1404603) >+++ src/java/org/apache/poi/poifs/filesystem/EntryUtils.java (working copy) >@@ -36,7 +36,7 @@ > public static void copyNodeRecursively( Entry entry, DirectoryEntry target ) > throws IOException > { >- // System.err.println("copyNodeRecursively called with "+entry.getName()+ >+ // logger.log( POILogger.ERROR, "copyNodeRecursively called with "+entry.getName()+ > // ","+target.getName()); > DirectoryEntry newTarget = null; > if ( entry.isDirectoryEntry() ) >Index: src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java >=================================================================== >--- src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java (revision 1404603) >+++ src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java (working copy) >@@ -18,6 +18,8 @@ > package org.apache.poi.ss.formula.constant; > > import org.apache.poi.ss.usermodel.ErrorConstants; >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; > /** > * Represents a constant error code value as encoded in a constant values array. <p/> > * >@@ -27,6 +29,7 @@ > * @author Josh Micich > */ > public class ErrorConstant { >+ private static POILogger logger = POILogFactory.getLogger(ErrorConstant.class); > // convenient access to name space > private static final ErrorConstants EC = null; > >@@ -64,7 +67,7 @@ > case ErrorConstants.ERROR_NUM: return NUM; > case ErrorConstants.ERROR_NA: return NA; > } >- System.err.println("Warning - unexpected error code (" + errorCode + ")"); >+ logger.log( POILogger.WARN, "Warning - unexpected error code (" + errorCode + ")"); > return new ErrorConstant(errorCode); > } > public String toString() { >Index: src/java/org/apache/poi/ss/util/DateFormatConverter.java >=================================================================== >--- src/java/org/apache/poi/ss/util/DateFormatConverter.java (revision 1404603) >+++ src/java/org/apache/poi/ss/util/DateFormatConverter.java (working copy) >@@ -24,6 +24,9 @@ > import java.util.Locale; > import java.util.Map; > >+import org.apache.poi.util.POILogFactory; >+import org.apache.poi.util.POILogger; >+ > /** > * Convert java DateFormat patterns into Excel custom number formats. > * For example, to format a date in excel using the "dd MMMM, yyyy" pattern and Japanese >@@ -45,6 +48,7 @@ > * > */ > public class DateFormatConverter { >+ private static POILogger logger = POILogFactory.getLogger(DateFormatConverter.class); > > public static class DateFormatTokenizer { > String format; >@@ -329,7 +333,7 @@ > result = localePrefixes.get( localeString.substring( 0, 2 ) ); > if( result == null ) { > Locale parentLocale = new Locale(localeString.substring( 0, 2 )); >- System.out.println( "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or " >+ logger.log( POILogger.ERROR, "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or " > + localeString.substring( 0, 2 ) + "(" + parentLocale.getDisplayName() + ")" ); > return ""; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 52628
:
29540
|
29561