Skip to content

Commit

Permalink
Make inner classes static to avoid memory leaks. Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr72 committed May 21, 2024
1 parent 14d2f54 commit 3dc6407
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/mapfish/print/FontTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static List<FontConfigDescription> listFontConfigFonts(final String famil

inputStreamReader = new InputStreamReader(process.getInputStream(), "utf-8");
stdInput = new BufferedReader(inputStreamReader);
String inputLine = null;
String inputLine;
FontConfigDescription description = null;
while ((inputLine = stdInput.readLine()) != null) {
if (inputLine.startsWith("Pattern ")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ public Map<String, Attribute> getAttributes() {
*/
public void setAttributes(final Map<String, Attribute> attributes) {
for (Map.Entry<String, Attribute> entry : attributes.entrySet()) {
Object attribute = entry.getValue();
if (!(attribute instanceof Attribute)) {
Attribute attribute = entry.getValue();
if (attribute == null) {
final String msg =
"Attribute: '" + entry.getKey() + "' is not an attribute. It is a: " + attribute;
"Attribute: '" + entry.getKey() + "' is not an attribute. It is a: " + null;
LOGGER.error("Error setting the Attributes: {}", msg);
throw new IllegalArgumentException(msg);
} else {
((Attribute) attribute).setConfigName(entry.getKey());
attribute.setConfigName(entry.getKey());
}
}
this.attributes = attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public final void setCreateSubReport(final Boolean createSubReport) {
}

/** The value of {@link NorthArrowAttribute}. */
public class NorthArrowAttributeValues {
public static class NorthArrowAttributeValues {

private static final String DEFAULT_BACKGROUND_COLOR = "rgba(255, 255, 255, 0)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ private void encodeAttributeValue(
json.value(valueToAdd);
}
if (type.isArray()) {
json.key(JSON_ATTRIBUTE_IS_ARRAY).value(type.isArray());
json.key(JSON_ATTRIBUTE_IS_ARRAY).value(true);
}

json.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public final void setCreateSubReport(final Boolean createSubReport) {
}

/** The value of {@link ScalebarAttribute}. */
public class ScalebarAttributeValues {
public static class ScalebarAttributeValues {

private static final int DEFAULT_INTERVALS = 3;
private static final String DEFAULT_FONT = "Helvetica";
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/org/mapfish/print/config/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ public final Map<String, Attribute> getAttributes() {
*/
public final void setAttributes(final Map<String, Attribute> attributes) {
for (Map.Entry<String, Attribute> entry : attributes.entrySet()) {
Object attribute = entry.getValue();
if (!(attribute instanceof Attribute)) {
Attribute attribute = entry.getValue();
if (attribute == null) {
final String msg =
"Attribute: '" + entry.getKey() + "' is not an attribute. It is a: " + attribute;
"Attribute: '" + entry.getKey() + "' is not an attribute. It is a: " + null;
LOGGER.error("Error setting the Attributes: {}", msg);
throw new IllegalArgumentException(msg);
} else {
((Attribute) attribute).setConfigName(entry.getKey());
attribute.setConfigName(entry.getKey());
}
}
this.attributes = attributes;
Expand Down Expand Up @@ -168,9 +168,9 @@ public final void setProcessors(final List<Processor> processors) {

private void assertProcessors(final List<Processor> processorsToCheck) {
for (Processor entry : processorsToCheck) {
if (!(entry instanceof Processor)) {
final String msg = "Processor: " + entry + " is not a processor.";
LOGGER.error("Error setting the Attributes: {}", msg);
if (entry == null) {
final String msg = "Processor: " + null + " is not a processor.";
LOGGER.error("Error in the processors to check while setting the Attributes: {}", msg);
throw new IllegalArgumentException(msg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static GridLabelFormat fromConfig(final GridParam param) {

/** Label format where value and unit are formatted at once. */
public static class Simple extends GridLabelFormat {
private String labelFormat = null;
private final String labelFormat;

/**
* Constructor.
Expand Down Expand Up @@ -77,7 +77,7 @@ public Detailed(

@Override
public final String format(final double value, final String unit) {
DecimalFormat decimalFormat = null;
DecimalFormat decimalFormat;

if (this.formatDecimalSeparator != null || this.formatGroupingSeparator != null) {
// if custom separator characters are given, use them to create the format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public final class MapfishJsonStyleVersion2 {
static final String JSON_SYMB = "symbolizers";
private static final String JSON_TYPE = "type";
private static final Pattern VALUE_EXPR_PATTERN = Pattern.compile("\\$\\{([\\w\\d_-]+)\\}");
private static final Pattern VALUE_EXPR_PATTERN = Pattern.compile("\\$\\{([\\w_-]+)\\}");
private static final String JSON_MIN_SCALE = "minScale";
private static final String JSON_MAX_SCALE = "maxScale";
private static final String JSON_FILTER_INCLUDE = "*";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,18 @@ public TilePreparationInfo call() {
}
} else {
if (LOGGER.isDebugEnabled()) {
if (tileBounds != null && tileCacheBounds != null) {
LOGGER.debug(
"Tile '{}' bounds [{}, {}, {}, {}] out of tile cache bounds [{}, {}, {},"
+ " {}]",
tileRequest == null ? "-" : tileRequest.getURI(),
tileBounds.getMinX(),
tileBounds.getMinY(),
tileBounds.getMaxX(),
tileBounds.getMaxY(),
tileCacheBounds.getMinX(),
tileCacheBounds.getMinY(),
tileCacheBounds.getMaxX(),
tileCacheBounds.getMaxY());
} else {
LOGGER.debug(
"Tile '{}' with missing bounds.",
tileRequest == null ? "-" : tileRequest.getURI());
}
LOGGER.debug(
"Tile '{}' bounds [{}, {}, {}, {}] out of tile cache bounds [{}, {}, {},"
+ " {}]",
tileRequest.getURI(),
tileBounds.getMinX(),
tileBounds.getMinY(),
tileBounds.getMaxX(),
tileBounds.getMaxY(),
tileCacheBounds.getMinX(),
tileCacheBounds.getMinY(),
tileCacheBounds.getMaxX(),
tileCacheBounds.getMaxY());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public final URI render(
settings.setPadding(getPadding(settings));

// start the rendering
File path = null;
File path;
if (template.getConfiguration().renderAsSvg(scalebarParams.renderAsSvg)) {
// render scalebar as SVG
final SVGGraphics2D graphics2D =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final Object assemble(final Serializable cached, final Object owner) {
@Override
public final Object deepCopy(final Object value) {
if (value == null) {
return value;
return null;
}
return ((AccessAssertion) value).copy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final Object assemble(final Serializable cached, final Object owner) {
@Override
public final Object deepCopy(final Object value) {
if (value == null) {
return value;
return null;
} else {
try {
return new PJsonObject(
Expand Down

0 comments on commit 3dc6407

Please sign in to comment.