Skip to content

Commit 9eb8df0

Browse files
committed
Refactor log messages with non-initialized occupied area
The message has been changed to a generic one and explanations are added in-place whenever needed DEVSIX-1381
1 parent 1dfb78f commit 9eb8df0

File tree

8 files changed

+16
-8
lines changed

8 files changed

+16
-8
lines changed

io/src/main/java/com/itextpdf/io/LogMessageConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public final class LogMessageConstant {
8989
public static final String PDF_READER_CLOSING_FAILED = "PdfReader closing failed due to the error occurred!";
9090
public static final String PDF_WRITER_CLOSING_FAILED = "PdfWriter closing failed due to the error occurred!";
9191
public static final String POPUP_ENTRY_IS_NOT_POPUP_ANNOTATION = "Popup entry in the markup annotations refers not to the annotation with Popup subtype.";
92-
public static final String OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED = "Occupied area hasn't been initialized. Drawing won't be performed";
92+
public static final String OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED = "Occupied area has not been initialized. {0}";
9393
public static final String OCSP_STATUS_IS_REVOKED = "OCSP status is revoked.";
9494
public static final String OCSP_STATUS_IS_UNKNOWN = "OCSP status is unknown.";
9595
public static final String ONE_OF_GROUPED_SOURCES_CLOSING_FAILED = "Closing of one of the grouped sources failed.";

layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ protected void alignChildHorizontally(IRenderer childRenderer, Rectangle current
10731073
}
10741074
} catch (NullPointerException npe) {
10751075
Logger logger = LoggerFactory.getLogger(AbstractRenderer.class);
1076-
logger.error(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED);
1076+
logger.error(MessageFormat.format(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Some of the children might not end up aligned horizontally."));
10771077
}
10781078
}
10791079
}

layout/src/main/java/com/itextpdf/layout/renderer/BlockRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ protected AbstractRenderer createOverflowRenderer(int layoutResult) {
472472
public void draw(DrawContext drawContext) {
473473
if (occupiedArea == null) {
474474
Logger logger = LoggerFactory.getLogger(BlockRenderer.class);
475-
logger.error(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED);
475+
logger.error(MessageFormat.format(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Drawing won't be performed."));
476476
return;
477477
}
478478

layout/src/main/java/com/itextpdf/layout/renderer/ImageRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ This file is part of the iText (R) project.
7070
import org.slf4j.Logger;
7171
import org.slf4j.LoggerFactory;
7272

73+
import java.text.MessageFormat;
7374
import java.util.List;
7475

7576
public class ImageRenderer extends AbstractRenderer implements ILeafElementRenderer {
@@ -264,7 +265,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
264265
public void draw(DrawContext drawContext) {
265266
if (occupiedArea == null) {
266267
Logger logger = LoggerFactory.getLogger(ImageRenderer.class);
267-
logger.error(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED);
268+
logger.error(MessageFormat.format(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Drawing won't be performed."));
268269
return;
269270
}
270271
applyMargins(occupiedArea.getBBox(), false);

layout/src/main/java/com/itextpdf/layout/renderer/LinkRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ This file is part of the iText (R) project.
4848
import org.slf4j.Logger;
4949
import org.slf4j.LoggerFactory;
5050

51+
import java.text.MessageFormat;
52+
5153
public class LinkRenderer extends TextRenderer {
5254

5355
/**
@@ -73,7 +75,7 @@ public LinkRenderer(Link linkElement, String text) {
7375
public void draw(DrawContext drawContext) {
7476
if (occupiedArea == null) {
7577
Logger logger = LoggerFactory.getLogger(LinkRenderer.class);
76-
logger.error(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED);
78+
logger.error(MessageFormat.format(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Drawing won't be performed."));
7779
return;
7880
}
7981
super.draw(drawContext);

layout/src/main/java/com/itextpdf/layout/renderer/ListItemRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ This file is part of the iText (R) project.
5858
import org.slf4j.Logger;
5959
import org.slf4j.LoggerFactory;
6060

61+
import java.text.MessageFormat;
62+
6163
public class ListItemRenderer extends DivRenderer {
6264

6365
protected IRenderer symbolRenderer;
@@ -96,7 +98,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
9698
public void draw(DrawContext drawContext) {
9799
if (occupiedArea == null) {
98100
Logger logger = LoggerFactory.getLogger(ListItemRenderer.class);
99-
logger.error(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED);
101+
logger.error(MessageFormat.format(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Drawing won't be performed."));
100102
return;
101103
}
102104
boolean isTagged = drawContext.isTaggingEnabled() && getModelElement() instanceof IAccessibleElement;

layout/src/main/java/com/itextpdf/layout/renderer/TabRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ This file is part of the iText (R) project.
5555
import org.slf4j.Logger;
5656
import org.slf4j.LoggerFactory;
5757

58+
import java.text.MessageFormat;
59+
5860
public class TabRenderer extends AbstractRenderer {
5961
/**
6062
* Creates a TabRenderer from its corresponding layout object
@@ -80,7 +82,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
8082
public void draw(DrawContext drawContext) {
8183
if (occupiedArea == null) {
8284
Logger logger = LoggerFactory.getLogger(TabRenderer.class);
83-
logger.error(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED);
85+
logger.error(MessageFormat.format(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Drawing won't be performed."));
8486
return;
8587
}
8688
ILineDrawer leader = this.<ILineDrawer>getProperty(Property.TAB_LEADER);

layout/src/main/java/com/itextpdf/layout/renderer/TextRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This file is part of the iText (R) project.
8787
import org.slf4j.Logger;
8888
import org.slf4j.LoggerFactory;
8989

90+
import java.text.MessageFormat;
9091
import java.util.ArrayList;
9192
import java.util.Collection;
9293
import java.util.Collections;
@@ -547,7 +548,7 @@ public void applyOtf() {
547548
public void draw(DrawContext drawContext) {
548549
if (occupiedArea == null) {
549550
Logger logger = LoggerFactory.getLogger(TextRenderer.class);
550-
logger.error(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED);
551+
logger.error(MessageFormat.format(LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Drawing won't be performed."));
551552
return;
552553
}
553554

0 commit comments

Comments
 (0)