diff --git a/Dockerfile b/Dockerfile index b3e50c7412..018e66d8ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,8 @@ RUN --mount=type=cache,target=/home/gradle/.gradle \ COPY checkstyle_* ./ # '&& touch success || true' is a trick to be able to get out some artifacts RUN --mount=type=cache,target=/home/gradle/.gradle \ - (gradle :core:checkstyleMain :core:spotbugsMain :core:violations --stacktrace > /tmp/logs 2>&1) \ - && ( (gradle :core:build :core:explodedWar :core:libSourcesJar :core:libJavadocJar && touch success) || true) + (gradle :core:checkstyleMain :core:spotbugsMain :core:violations --stacktrace) \ + && ( (gradle :core:build :core:explodedWar :core:libSourcesJar :core:libJavadocJar > /tmp/logs 2>&1 && touch success) || true) ARG GIT_HEAD ENV GIT_HEAD=${GIT_HEAD} @@ -39,6 +39,6 @@ RUN --mount=type=cache,target=/home/gradle/.gradle \ FROM builder AS test-builder -RUN cat /tmp/logs && [ -e success ] && [ -e success-publish ] && [ -e success-examples-docs ] +RUN cat /tmp/logs && ls success success-publish success-examples-docs VOLUME [ "/src/core" ] diff --git a/core/src/main/java/org/mapfish/print/attribute/ReflectiveAttribute.java b/core/src/main/java/org/mapfish/print/attribute/ReflectiveAttribute.java index 382a76837b..61a216f783 100644 --- a/core/src/main/java/org/mapfish/print/attribute/ReflectiveAttribute.java +++ b/core/src/main/java/org/mapfish/print/attribute/ReflectiveAttribute.java @@ -24,6 +24,7 @@ import org.mapfish.print.wrapper.yaml.PYamlObject; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -331,8 +332,9 @@ private void encodeAttributeValue( } } else { try { - value = typeOrComponentType.newInstance(); - } catch (InstantiationException e) { + value = typeOrComponentType.getDeclaredConstructor().newInstance(); + } catch (InvocationTargetException | NoSuchMethodException + | InstantiationException e) { throw ExceptionUtils.getRuntimeException(e); } } diff --git a/core/src/main/java/org/mapfish/print/cli/CliServletContext.java b/core/src/main/java/org/mapfish/print/cli/CliServletContext.java index 7c24442fd9..d3fadb1e7a 100644 --- a/core/src/main/java/org/mapfish/print/cli/CliServletContext.java +++ b/core/src/main/java/org/mapfish/print/cli/CliServletContext.java @@ -84,16 +84,19 @@ public RequestDispatcher getNamedDispatcher(String name) { } @Override + @Deprecated public Servlet getServlet(String name) { return null; } @Override + @Deprecated public Enumeration getServlets() { return null; } @Override + @Deprecated public Enumeration getServletNames() { return null; } @@ -104,6 +107,7 @@ public void log(String msg) { } @Override + @Deprecated public void log(Exception exception, String msg) { } diff --git a/core/src/main/java/org/mapfish/print/map/geotools/function/FunctionFactory.java b/core/src/main/java/org/mapfish/print/map/geotools/function/FunctionFactory.java index 885bff7f24..fca2b09cb0 100644 --- a/core/src/main/java/org/mapfish/print/map/geotools/function/FunctionFactory.java +++ b/core/src/main/java/org/mapfish/print/map/geotools/function/FunctionFactory.java @@ -7,6 +7,7 @@ import org.opengis.filter.expression.Function; import org.opengis.filter.expression.Literal; +import java.lang.reflect.InvocationTargetException; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -30,10 +31,12 @@ public Function function(final String name, final List args, final L for (FunctionExpressionImpl template: FUNCTIONS) { if (template.getName().equals(name)) { try { - final FunctionExpressionImpl function = template.getClass().newInstance(); + final FunctionExpressionImpl function = template.getClass().getDeclaredConstructor() + .newInstance(); function.setParameters(args); return function; - } catch (InstantiationException | IllegalAccessException e) { + } catch (InvocationTargetException | NoSuchMethodException | InstantiationException + | IllegalAccessException e) { throw new RuntimeException(e); } } diff --git a/core/src/main/java/org/mapfish/print/parser/MapfishParser.java b/core/src/main/java/org/mapfish/print/parser/MapfishParser.java index b49bcda196..b07ee4e1ec 100644 --- a/core/src/main/java/org/mapfish/print/parser/MapfishParser.java +++ b/core/src/main/java/org/mapfish/print/parser/MapfishParser.java @@ -237,10 +237,10 @@ private static Object parseValue( value = parseEnum(type, layer.getPath(fieldName), layer.getString(name)); } else { try { - value = type.newInstance(); + value = type.getDeclaredConstructor().newInstance(); PObject object = layer.getObject(name); parse(errorOnExtraProperties, object, value, extraPropertyToIgnore); - } catch (InstantiationException e) { + } catch (InvocationTargetException | NoSuchMethodException | InstantiationException e) { throw new UnsupportedTypeException(type, e); } catch (IllegalAccessException e) { throw ExceptionUtils.getRuntimeException(e); @@ -310,10 +310,10 @@ private static Object parseArrayValue( value = parseEnum(type, array.getPath("" + i), array.getString(i)); } else { try { - value = type.newInstance(); + value = type.getDeclaredConstructor().newInstance(); PObject object = array.getObject(i); parse(errorOnExtraProperties, object, value, extraPropertyToIgnore); - } catch (InstantiationException e) { + } catch (InvocationTargetException | NoSuchMethodException | InstantiationException e) { throw new UnsupportedTypeException(type, e); } catch (IllegalAccessException e) { throw ExceptionUtils.getRuntimeException(e); diff --git a/core/src/main/java/org/mapfish/print/processor/PdfConfigurationProcessor.java b/core/src/main/java/org/mapfish/print/processor/PdfConfigurationProcessor.java index 5c5d8c2a1a..33ac624db1 100644 --- a/core/src/main/java/org/mapfish/print/processor/PdfConfigurationProcessor.java +++ b/core/src/main/java/org/mapfish/print/processor/PdfConfigurationProcessor.java @@ -203,7 +203,7 @@ private Object getAttributeValue(final String attributeName, final Values values final Field field; try { field = value.getClass().getField(part); - if (!field.isAccessible()) { + if (!field.canAccess(value)) { field.setAccessible(true); } value = field.get(value); diff --git a/core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java b/core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java index 781cffdd51..24ef27739f 100644 --- a/core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java +++ b/core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java @@ -18,6 +18,7 @@ import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; import net.sf.jasperreports.engine.type.ScaleImageEnum; import net.sf.jasperreports.engine.type.StretchTypeEnum; +import net.sf.jasperreports.engine.type.TextAdjustEnum; import net.sf.jasperreports.engine.xml.JRXmlLoader; import net.sf.jasperreports.engine.xml.JRXmlWriter; @@ -426,7 +427,7 @@ private String generateSubReport( colHeaderField.setHeight(headerHeight); colHeaderField.setHorizontalTextAlign(HorizontalTextAlignEnum.LEFT); colHeaderField.setStyle(columnHeaderStyle); - colHeaderField.setStretchWithOverflow(true); + colHeaderField.setTextAdjust(TextAdjustEnum.STRETCH_HEIGHT); colHeaderField.setStretchType(StretchTypeEnum.ELEMENT_GROUP_HEIGHT); JRDesignExpression headerExpression = new JRDesignExpression(); @@ -495,7 +496,7 @@ private JRDesignTextField createTextField(final String columnName) { JRDesignExpression expression = new JRDesignExpression(); expression.setText("$F{" + columnName + "}"); textField.setExpression(expression); - textField.setStretchWithOverflow(true); + textField.setTextAdjust(TextAdjustEnum.STRETCH_HEIGHT); return textField; } diff --git a/core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java b/core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java index d8c77effea..109bbfc0b2 100644 --- a/core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java +++ b/core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java @@ -15,7 +15,6 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.nio.channels.ClosedByInterruptException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -74,12 +73,14 @@ public final synchronized MapPrinter create(@Nullable final String app) throws N } if (configFile == null) { - LOGGER.error( - "There is no configurationFile registered in the {}" + - " bean with the id: '{}' from configurationFiles:\n {}", - getClass().getName(), finalApp, - String.join("\n", this.configurationFiles.keySet()) - ); + if (LOGGER.isErrorEnabled()) { + LOGGER.error( + "There is no configurationFile registered in the {}" + + " bean with the id: '{}' from configurationFiles:\n {}", + getClass().getName(), finalApp, + String.join("\n", this.configurationFiles.keySet()) + ); + } throw new NoSuchAppException( "There is no configurationFile registered in the " + getClass().getName() + " bean with the id: '" + finalApp + "'"); @@ -127,17 +128,6 @@ public final synchronized MapPrinter create(@Nullable final String app) throws N printer.setConfiguration(configFile, bytes); this.printers.put(finalApp, printer); - } catch (ClosedByInterruptException e) { - // because of a bug in the JDK, the interrupted status might not be set - // when throwing a ClosedByInterruptException. so, we do it manually. - // see also http://bugs.java.com/view_bug.do?bug_id=7043425 - Thread.currentThread().interrupt(); - LOGGER.error( - "Error occurred while reading configuration file '{}', '{}'", configFile, e.getMessage() - ); - throw new RuntimeException(String.format( - "Error occurred while reading configuration file '%s': ", configFile), - e); } catch (Throwable e) { LOGGER.error( "Error occurred while reading configuration file '{}', '{}'", configFile, e.getMessage() @@ -285,4 +275,5 @@ protected boolean handleDirectory( return depth < MAX_DEPTH; } } + }