Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ allprojects {
disable(
"ComplexBooleanConstant",
"EqualsGetClass",
"InlineMeSuggester",
"OperatorPrecedence",
"MutableConstantField",
// "ReferenceEquality",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ private JPanel createGraphActionsPane() {
return buttonPanel;
}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public String[] getXAxisLabels() {
SimpleDateFormat formatter = new SimpleDateFormat(xAxisTimeFormat.getText()); //$NON-NLS-1$
String[] xAxisLabels = new String[(int) durationTest]; // Test can't have a duration more than 2^31 secs (cast from long to int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void init() {
}

@Override
@SuppressWarnings({"boxing", "JdkObsolete"})
@SuppressWarnings({"boxing", "JavaUtilDate"})
public void setupTabPane() {
// Clear all data before display a new
this.clearData();
Expand Down
6 changes: 3 additions & 3 deletions src/core/src/main/java/org/apache/jmeter/JMeter.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ private void startGui(String testFile) {
* Called reflectively by {@link NewDriver#main(String[])}
* @param args The arguments for JMeter
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public void start(String[] args) {
CLArgsParser parser = new CLArgsParser(args, options);
String error = parser.getErrorString();
Expand Down Expand Up @@ -1016,7 +1016,7 @@ private void startNonGui(String testFile, String logFile, CLOption remoteStart,
}

// run test in batch mode
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
void runNonGui(String testFile, String logFile, boolean remoteStart, String remoteHostsString, boolean generateReportDashboard)
throws ConfigurationException {
try {
Expand Down Expand Up @@ -1323,7 +1323,7 @@ public void testStarted() {
}
}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private void endTest(boolean isDistributed) {
long now = System.currentTimeMillis();
if (isDistributed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void init(List<String> addresses, HashTree tree) {
*
* @param addresses list of the DNS names or IP addresses of the remote testing engines
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public void start(List<String> addresses) {
long now = System.currentTimeMillis();
println("Starting distributed test with remote engines: " + addresses + " @ " + new Date(now) + " (" + now + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void configure(HashTree testTree) {
}

@Override
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public void runTest() throws JMeterEngineException {
if (host != null){
long now=System.currentTimeMillis();
Expand Down Expand Up @@ -209,7 +209,7 @@ private void notifyTestListenersOfStart(SearchByClass<TestStateListener> testLis
}
}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private void notifyTestListenersOfEnd(SearchByClass<TestStateListener> testListeners) {
log.info("Notifying test listeners of end of test");
for (TestStateListener tl : testListeners.getSearchResults()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -83,7 +84,7 @@ public List<String> run() {
LOGGER.debug("Running report generation");
resultCode = sc.run(generationCommand);
if (resultCode != 0) {
errorMessageList.add(commandExecutionOutput.toString());
errorMessageList.add(commandExecutionOutput.toString(Charset.defaultCharset().name()));
LOGGER.info("The HTML report generation failed and returned: {}", commandExecutionOutput);
return errorMessageList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public JDateField(Date date) {
}

// Dummy constructor to allow JUnit tests to work
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public JDateField() {
this(new Date());
}
Expand All @@ -113,7 +113,7 @@ public void setDate(Date date) {
*
* @return The currently set date
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public Date getDate() {
try {
return dateFormat.parse(getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static String formatTimeStamp(long timeStamp) {
* the format
* @return the string
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public static String formatTimeStamp(long timeStamp, String format) {
SimpleDateFormat dateFormat = format != null ? new SimpleDateFormat(
format) : new SimpleDateFormat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void generate() throws GenerationException {
/**
* @return {@link FilterConsumer} that filter data based on date range
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private FilterConsumer createFilterByDateRange() {
FilterConsumer dateRangeFilter = new FilterConsumer();
dateRangeFilter.setName(DATE_RANGE_FILTER_CONSUMER_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private SimpleDateFormat createFormatter() {
}

@Override
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public void consume(Sample s, int channel) {
Date date = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void testStarted() {
}

@Override
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public void testStarted(String host) {
synchronized(LOCK){
sequenceNumber = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static void processSamples(String filename, Visualizer visualizer,
*
* @throws JMeterError
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private static SampleEvent makeResultFromDelimitedString(
final String[] parts,
final SampleSaveConfiguration saveConfig, // may be updated
Expand Down Expand Up @@ -843,7 +843,7 @@ public static String resultToDelimitedString(SampleEvent event,
* the separation string
* @return the separated value representation of the result
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public static String resultToDelimitedString(SampleEvent event,
SampleResult sample,
SampleSaveConfiguration saveConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public long getStartTime() {
* @return the start time using the specified format
* Intended for use from Functors
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public String getStartTimeFormatted(Format format) {
return format.format(new Date(getStartTime()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public long getStartTime() {
* @return the start time using the specified format
* Intended for use from Functors
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public String getStartTimeFormatted(Format format) {
return format.format(new Date(getStartTime()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public List<String> getArgumentDesc() {
}

@Override
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
String dateString = values[0].execute();
String sourceDateFormat = values[1].execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public TimeFunction(){

/** {@inheritDoc} */
@Override
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
String datetime;
if (format.length() == 0){// Default to milliseconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class CacheManager extends ConfigTestElement implements TestStateListener

private static final Logger log = LoggerFactory.getLogger(CacheManager.class);

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private static final Date EXPIRED_DATE = new Date(0L);
private static final int DEFAULT_MAX_SIZE = 5000;
private static final long ONE_YEAR_MS = 365*24*60*60*1000L;
Expand Down Expand Up @@ -307,7 +307,7 @@ private Date extractExpiresDateFromExpires(String expires) {
return expiresDate;
}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private Date extractExpiresDateFromCacheControl(String lastModified,
String cacheControl, String expires, String etag, String url,
String date, final String maxAge, Date defaultExpiresDate) {
Expand All @@ -327,7 +327,7 @@ private Date extractExpiresDateFromCacheControl(String lastModified,
return defaultExpiresDate;
}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private Date calcExpiresDate(String lastModified, String cacheControl,
String expires, String etag, String url, String date) {
if(!StringUtils.isEmpty(lastModified) && !StringUtils.isEmpty(date)) {
Expand Down Expand Up @@ -516,7 +516,7 @@ public String getValue() {

}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private boolean entryStillValid(URL url, CacheEntry entry) {
log.debug("Check if entry {} is still valid for url {}", entry, url);
if (entry != null && entry.getVaryHeader() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public HC4CookieHandler(String policy) {
}

@Override
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public void addCookieFromHeader(CookieManager cookieManager,
boolean checkCookies, String cookieHeader, URL url) {
boolean debugEnabled = log.isDebugEnabled();
Expand Down Expand Up @@ -240,7 +240,7 @@ List<org.apache.http.cookie.Cookie> getCookiesForUrl(
/**
* Create an HttpClient cookie from a JMeter cookie
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private org.apache.http.cookie.Cookie makeCookie(Cookie jmc) {
long exp = jmc.getExpiresMillis();
BasicClientCookie ret = new BasicClientCookie(jmc.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
Expand Down Expand Up @@ -164,7 +165,7 @@ public byte[] parse(InputStream in) throws IOException {
inHeaders = false;
firstLine = false; // cannot be first line either
}
final String reqLine = line.toString();
final String reqLine = line.toString(StandardCharsets.ISO_8859_1.name());
if (firstLine) {
parseFirstLine(reqLine);
firstLine = false;
Expand All @@ -189,7 +190,7 @@ public byte[] parse(InputStream in) throws IOException {
if (log.isDebugEnabled()){
log.debug("rawPostData in default JRE encoding: {}, Request: '{}'",
new String(rawPostData, Charset.defaultCharset()),
clientRequest.toString().replaceAll("\r\n", CRLF));
clientRequest.toString(StandardCharsets.ISO_8859_1.name()).replaceAll("\r\n", CRLF));
}
return clientRequest.toByteArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public void stopProxy() {
}
}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public String[] getCertificateDetails() {
if (isDynamicMode()) {
try {
Expand Down Expand Up @@ -1540,7 +1540,7 @@ private void initKeyStore() throws IOException, GeneralSecurityException {
/**
* Initialise the user-provided keystore
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private void initUserKeyStore() {
try {
keyStore = getKeyStore(storePassword.toCharArray());
Expand All @@ -1562,7 +1562,7 @@ private void initUserKeyStore() {
/**
* Initialise the dynamic domain keystore
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private void initDynamicKeyStore() throws IOException, GeneralSecurityException {
if (storePassword != null) { // Assume we have already created the store
try {
Expand Down Expand Up @@ -1658,7 +1658,7 @@ KeyStore updateKeyStore(String port, String host) throws IOException, GeneralSec
/**
* Initialise the single key JMeter keystore (original behaviour)
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private void initJMeterKeyStore() throws IOException, GeneralSecurityException {
if (storePassword != null) { // Assume we have already created the store
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public boolean isDestinationStatic(){
* @param message JMS Message
* @return String with message header values.
*/
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public static String getMessageHeaders(Message message) {
final StringBuilder response = new StringBuilder(256);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ private void printEnvironment(Context context) throws NamingException {
}
}

@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
private void logThreadStart() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Thread started {}", new Date());
Expand Down Expand Up @@ -794,7 +794,7 @@ public String getPriority() {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("JdkObsolete")
@SuppressWarnings("JavaUtilDate")
public void threadFinished() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Thread ended {}", new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -115,11 +116,15 @@ public String read(InputStream is, SampleResult sampleResult) throws ReadExcepti

// do we need to close byte array (or flush it?)
if(log.isDebugEnabled()) {
log.debug("Read: {}\n{}", w.size(), w.toString());
log.debug("Read: {}\n{}", w.size(), w.toString(CHARSET));
}
return w.toString(CHARSET);
} catch (IOException e) {
throw new ReadException("Error reading from server, bytes read: " + w.size(), e, w.toString());
try {
throw new ReadException("Error reading from server, bytes read: " + w.size(), e, w.toString(CHARSET));
} catch (UnsupportedEncodingException ue) {
throw new RuntimeException("Unsupported CHARSET: " + CHARSET, ue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to catch the UnsupportedEncodingException before the IOException, as that might happen earlier, too and the error message might look funny otherwise.
On this line, we could include a bit more information such as the size of w and the fact, that we got an error while reading/decoding stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I disagree about it, but this catch block here is unavoidable. It is thrown because w.toString(CHARSET) is called from within throw new ReadException(...).
This is avoidable only if the result of w.toString(CHARSET) is accessible within the catch block without calling the said method, but making it happen requires even more non-trivial changes on this method.

}
}
}

Expand Down