Skip to content

Commit

Permalink
PDFBOX-5660: fix logging exception parameter type
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1918836 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Jul 2, 2024
1 parent 941cf8d commit 799004d
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private byte[] getTSAResponse(byte[] request) throws IOException
}
catch (IOException ex)
{
LOG.error("Exception when writing to {}", this.url, ex);
LOG.error(() -> "Exception when writing to " + this.url, ex);
throw ex;
}

Expand All @@ -196,7 +196,7 @@ private byte[] getTSAResponse(byte[] request) throws IOException
}
catch (IOException ex)
{
LOG.error("Exception when reading from {}", this.url, ex);
LOG.error(() -> "Exception when reading from " + this.url, ex);
throw ex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private void getAlternativeIssuerCertificate(CertSignatureInformation certInfo,
}
catch (IOException | URISyntaxException | CertificateException e)
{
LOG.error("Error getting alternative issuer certificate from {}", certInfo.issuerUrl,
LOG.error(() -> "Error getting alternative issuer certificate from " + certInfo.issuerUrl,
e);
}
}
Expand Down
12 changes: 6 additions & 6 deletions io/src/main/java/org/apache/pdfbox/io/ScratchFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ public static ScratchFile getMainMemoryOnlyInstance()
catch (IOException ioe)
{
// cannot happen for main memory setup
LOG.error(
"Unexpected exception occurred creating main memory scratch file instance: {}",
ioe.getMessage(), ioe);
LOG.error(() ->
"Unexpected exception occurred creating main memory scratch file instance: " +
ioe.getMessage(), ioe);
return null;
}
}
Expand All @@ -180,9 +180,9 @@ public static ScratchFile getMainMemoryOnlyInstance(long maxMainMemoryBytes)
catch (IOException ioe)
{
// cannot happen for main memory setup
LOG.error(
"Unexpected exception occurred creating main memory scratch file instance: {}",
ioe.getMessage(), ioe);
LOG.error(() ->
"Unexpected exception occurred creating main memory scratch file instance: " +
ioe.getMessage(), ioe);
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public COSBase getObject()
}
catch (IOException e)
{
LOG.error("Can't dereference {}", this, e);
LOG.error(() -> "Can't dereference " + this, e);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ protected COSBase parseObjectStreamObject(long objstmObjNr, COSObjectKey key) th
{
if (isLenient)
{
LOG.error("object stream {} could not be parsed due to an exception",
LOG.error(() -> "object stream {} could not be parsed due to an exception" +
objstmObjNr, ex);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public COSDictionary parseXref(COSDocument document, long startXRefOffset) throw
}
catch (IOException ex)
{
LOG.error("Failed to parse /XRefStm at offset {}", streamOffset, ex);
LOG.error("Failed to parse /XRefStm at offset " + streamOffset, ex);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public PDCIDFontType0(COSDictionary fontDictionary, PDType0Font parent) throws I
}
catch (IOException e)
{
LOG.error("Can't read the embedded CFF font {}", fd.getFontName(), e);
LOG.error(() -> "Can't read the embedded CFF font " + fd.getFontName(), e);
fontIsDamaged = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private CMap loadUnicodeCmap()
}
catch (IOException ex)
{
LOG.error("Could not read ToUnicode CMap in font {}", getName(), ex);
LOG.error(() -> "Could not read ToUnicode CMap in font " + getName(), ex);
}
return cmap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public PDType1CFont(COSDictionary fontDictionary) throws IOException
}
catch (IOException e)
{
LOG.error("Can't read the embedded Type1C font {}", getName(), e);
LOG.error(() -> "Can't read the embedded Type1C font " + getName(), e);
fontIsDamaged = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ public PDType1Font(COSDictionary fontDictionary) throws IOException
}
catch (DamagedFontException e)
{
LOG.warn("Can't read damaged embedded Type1 font {}", fd.getFontName(), e);
LOG.warn(() -> "Can't read damaged embedded Type1 font " + fd.getFontName(), e);
fontIsDamaged = true;
}
catch (IOException e)
{
LOG.error("Can't read the embedded Type1 font {}", fd.getFontName(), e);
LOG.error(() -> "Can't read the embedded Type1 font " + fd.getFontName(), e);
fontIsDamaged = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public AxialShadingContext(PDShadingType2 shading, ColorModel colorModel, Affine
}
catch (NoninvertibleTransformException ex)
{
LOG.error("{}, matrix: {}", ex.getMessage(), matrix, ex);
LOG.error(() -> ex.getMessage() + ", matrix: " + matrix, ex);
rat = new AffineTransform();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public RadialShadingContext(PDShadingType3 shading, ColorModel colorModel,
}
catch (NoninvertibleTransformException ex)
{
LOG.error("{}, matrix: {}", ex.getMessage(), matrix, ex);
LOG.error(() -> ex.getMessage() + ", matrix: " + matrix, ex);
rat = new AffineTransform();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Type1ShadingContext extends ShadingContext
}
catch (NoninvertibleTransformException ex)
{
LOG.error("{}, matrix: {}", ex.getMessage(), matrix, ex);
LOG.error(() -> ex.getMessage() + ", matrix: " + matrix, ex);
rat = new AffineTransform();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void generateNormalAppearance()
catch (IllegalArgumentException ex)
{
// Adobe Reader displays placeholders instead
LOG.error("line text '{}' can't be shown", annotation.getContents(), ex);
LOG.error(() -> "line text '" + annotation.getContents() + "' can't be shown", ex);
}
float xOffset = (lineLength - contentLength) / 2;
float yOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ else if (font instanceof PDSimpleFont)
{
// todo: escalate this error?
String fontName = ((PDFontLike) font).getName();
LOG.error("Glyph rendering failed for code {} in font {}", code, fontName, e);
LOG.error(() -> "Glyph rendering failed for code " + code + " in font " + fontName, e);
return new GeneralPath();
}
}
Expand Down
2 changes: 1 addition & 1 deletion pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public static byte[] decodeHex(String s)
}
catch (NumberFormatException ex)
{
LOG.error("Can't parse {}, aborting decode", hexByte, ex);
LOG.error(() -> "Can't parse " + hexByte + ", aborting decode", ex);
break;
}
i += 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ else if (!filesAreIdentical(outFile, inFile))
{
new FileOutputStream(new File(outDir, file.getName() + ".cmperror")).close();
failed = true;
LOG.error("Error comparing file output for " + file.getName(), e);
LOG.error(() -> "Error comparing file output for " + file.getName(), e);
}

return !failed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void extractPages(int startPage, int endPage,
{
throw ex;
}
LOG.error("Failed to process page {}", p, ex);
LOG.error("Failed to process page " + p, ex);
}
}
}
Expand Down

0 comments on commit 799004d

Please sign in to comment.