Skip to content

Commit

Permalink
Merge pull request #2857 from mapfish/remove-warnings
Browse files Browse the repository at this point in the history
Remove some build warnings essentially deprecated warnings
  • Loading branch information
sbrunner authored Mar 15, 2023
2 parents c240ec1 + 313d312 commit d5661bb
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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" ]
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,19 @@ public RequestDispatcher getNamedDispatcher(String name) {
}

@Override
@Deprecated
public Servlet getServlet(String name) {
return null;
}

@Override
@Deprecated
public Enumeration<Servlet> getServlets() {
return null;
}

@Override
@Deprecated
public Enumeration<String> getServletNames() {
return null;
}
Expand All @@ -104,6 +107,7 @@ public void log(String msg) {
}

@Override
@Deprecated
public void log(Exception exception, String msg) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,10 +31,12 @@ public Function function(final String name, final List<Expression> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 + "'");
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -285,4 +275,5 @@ protected boolean handleDirectory(
return depth < MAX_DEPTH;
}
}

}

0 comments on commit d5661bb

Please sign in to comment.