Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f25169b
Merge pull request #665 from naver/release/3.5.2
songeunwoo Sep 29, 2020
094e019
Fix case unintended reset of followers at login
donggyu04 Oct 8, 2020
c565dbc
Move cache of recently used agents to distribution map
donggyu04 Oct 8, 2020
63b6711
Rename cache
donggyu04 Oct 13, 2020
d21e1e6
Make the modified file distribution handler to be loaded first
donggyu04 Oct 15, 2020
319feb4
Add .gitattributes
donggyu04 Oct 16, 2020
6f96eb6
Merge pull request #673 from naver/feature/add-gitattributes
songeunwoo Oct 16, 2020
4d37b16
Make the H2 console optionally available
donggyu04 Oct 16, 2020
ae9715c
Merge pull request #672 from naver/feature/move-file-dist-handler-to-…
songeunwoo Oct 19, 2020
b95687b
Merge pull request #668 from naver/feature/move-recent-agent-cache-to…
songeunwoo Oct 19, 2020
0a95a77
Merge pull request #675 from naver/feature/make-h2-console-optionally…
songeunwoo Oct 19, 2020
5ef4511
Prevent lazy initialize exception in spring security authentication o…
donggyu04 Oct 8, 2020
cae2f52
Fix failed unit test
donggyu04 Oct 22, 2020
aba46f5
Merge pull request #669 from naver/bugfix/prevent-lazy-initialize-exc…
imbyungjun Oct 27, 2020
92109fb
Support UTC
donggyu04 Oct 19, 2020
d9926d3
Rename column
donggyu04 Oct 22, 2020
0e50ccd
Use vuejs-datepicker
donggyu04 Oct 27, 2020
2618488
Prevent NEP if start console is failed
donggyu04 Oct 28, 2020
fd40a3c
Escape response body in result console
donggyu04 Oct 28, 2020
67c0250
Merge pull request #682 from naver/bugfix/escape-response-body-in-res…
songeunwoo Oct 28, 2020
9eb50e5
Merge pull request #676 from naver/feature/make-to-use-utc
songeunwoo Oct 29, 2020
b1e7ccf
Reduce range of global css
donggyu04 Oct 29, 2020
b2ed870
Merge pull request #683 from naver/feature/reduce-range-of-global-css
imbyungjun Oct 29, 2020
1f41a99
Add abnormal testing status category
donggyu04 Oct 30, 2020
5bda279
Prevent test start button flickering
donggyu04 Oct 29, 2020
4adea12
Fix unstoppable abnormal test
donggyu04 Oct 30, 2020
cd9a664
Merge pull request #685 from naver/feature/prevent-test-start-button-…
songeunwoo Nov 4, 2020
3af9ea8
Merge pull request #684 from naver/bugfix/unstoppable-abnormal-test
songeunwoo Nov 4, 2020
2268bf7
Add identity information to perftest related log
donggyu04 Nov 2, 2020
a5a3a4a
Merge pull request #686 from naver/feature/enhance-logging
songeunwoo Nov 5, 2020
4396235
Remove @Index from entity
donggyu04 Oct 22, 2020
0a68ea2
Use try-with-resource
donggyu04 Oct 22, 2020
6bfcd86
Change deprecated method
donggyu04 Oct 22, 2020
454dbaa
Remove unnecessary code
donggyu04 Oct 22, 2020
64e4444
Use lambda expression
donggyu04 Oct 23, 2020
8a9419d
Use constructor based dependency injection
donggyu04 Oct 23, 2020
81b8c17
Fix ambiguous code
donggyu04 Oct 23, 2020
64614de
Use double quotes in build.gradle
donggyu04 Oct 28, 2020
b7fff69
Append final keyword to unmodifiable variables
donggyu04 Nov 2, 2020
a12cb2f
Attach @SuppressWarnings
donggyu04 Nov 3, 2020
986c0ec
Remove pre-sized array
donggyu04 Nov 4, 2020
8153da1
Simplify code
donggyu04 Nov 4, 2020
8a07f3d
Merge pull request #679 from naver/feature/clean-up-code
songeunwoo Nov 5, 2020
143bac6
Fix agent updating doesn't work
donggyu04 Nov 10, 2020
2828889
Merge pull request #688 from naver/bugfix/fix-agent-updating-does-not…
imbyungjun Nov 11, 2020
6078bb6
Add bintray gradle configuration
donggyu04 Nov 4, 2020
20a3798
Merge pull request #687 from naver/feature/publish-to-bintray
songeunwoo Nov 20, 2020
ab7fbe8
Check property existence in bintray gradle configuration
donggyu04 Nov 23, 2020
b881228
Merge pull request #691 from naver/feature/fix-bintray-gradle-configu…
songeunwoo Nov 23, 2020
83efc62
Remove embedded maven
donggyu04 Nov 11, 2020
73c935a
Support groovy gradle project script
donggyu04 Nov 16, 2020
4161f3c
Update docker file to install Maven and Gradle
donggyu04 Nov 24, 2020
37c7147
Merge pull request #689 from naver/feature/support-gradle-groovy
songeunwoo Nov 27, 2020
a8823d4
Bump version up to 3.5.3
donggyu04 Nov 27, 2020
9ebf7d8
Update RELEASE-NOTE.md
donggyu04 Nov 27, 2020
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
Prev Previous commit
Next Next commit
Use try-with-resource
  • Loading branch information
