Skip to content

Commit

Permalink
Remove property response.body.size.warn.default (frankframework#3866)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanbrakel authored Oct 17, 2022
1 parent f33639f commit dadbccc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017-2019 Nationale-Nederlanden, 2020-2021 WeAreFrank!
Copyright 2017-2019 Nationale-Nederlanden, 2020-2022 WeAreFrank!
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,7 +47,6 @@
import nl.nn.adapterframework.stream.Message;
import nl.nn.adapterframework.util.CredentialFactory;
import nl.nn.adapterframework.util.LogUtil;
import nl.nn.adapterframework.util.Misc;
import nl.nn.adapterframework.util.XmlBuilder;
import nl.nn.adapterframework.util.XmlUtils;

Expand Down Expand Up @@ -280,22 +279,14 @@ public String getResponseBodyAsString(HttpResponseHandler responseHandler, boole

Message response = responseHandler.getResponseMessage();

String responseBody = null;
try {
responseBody = response.asString();
return response.asString();
} catch(IOException e) {
if(throwIOExceptionWhenParsingResponse) {
throw e;
}
return null;
}

int rbLength = responseBody.length();
long rbSizeWarn = Misc.getResponseBodySizeWarnByDefault();
if (rbLength >= rbSizeWarn) {
log.warn(getLogPrefix()+"retrieved result size [" +Misc.toFileSize(rbLength)+"] exceeds ["+Misc.toFileSize(rbSizeWarn)+"]");
}
return responseBody;
}

/** Only works in combination with the UPLOAD action. If set, and not specified as parameter, the sender will sign the file to be uploaded.*/
Expand Down
36 changes: 9 additions & 27 deletions core/src/main/java/nl/nn/adapterframework/util/Misc.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ public class Misc {
@Deprecated
public static final String DEFAULT_INPUT_STREAM_ENCODING=StreamUtil.DEFAULT_INPUT_STREAM_ENCODING;
public static final String MESSAGE_SIZE_WARN_BY_DEFAULT_KEY = "message.size.warn.default";
public static final String RESPONSE_BODY_SIZE_WARN_BY_DEFAULT_KEY = "response.body.size.warn.default";

private static Long messageSizeWarnByDefault = null;
private static Long responseBodySizeWarnByDefault = null;
private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
public static final String LINE_SEPARATOR = System.lineSeparator();

Expand All @@ -112,9 +110,8 @@ public static String createRandomUUID(boolean removeDashes) {
String uuidString = java.util.UUID.randomUUID().toString();
if (removeDashes) {
return uuidString.replaceAll("-", "");
} else {
return uuidString;
}
return uuidString;
}

public static String createRandomUUID() {
Expand Down Expand Up @@ -188,7 +185,7 @@ public static String createNumericUUID() {
* @return integer that is converted from unsigned byte.
*/
public static int unsignedByteToInt(byte b) {
return (int) b & 0xFF;
return b & 0xFF;
}

/**
Expand Down Expand Up @@ -528,7 +525,7 @@ public static String replace (String source, String from, String to) {
}

/**
* Concatenates two strings, if specified, uses the separator in between two strings.
* Concatenates two strings, if specified, uses the separator in between two strings.
* Does not use any separators if both or one of the strings are empty.
*<p>
* Example:
Expand Down Expand Up @@ -599,9 +596,8 @@ public static String hide(String string, int mode) {
char firstChar = string.charAt(0);
char lastChar = string.charAt(len - 1);
return firstChar + StringUtils.repeat("*", len - 2) + lastChar;
} else {
return StringUtils.repeat("*", len);
}
return StringUtils.repeat("*", len);
}

/**
Expand Down Expand Up @@ -1028,16 +1024,13 @@ public static String toFileSize(long value, boolean format, boolean floor) {
if (format) {
if (value > 0) {
return "1 kB";
} else {
return "0 kB";
}
} else {
return Long.toString(value) + (floor ? "B" : "");
return "0 kB";
}
} else {
float f = (float) value / divider;
return Math.round(f) + (format ? " " : "") + suffix;
return Long.toString(value) + (floor ? "B" : "");
}
float f = (float) value / divider;
return Math.round(f) + (format ? " " : "") + suffix;
}

public static synchronized long getMessageSizeWarnByDefault() {
Expand All @@ -1049,16 +1042,6 @@ public static synchronized long getMessageSizeWarnByDefault() {
return messageSizeWarnByDefault.longValue();
}

public static synchronized long getResponseBodySizeWarnByDefault() {
if (responseBodySizeWarnByDefault == null) {
String definitionString = AppConstants.getInstance().getString(RESPONSE_BODY_SIZE_WARN_BY_DEFAULT_KEY,
null);
long definition = toFileSize(definitionString, -1);
responseBodySizeWarnByDefault = new Long(definition);
}
return responseBodySizeWarnByDefault.longValue();
}

/**
* Converts the list to a string.
* <pre>
Expand Down Expand Up @@ -1355,9 +1338,8 @@ public static String getProjectBaseDir() {
if ("WebContent".equalsIgnoreCase(name)
|| "target".equalsIgnoreCase(name)) {
return dir.getParent();
} else {
dir = dir.getParentFile();
}
dir = dir.getParentFile();
}
}
return null;
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/resources/AppConstants.properties
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,6 @@ adapter.message.max.size=1000

message.size.warn.default=3MB

# size limit for the response body of a HTTP method; when exceeded a warning message is logged
response.body.size.warn.default=128KB

# perform stubbing of the configuration for Larva Test Tool
stub4testtool.configuration=false
Expand Down

0 comments on commit dadbccc

Please sign in to comment.