Skip to content

Commit

Permalink
Cleanup code a bit, no refactoring (frankframework#5113)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsm5 authored Jul 14, 2023
1 parent f043601 commit b623b73
Show file tree
Hide file tree
Showing 29 changed files with 61 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import nl.nn.adapterframework.util.LogUtil;

/**
* Translates the request, adds required headers per action, creates a hash and signs the message.
*
* @author Niels Meijer
*/
public class NetStorageRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.logging.log4j.Logger;

import lombok.Getter;
import nl.nn.adapterframework.configuration.ConfigurationException;
Expand All @@ -46,7 +45,6 @@
import nl.nn.adapterframework.parameters.ParameterValueList;
import nl.nn.adapterframework.stream.Message;
import nl.nn.adapterframework.util.CredentialFactory;
import nl.nn.adapterframework.util.LogUtil;
import nl.nn.adapterframework.util.XmlBuilder;
import nl.nn.adapterframework.util.XmlUtils;

Expand All @@ -65,7 +63,6 @@
* @since 7.0-B4
*/
public class NetStorageSender extends HttpSenderBase {
private Logger log = LogUtil.getLogger(NetStorageSender.class);
private static final String URL_PARAM_KEY = "urlParameter";
public static final String DESTINATION_PARAM_KEY = "destination";
public static final String FILE_PARAM_KEY = "file";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public void setMainDocumentSessionKey(String mainDocumentSessionKey) {

@Deprecated
@ConfigurationWarning("attribute 'fileNameToAttachSessionKey' is replaced with 'filenameToAttachSessionKey'")
public void setFileNameToAttachSessionKey(String fileNameToAttachSessionKey) {
this.filenameToAttachSessionKey = fileNameToAttachSessionKey;
public void setFileNameToAttachSessionKey(String filenameToAttachSessionKey) {
this.filenameToAttachSessionKey = filenameToAttachSessionKey;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class RepositoryConnectorFactory extends AbstractServiceFactory {
public static final boolean CMIS_BRIDGE_ENABLED = AppConstants.getInstance().getBoolean(CMIS_BRIDGE_PROPERTY_PREFIX+"active", true);

private static final Logger LOG = LogUtil.getLogger(RepositoryConnectorFactory.class);
private ThreadLocal<CallContextAwareCmisService> threadLocalService = new ThreadLocal<>();
private static final ThreadLocal<CallContextAwareCmisService> CMIS_SERVICE = new ThreadLocal<>(); //1 service per appl-server HTTP connection pool thread.
private File tempDirectory = null;

@Override
Expand Down Expand Up @@ -73,10 +73,10 @@ public CmisService getService(CallContext context) {
LOG.debug("retrieve repository service");

// Make sure that each thread in the HTTP CONN POOL has it's own BridgedCmisService
CallContextAwareCmisService service = threadLocalService.get();
CallContextAwareCmisService service = CMIS_SERVICE.get();
if (service == null) {
service = new ConformanceCmisServiceWrapper(createService(context));
threadLocalService.set(service);
CMIS_SERVICE.set(service);
LOG.debug("stored repository service in local http-conn-thread");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2022 WeAreFrank!
Copyright 2022-2023 WeAreFrank!
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,9 +15,10 @@
*/
package nl.nn.adapterframework.align;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
Expand All @@ -41,11 +42,11 @@ public class NamespaceAligningFilter extends XMLFilterImpl {
protected Logger log = LogUtil.getLogger(this.getClass());

private XmlAligner aligner;
private Stack<ElementInfo> stack = new Stack<>();
private Deque<ElementInfo> stack = new ArrayDeque<>();

private Map<String,String> namespacePrefixes=new HashMap<>();

private class ElementInfo {
private static class ElementInfo {
String namespacePrefix;
String namespaceUri;
boolean namespacePrefixCreated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Properties2Xml extends Map2Xml<String,String,PropertyNode,Map<Strin

private Map<String,String> data;

protected class PropertyNode {
protected static class PropertyNode {
String value;
Map<String,String> attributes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void addContent(JsonElementContainer content) {
}
if (isXmlArrayContainer() && content.isRepeatedElement() && skipArrayElementContainers) {
if (array==null) {
array=new LinkedList<Object>();
array=new LinkedList<>();
setType(content.getType());
}
array.add(content.getContent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ protected String getLogPrefix() {
return "["+getName()+"] ";
}

public void setTimeout(int timeOut) {
this.timeout = timeOut;
public void setTimeout(int timeout) {
this.timeout = timeout;
}

public void setKeepAliveInterval(int keepAliveInterval) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
*/
public abstract class FileSystemBase<F> implements IBasicFileSystem<F> {
protected Logger log = LogUtil.getLogger(this);
protected final Logger log = LogUtil.getLogger(this);

private int maxNumberOfMessagesToList=-1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Set;

import nl.nn.adapterframework.configuration.ConfigurationException;
import nl.nn.adapterframework.core.HasPhysicalDestination;
import nl.nn.adapterframework.core.IDataIterator;
import nl.nn.adapterframework.core.PipeLineSession;
import nl.nn.adapterframework.core.PipeStartException;
Expand Down Expand Up @@ -150,8 +149,8 @@ protected Message itemToMessage(A item) throws SenderException {
}

public String getPhysicalDestinationName() {
if (getFileSystem() instanceof HasPhysicalDestination) {
return ((HasPhysicalDestination)getFileSystem()).getPhysicalDestinationName();
if (getFileSystem() != null) {
return getFileSystem().getPhysicalDestinationName();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
import java.util.Comparator;
import java.util.Date;
import java.util.Map;
import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;

import lombok.Getter;
import nl.nn.adapterframework.configuration.ConfigurationException;
import nl.nn.adapterframework.stream.Message;
import nl.nn.adapterframework.stream.PathMessage;
import nl.nn.adapterframework.util.LogUtil;

/**
* {@link IWritableFileSystem FileSystem} representation of the local filesystem.
Expand All @@ -45,7 +44,6 @@
*/
public class LocalFileSystem extends FileSystemBase<Path> implements IWritableFileSystem<Path> {
private final @Getter(onMethod = @__(@Override)) String domain = "LocalFilesystem";
protected Logger log = LogUtil.getLogger(this);

private String root;

Expand Down Expand Up @@ -150,10 +148,11 @@ public void removeFolder(String folder, boolean removeNonEmptyFolder) throws Fil
if (folderExists(folder)) {
try {
if(removeNonEmptyFolder) {
Files.walk(toFile(folder))
.sorted(Comparator.reverseOrder())
try (Stream<Path> directoryStream = Files.walk(toFile(folder))) {
directoryStream.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}
} else {
Files.delete(toFile(folder));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ protected HttpRequestBase getMethod(URI uri, Message message, ParameterValueList

/**
* Returns a multi-parted message, either as X-WWW-FORM-URLENCODED, FORM-DATA or MTOM
* @throws IOException
*/
private HttpPost getMultipartPostMethodWithParamsInBody(URI uri, Message message, ParameterValueList parameters, PipeLineSession session) throws SenderException, IOException {
HttpPost hmethod = new HttpPost(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
* @since 7.0
*/
public abstract class HttpSessionBase implements ConfigurableLifecycle, HasKeystore, HasTruststore {
protected Logger log = LogUtil.getLogger(this);
protected final Logger log = LogUtil.getLogger(this);

private @Getter ClassLoader configurationClassLoader = Thread.currentThread().getContextClassLoader();
private @Getter @Setter String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
*
*/
public class OAuthPreferringAuthenticationStrategy extends TargetAuthenticationStrategy {
protected Logger log = LogUtil.getLogger(this);
private Logger log = LogUtil.getLogger(this);

// private boolean refreshTokenOn401; // retrying unchallenged request/responses might cause endless authentication loops

@Override
public Queue<AuthOption> select(Map<String, Header> challenges, HttpHost authhost, HttpResponse response, HttpContext context) throws MalformedChallengeException {
final HttpClientContext clientContext = HttpClientContext.adapt(context);

final Queue<AuthOption> options = new LinkedList<AuthOption>();
final Queue<AuthOption> options = new LinkedList<>();

final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
if (credsProvider == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void writeTo(final OutputStream out) throws IOException {
/**
* Determines the total length of the multipart content (content length of
* individual parts plus that of extra elements required to delimit the parts
* from one another). If any of the @{link BodyPart}s contained in this object
* from one another). If any of the {@link FormBodyPart BodyParts} contained in this object
* is of a streaming entity of unknown length the total length is also unknown.
* <p>
* This method buffers only a small amount of data in order to determine the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public String toString() {
} catch (Throwable t) {
log.warn("exception getting string representation of jmsRealm [" + getRealmName() + "]", t);
}
return null;
return super.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,17 @@ public Throwable getThrowable() {

/**
* When converting from a (Log4jLogEvent) to a mutable LogEvent ensure to not invoke any getters but assign the fields directly.
* @see "https://issues.apache.org/jira/browse/LOG4J2-1179"
* @see "https://issues.apache.org/jira/browse/LOG4J2-1382"
*
* Directly calling RewriteAppender.append(LogEvent) can do 44 million ops/sec, but when calling rewriteLogger.debug(msg) to invoke
* a logger that calls this appender, all of a sudden throughput drops to 37 thousand ops/sec. That's 1000x slower.
*
* Rewriting the event ({@link MutableLogEvent#initFrom(LogEvent)}) includes invoking caller location information, {@link LogEvent#getSource()}
* This is done by taking a snapshot of the stack and walking it, @see {@link StackLocatorUtil#calcLocation(String)}).
* This is done by taking a snapshot of the stack and walking it, see {@link StackLocatorUtil#calcLocation(String)}).
* Hence avoid this at all costs, fixed from version 2.6 (LOG4J2-1382) use a builder instance to update the @{link Message}.
*
* @see "https://issues.apache.org/jira/browse/LOG4J2-1179"
* @see "https://issues.apache.org/jira/browse/LOG4J2-1382"
* @see StackLocatorUtil#calcLocation(String)
*/
private LogEvent updateLogEventMessage(LogEvent event, Message message) {
if(event instanceof Log4jLogEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public Message<String> getProcessStores(Message<?> message) {
return new JsonResponseMessage(storeItemsGroupedByProcessState);
}

private class InlineStoreStateItem {
private static class InlineStoreStateItem {
private @Getter List<InlineStoreItem> items = new LinkedList<>();
private @Getter @Setter int totalMessageCount;
}

@AllArgsConstructor
private class InlineStoreItem {
private static class InlineStoreItem {
private @Getter @Setter String adapterName;
private @Getter @Setter String receiverName;
private @Getter @Setter int messageCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import nl.nn.adapterframework.jndi.JndiObjectFactory;
import nl.nn.adapterframework.util.AppConstants;

/*
/**
* MongoClientFactory that retrieves its configuration from JNDI.
*
* @author Gerrit van Brakel
Expand Down Expand Up @@ -54,7 +54,7 @@ public MongoClient getMongoClient(String dataSourceName, Properties jndiEnvironm

@Override
public List<String> getMongoClients() {
return new ArrayList<String>(objects.keySet());
return new ArrayList<>(objects.keySet());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public PipeRunResult doPipe(Message message, PipeLineSession session) throws Pip
return new PipeRunResult(getSuccessForward(), result);
}

private class FieldsContentHandler extends DefaultHandler {
private static class FieldsContentHandler extends DefaultHandler {
private byte[] result = new byte[0];

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected ChecksumGenerator createChecksumGenerator() throws NoSuchAlgorithmExce
}
}

protected class ZipChecksumGenerator implements ChecksumGenerator {
protected static class ZipChecksumGenerator implements ChecksumGenerator {

private Checksum checksum;

Expand All @@ -121,7 +121,7 @@ public String getResult(){
}
}

protected class MessageDigestChecksumGenerator implements ChecksumGenerator {
protected static class MessageDigestChecksumGenerator implements ChecksumGenerator {

private MessageDigest messageDigest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected String makeEncapsulatingXslt(String rootElementname, String xpathExpre
"</xsl:stylesheet>";
}

private class ItemCallbackCallingHandler extends NodeSetFilter {
private static class ItemCallbackCallingHandler extends NodeSetFilter {
private ItemCallback callback;

private XmlWriter xmlWriter;
Expand Down Expand Up @@ -283,7 +283,7 @@ public boolean isStopRequested() {

}

private class StopSensor extends FullXmlFilter {
private static class StopSensor extends FullXmlFilter {

private ItemCallbackCallingHandler itemHandler;

Expand All @@ -300,7 +300,7 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
}
}

private class HandlerRecord {
private static class HandlerRecord {
private ItemCallbackCallingHandler itemHandler;
private ContentHandler inputHandler;
private String errorMessage="Could not parse input";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected enum StopReason {
MAX_ITEMS_REACHED(MAX_ITEMS_REACHED_FORWARD),
STOP_CONDITION_MET(STOP_CONDITION_MET_FORWARD);

private @Getter String forwardName;
private final @Getter String forwardName;

private StopReason(String forwardName) {
this.forwardName=forwardName;
Expand Down Expand Up @@ -507,8 +507,8 @@ protected TransformerPool getStopConditionTp() {
}

/** Stylesheet to apply to each message, before sending it */
public void setStyleSheetName(String stylesheetName){
this.styleSheetName=stylesheetName;
public void setStyleSheetName(String styleSheetName){
this.styleSheetName=styleSheetName;
}

/** Alternatively: xpath-expression to create stylesheet from */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public IValidator getResponseValidator() {
return null;
}

public class ResponseValidatorWrapper implements IValidator {
public static class ResponseValidatorWrapper implements IValidator {

private @Getter @Setter String name;

Expand Down
Loading

0 comments on commit b623b73

Please sign in to comment.