donggyu04 committed Nov 5, 2020
commit 0a68ea2092648cbafb3846621ba1c1ee8203e43c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -9,7 +9,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
package org.ngrinder.common.util;

Expand Down Expand Up @@ -59,12 +59,10 @@ public static boolean downloadFile(HttpServletResponse response, File file) {
response.addHeader("Content-Disposition", "attachment;filename=" + file.getName());
response.setContentType("application/octet-stream");
response.addHeader("Content-Length", "" + file.length());
InputStream fis = null;
byte[] buffer = new byte[FILE_DOWNLOAD_BUFFER_SIZE];
OutputStream toClient = null;
try {
fis = new BufferedInputStream(new FileInputStream(file));
toClient = new BufferedOutputStream(response.getOutputStream());

try (InputStream fis = new BufferedInputStream(new FileInputStream(file));
OutputStream toClient = new BufferedOutputStream(response.getOutputStream())) {
int readLength;
while (((readLength = fis.read(buffer)) != -1)) {
toClient.write(buffer, 0, readLength);
Expand All @@ -76,10 +74,8 @@ public static boolean downloadFile(HttpServletResponse response, File file) {
} catch (IOException e) {
LOGGER.error("read file error:" + file.getAbsolutePath(), e);
result = false;
} finally {
IOUtils.closeQuietly(fis);
IOUtils.closeQuietly(toClient);
}

return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -9,7 +9,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
package org.ngrinder.common.util;

Expand All @@ -18,11 +18,12 @@
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;

import static org.apache.commons.io.IOUtils.copy;

/**
* Convenient File utilities.
*
Expand All @@ -39,17 +40,11 @@ public abstract class FileUtils {
* @since 3.2
*/
public static void copyResourceToFile(String resourcePath, File file) {
InputStream io = null;
FileOutputStream fos = null;
try {
io = new ClassPathResource(resourcePath).getInputStream();
fos = new FileOutputStream(file);
IOUtils.copy(io, fos);
try (InputStream io = new ClassPathResource(resourcePath).getInputStream();
FileOutputStream fos = new FileOutputStream(file)) {
copy(io, fos);
} catch (IOException e) {
LOGGER.error("error while writing {}", resourcePath, e);
} finally {
IOUtils.closeQuietly(io);
IOUtils.closeQuietly(fos);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -9,7 +9,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
package org.ngrinder.home.service;

Expand Down Expand Up @@ -88,37 +88,39 @@ public Map<String, String> getUserDefinedMessageSources(String locale) {
*/
public List<PanelEntry> getPanelEntries(String feedURL, int maxSize, boolean includeReply) {
SyndFeedInput input = new SyndFeedInput();
XmlReader reader = null;
HttpURLConnection feedConnection = null;

try {
List<PanelEntry> panelEntries = new ArrayList<>();
URL url = new URL(feedURL);
feedConnection = (HttpURLConnection) url.openConnection();
feedConnection.setConnectTimeout(8000);
feedConnection.setReadTimeout(8000);
reader = new XmlReader(feedConnection);
SyndFeed feed = input.build(reader);
int count = 0;

for (Object eachObj : feed.getEntries()) {
SyndEntryImpl each = cast(eachObj);
if (!includeReply && StringUtils.startsWithIgnoreCase(each.getTitle(), "Re: ")) {
continue;
}
if (count++ >= maxSize) {
break;

try (XmlReader reader = new XmlReader(feedConnection)) {
SyndFeed feed = input.build(reader);
int count = 0;

for (Object eachObj : feed.getEntries()) {
SyndEntryImpl each = cast(eachObj);
if (!includeReply && StringUtils.startsWithIgnoreCase(each.getTitle(), "Re: ")) {
continue;
}
if (count++ >= maxSize) {
break;
}
panelEntries.add(getPanelEntry(each));
}
panelEntries.add(getPanelEntry(each));
Collections.sort(panelEntries);
return panelEntries;
}
Collections.sort(panelEntries);
return panelEntries;

} catch (Exception e) {
LOG.error("Error while patching the feed entries for {} : {}", feedURL, e.getMessage());
} finally {
if (feedConnection != null) {
feedConnection.disconnect();
}
IOUtils.closeQuietly(reader);
}
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import net.grinder.util.ListenerSupport.Informer;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.ngrinder.common.constant.ClusterConstants;
import org.ngrinder.common.constant.ControllerConstants;
Expand Down Expand Up @@ -348,17 +347,13 @@ protected Home resolveExHome() {
* Load internal properties which is not modifiable by user.
*/
protected void loadInternalProperties() {
InputStream inputStream = null;
Properties properties = new Properties();
try {
inputStream = new ClassPathResource("/internal.properties").getInputStream();
try (InputStream inputStream = new ClassPathResource("/internal.properties").getInputStream()) {
properties.load(inputStream);
internalProperties = new PropertiesWrapper(properties, internalPropertiesKeyMapper);
} catch (IOException e) {
CoreLogger.LOGGER.error("Error while load internal.properties", e);
internalProperties = new PropertiesWrapper(properties, internalPropertiesKeyMapper);
} finally {
IOUtils.closeQuietly(inputStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ public ModelAndView resolveException(HttpServletRequest request, HttpServletResp
Throwable throwable = ExceptionUtils.sanitize(ex);

StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
throwable.printStackTrace(printWriter);
IOUtils.closeQuietly(printWriter);

try (PrintWriter printWriter = new PrintWriter(out)) {
throwable.printStackTrace(printWriter);
}

Map<String, Object> jsonResponse = buildMap(
JSON_SUCCESS, false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ public void showLog(User user, @PathVariable("id") long id, @RemainedPath String
response.reset();
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(targetFile);

try (FileInputStream fileInputStream = new FileInputStream(targetFile)) {
ServletOutputStream outputStream = response.getOutputStream();
if (FilenameUtils.isExtension(targetFile.getName(), "zip")) {
// Limit log view to 1MB
Expand All @@ -141,8 +140,6 @@ public void showLog(User user, @PathVariable("id") long id, @RemainedPath String
}
} catch (Exception e) {
CoreLogger.LOGGER.error("Error while processing log. {}", targetFile, e);
} finally {
IOUtils.closeQuietly(fileInputStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import net.grinder.engine.controller.AgentControllerIdentityImplementation;
import net.grinder.message.console.AgentControllerState;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.ngrinder.agent.service.AgentPackageService;
Expand Down Expand Up @@ -332,9 +331,8 @@ public Set<AgentStatus> getAttachedAgentStatusSetConnectingToPort(final int sing
public synchronized AgentUpdateGrinderMessage onAgentDownloadRequested(String version, int offset) {
final int updateChunkSize = getUpdateChunkSize();
byte[] buffer = new byte[updateChunkSize];
RandomAccessFile agentPackageReader = null;
try {
agentPackageReader = new RandomAccessFile(agentPackageService.createAgentPackage(), "r");

try (RandomAccessFile agentPackageReader = new RandomAccessFile(agentPackageService.createAgentPackage(), "r")) {
agentPackageReader.seek(offset);
int count = agentPackageReader.read(buffer, 0, updateChunkSize);
byte[] bytes = buffer;
Expand All @@ -347,8 +345,6 @@ public synchronized AgentUpdateGrinderMessage onAgentDownloadRequested(String ve
CRC32ChecksumUtils.getCRC32Checksum(bytes));
} catch (Exception e) {
LOGGER.error("Error while reading agent package, its offset is {} and details {}:", offset, e);
} finally {
IOUtils.closeQuietly(agentPackageReader);
}
return AgentUpdateGrinderMessage.getNullAgentUpdateGrinderMessage(version);
}
Expand Down
Loading