You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by dk...@apache.org on 2015/08/04 17:59:27 UTC
[08/10] activemq git commit:
https://issues.apache.org/jira/browse/AMQ-5745
https://issues.apache.org/jira/browse/AMQ-5745
This commit is based off a patch submitted by admin@int3solutions.com.
It fixes several locations in the code where there are potential resource leaks.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/42d9fd11
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/42d9fd11
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/42d9fd11
Branch: refs/heads/activemq-5.11.x
Commit: 42d9fd118daea5cc10f7eb56c263063adb322f25
Parents: 2c166b7
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Authored: Mon Jun 22 18:34:37 2015 +0000
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Aug 4 09:31:26 2015 -0400
----------------------------------------------------------------------
.../apache/activemq/broker/BrokerService.java | 14 ++-
.../broker/PropertiesBrokerFactory.java | 43 ++++----
.../java/org/apache/activemq/util/IOHelper.java | 17 +--
.../org/apache/activemq/ActiveMQSession.java | 8 +-
.../activemq/ActiveMQSslConnectionFactory.java | 38 ++++---
.../org/apache/activemq/blob/BlobUploader.java | 4 +-
.../blob/DefaultBlobUploadStrategy.java | 18 +--
.../activemq/blob/FTPBlobUploadStrategy.java | 4 +-
.../activemq/blob/FileSystemBlobStrategy.java | 43 ++++----
.../activemq/console/command/CreateCommand.java | 23 ++--
.../java/org/apache/activemq/util/IOHelper.java | 43 ++++----
.../jaas/TextFileCertificateLoginModule.java | 10 +-
.../store/jdbc/adapter/BlobJDBCAdapter.java | 27 ++---
.../store/jdbc/adapter/StreamJDBCAdapter.java | 15 +--
.../store/kahadb/disk/page/PageFile.java | 8 +-
.../store/kahadb/disk/util/DiskBenchmark.java | 109 ++++++++++---------
.../transport/stomp/ProtocolConverter.java | 14 ++-
.../activemq/tool/AbstractJmsClientSystem.java | 6 +-
.../apache/activemq/tool/JmsProducerClient.java | 11 +-
.../tool/reports/XmlFilePerfReportWriter.java | 31 +++---
.../org/apache/activemq/web/AjaxServlet.java | 26 ++---
21 files changed, 272 insertions(+), 240 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
index b250d32..95d57f6 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -272,14 +272,16 @@ public class BrokerService implements Service {
}
LOCAL_HOST_NAME = localHostName;
- InputStream in = null;
String version = null;
- if ((in = BrokerService.class.getResourceAsStream("/org/apache/activemq/version.txt")) != null) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- try {
- version = reader.readLine();
- } catch(Exception e) {
+ try(InputStream in = BrokerService.class.getResourceAsStream("/org/apache/activemq/version.txt")) {
+ if (in != null) {
+ try(InputStreamReader isr = new InputStreamReader(in);
+ BufferedReader reader = new BufferedReader(isr)) {
+ version = reader.readLine();
+ }
}
+ } catch (IOException ie) {
+ LOG.warn("Error reading broker version ", ie);
}
BROKER_VERSION = version;
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-broker/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java b/activemq-broker/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java
index 698c326..2be9e34 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/PropertiesBrokerFactory.java
@@ -31,14 +31,14 @@ import org.apache.activemq.util.IntrospectionSupport;
/**
* A {@link BrokerFactoryHandler} which uses a properties file to configure the
* broker's various policies.
- *
- *
+ *
+ *
*/
public class PropertiesBrokerFactory implements BrokerFactoryHandler {
public BrokerService createBroker(URI brokerURI) throws Exception {
- Map properties = loadProperties(brokerURI);
+ Map<Object, Object> properties = loadProperties(brokerURI);
BrokerService brokerService = createBrokerService(brokerURI, properties);
IntrospectionSupport.setProperties(brokerService, properties);
@@ -48,14 +48,31 @@ public class PropertiesBrokerFactory implements BrokerFactoryHandler {
/**
* Lets load the properties from some external URL or a relative file
*/
- protected Map loadProperties(URI brokerURI) throws IOException {
+ protected Map<Object, Object> loadProperties(URI brokerURI) throws IOException {
// lets load a URI
String remaining = brokerURI.getSchemeSpecificPart();
Properties properties = new Properties();
File file = new File(remaining);
+ try (InputStream inputStream = loadStream(file, remaining)) {
+ if (inputStream != null) {
+ properties.load(inputStream);
+ }
+ }
+
+ // should we append any system properties?
+ try {
+ Properties systemProperties = System.getProperties();
+ properties.putAll(systemProperties);
+ } catch (Exception e) {
+ // ignore security exception
+ }
+ return properties;
+ }
+
+ protected InputStream loadStream(File file, String remaining) throws IOException {
InputStream inputStream = null;
- if (file.exists()) {
+ if (file != null && file.exists()) {
inputStream = new FileInputStream(file);
} else {
URL url = null;
@@ -72,19 +89,7 @@ public class PropertiesBrokerFactory implements BrokerFactoryHandler {
inputStream = url.openStream();
}
}
- if (inputStream != null) {
- properties.load(inputStream);
- inputStream.close();
- }
-
- // should we append any system properties?
- try {
- Properties systemProperties = System.getProperties();
- properties.putAll(systemProperties);
- } catch (Exception e) {
- // ignore security exception
- }
- return properties;
+ return inputStream;
}
protected InputStream findResourceOnClassPath(String remaining) {
@@ -95,7 +100,7 @@ public class PropertiesBrokerFactory implements BrokerFactoryHandler {
return answer;
}
- protected BrokerService createBrokerService(URI brokerURI, Map properties) {
+ protected BrokerService createBrokerService(URI brokerURI, Map<Object, Object> properties) {
return new BrokerService();
}
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java b/activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
index 2a70194..9f06029 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
@@ -281,14 +281,17 @@ public final class IOHelper {
}
public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
- int len = in.read(buffer);
- while (len >= 0) {
- out.write(buffer, 0, len);
- len = in.read(buffer);
+ try {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ int len = in.read(buffer);
+ while (len >= 0) {
+ out.write(buffer, 0, len);
+ len = in.read(buffer);
+ }
+ } finally {
+ in.close();
+ out.close();
}
- in.close();
- out.close();
}
static {
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java
index 14c2869..457ce3e 100755
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java
@@ -504,7 +504,13 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
* <CODE>BlobMessage</CODE> object is used to send a message containing
* the <CODE>File</CODE> content. Before the message is sent the file
* conent will be uploaded to the broker or some other remote repository
- * depending on the {@link #getBlobTransferPolicy()}.
+ * depending on the {@link #getBlobTransferPolicy()}. <br/>
+ * <p>
+ * The caller of this method is responsible for closing the
+ * input stream that is used, however the stream can not be closed
+ * until <b>after</b> the message has been sent. To have this class
+ * manage the stream and close it automatically, use the method
+ * {@link ActiveMQSession#createBlobMessage(File)}
*
* @param in the stream to be uploaded to some remote repo (or the broker)
* depending on the strategy
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-client/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
index b6b75da..8bee791 100644
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
@@ -130,13 +130,14 @@ public class ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
KeyStore trustedCertStore = KeyStore.getInstance(getTrustStoreType());
if (trustStore != null) {
- InputStream tsStream = getInputStream(trustStore);
+ try(InputStream tsStream = getInputStream(trustStore)) {
- trustedCertStore.load(tsStream, trustStorePassword.toCharArray());
- TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ trustedCertStore.load(tsStream, trustStorePassword.toCharArray());
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- tmf.init(trustedCertStore);
- trustStoreManagers = tmf.getTrustManagers();
+ tmf.init(trustedCertStore);
+ trustStoreManagers = tmf.getTrustManagers();
+ }
}
return trustStoreManagers;
}
@@ -149,10 +150,11 @@ public class ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
byte[] sslCert = loadClientCredential(keyStore);
if (sslCert != null && sslCert.length > 0) {
- ByteArrayInputStream bin = new ByteArrayInputStream(sslCert);
- ks.load(bin, keyStorePassword.toCharArray());
- kmf.init(ks, keyStoreKeyPassword !=null ? keyStoreKeyPassword.toCharArray() : keyStorePassword.toCharArray());
- keystoreManagers = kmf.getKeyManagers();
+ try(ByteArrayInputStream bin = new ByteArrayInputStream(sslCert)) {
+ ks.load(bin, keyStorePassword.toCharArray());
+ kmf.init(ks, keyStoreKeyPassword !=null ? keyStoreKeyPassword.toCharArray() : keyStorePassword.toCharArray());
+ keystoreManagers = kmf.getKeyManagers();
+ }
}
}
return keystoreManagers;
@@ -162,16 +164,16 @@ public class ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
if (fileName == null) {
return null;
}
- InputStream in = getInputStream(fileName);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buf = new byte[512];
- int i = in.read(buf);
- while (i > 0) {
- out.write(buf, 0, i);
- i = in.read(buf);
+ try(InputStream in = getInputStream(fileName);
+ ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+ byte[] buf = new byte[512];
+ int i = in.read(buf);
+ while (i > 0) {
+ out.write(buf, 0, i);
+ i = in.read(buf);
+ }
+ return out.toByteArray();
}
- in.close();
- return out.toByteArray();
}
protected InputStream getInputStream(String urlOrResource) throws IOException {
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-client/src/main/java/org/apache/activemq/blob/BlobUploader.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/blob/BlobUploader.java b/activemq-client/src/main/java/org/apache/activemq/blob/BlobUploader.java
index 244948a..05933d3 100644
--- a/activemq-client/src/main/java/org/apache/activemq/blob/BlobUploader.java
+++ b/activemq-client/src/main/java/org/apache/activemq/blob/BlobUploader.java
@@ -27,8 +27,8 @@ import org.apache.activemq.command.ActiveMQBlobMessage;
/**
* A helper class to represent a required upload of a BLOB to some remote URL
- *
- *
+ *
+ *
*/
public class BlobUploader {
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-client/src/main/java/org/apache/activemq/blob/DefaultBlobUploadStrategy.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/blob/DefaultBlobUploadStrategy.java b/activemq-client/src/main/java/org/apache/activemq/blob/DefaultBlobUploadStrategy.java
index 12c98a3..655c942 100644
--- a/activemq-client/src/main/java/org/apache/activemq/blob/DefaultBlobUploadStrategy.java
+++ b/activemq-client/src/main/java/org/apache/activemq/blob/DefaultBlobUploadStrategy.java
@@ -40,7 +40,9 @@ public class DefaultBlobUploadStrategy extends DefaultStrategy implements BlobUp
}
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException {
- return uploadStream(message, new FileInputStream(file));
+ try(FileInputStream fis = new FileInputStream(file)) {
+ return uploadStream(message, fis);
+ }
}
public URL uploadStream(ActiveMQBlobMessage message, InputStream fis) throws JMSException, IOException {
@@ -55,15 +57,13 @@ public class DefaultBlobUploadStrategy extends DefaultStrategy implements BlobUp
// (chunked mode not supported before JRE 1.5)
connection.setChunkedStreamingMode(transferPolicy.getBufferSize());
- OutputStream os = connection.getOutputStream();
-
- byte[] buf = new byte[transferPolicy.getBufferSize()];
- for (int c = fis.read(buf); c != -1; c = fis.read(buf)) {
- os.write(buf, 0, c);
- os.flush();
+ try(OutputStream os = connection.getOutputStream()) {
+ byte[] buf = new byte[transferPolicy.getBufferSize()];
+ for (int c = fis.read(buf); c != -1; c = fis.read(buf)) {
+ os.write(buf, 0, c);
+ os.flush();
+ }
}
- os.close();
- fis.close();
if (!isSuccessfulCode(connection.getResponseCode())) {
throw new IOException("PUT was not successful: " + connection.getResponseCode() + " "
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java b/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
index 6cb0e8a..4a00746 100644
--- a/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
+++ b/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
@@ -39,7 +39,9 @@ public class FTPBlobUploadStrategy extends FTPStrategy implements BlobUploadStra
@Override
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException {
- return uploadStream(message, new FileInputStream(file));
+ try(FileInputStream fis = new FileInputStream(file)) {
+ return uploadStream(message, fis);
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-client/src/main/java/org/apache/activemq/blob/FileSystemBlobStrategy.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/blob/FileSystemBlobStrategy.java b/activemq-client/src/main/java/org/apache/activemq/blob/FileSystemBlobStrategy.java
index 022aec1..a970d56 100644
--- a/activemq-client/src/main/java/org/apache/activemq/blob/FileSystemBlobStrategy.java
+++ b/activemq-client/src/main/java/org/apache/activemq/blob/FileSystemBlobStrategy.java
@@ -36,19 +36,19 @@ import org.apache.activemq.command.ActiveMQBlobMessage;
*/
public class FileSystemBlobStrategy implements BlobUploadStrategy, BlobDownloadStrategy{
-
+
private final BlobTransferPolicy policy;
private File rootFile;
-
+
public FileSystemBlobStrategy(final BlobTransferPolicy policy) throws MalformedURLException, URISyntaxException {
this.policy = policy;
-
+
createRootFolder();
}
-
+
/**
- * Create the root folder if not exist
- *
+ * Create the root folder if not exist
+ *
* @throws MalformedURLException
* @throws URISyntaxException
*/
@@ -65,7 +65,9 @@ public class FileSystemBlobStrategy implements BlobUploadStrategy, BlobDownloadS
* @see org.apache.activemq.blob.BlobUploadStrategy#uploadFile(org.apache.activemq.command.ActiveMQBlobMessage, java.io.File)
*/
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException {
- return uploadStream(message, new FileInputStream(file));
+ try(FileInputStream fis = new FileInputStream(file)) {
+ return uploadStream(message, fis);
+ }
}
/*
@@ -74,14 +76,13 @@ public class FileSystemBlobStrategy implements BlobUploadStrategy, BlobDownloadS
*/
public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException {
File f = getFile(message);
- FileOutputStream out = new FileOutputStream(f);
- byte[] buffer = new byte[policy.getBufferSize()];
- for (int c = in.read(buffer); c != -1; c = in.read(buffer)) {
- out.write(buffer, 0, c);
- out.flush();
+ try(FileOutputStream out = new FileOutputStream(f)) {
+ byte[] buffer = new byte[policy.getBufferSize()];
+ for (int c = in.read(buffer); c != -1; c = in.read(buffer)) {
+ out.write(buffer, 0, c);
+ out.flush();
+ }
}
- out.flush();
- out.close();
// File.toURL() is deprecated
return f.toURI().toURL();
}
@@ -104,14 +105,14 @@ public class FileSystemBlobStrategy implements BlobUploadStrategy, BlobDownloadS
return new FileInputStream(getFile(message));
}
-
+
/**
- * Return the {@link File} for the {@link ActiveMQBlobMessage}.
- *
+ * Return the {@link File} for the {@link ActiveMQBlobMessage}.
+ *
* @param message
* @return file
* @throws JMSException
- * @throws IOException
+ * @throws IOException
*/
protected File getFile(ActiveMQBlobMessage message) throws JMSException, IOException {
if (message.getURL() != null) {
@@ -123,8 +124,8 @@ public class FileSystemBlobStrategy implements BlobUploadStrategy, BlobDownloadS
}
}
//replace all : with _ to make windows more happy
- String fileName = message.getJMSMessageID().replaceAll(":", "_");
- return new File(rootFile, fileName);
-
+ String fileName = message.getJMSMessageID().replaceAll(":", "_");
+ return new File(rootFile, fileName);
+
}
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java
----------------------------------------------------------------------
diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java
index ae87837..28080e6 100644
--- a/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java
+++ b/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java
@@ -56,7 +56,7 @@ public class CreateCommand extends AbstractCommand {
protected String amqConf = "conf/activemq.xml"; // default conf if no conf is specified via --amqconf
- // default files to create
+ // default files to create
protected String[][] fileWriteMap = {
{ "winActivemq", "bin/${brokerName}.bat" },
{ "unixActivemq", "bin/${brokerName}" }
@@ -84,7 +84,7 @@ public class CreateCommand extends AbstractCommand {
targetAmqBase = new File(token);
brokerName = targetAmqBase.getName();
-
+
if (targetAmqBase.exists()) {
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
@@ -191,9 +191,10 @@ public class CreateCommand extends AbstractCommand {
buf.put(data.getBytes());
buf.flip();
- FileChannel destinationChannel = new FileOutputStream(dest).getChannel();
- destinationChannel.write(buf);
- destinationChannel.close();
+ try(FileOutputStream fos = new FileOutputStream(dest);
+ FileChannel destinationChannel = fos.getChannel()) {
+ destinationChannel.write(buf);
+ }
// Set file permissions available for Java 6.0 only
dest.setExecutable(true);
@@ -215,11 +216,13 @@ public class CreateCommand extends AbstractCommand {
if (!from.exists()) {
return;
}
- FileChannel sourceChannel = new FileInputStream(from).getChannel();
- FileChannel destinationChannel = new FileOutputStream(dest).getChannel();
- sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
- sourceChannel.close();
- destinationChannel.close();
+
+ try(FileInputStream fis = new FileInputStream(from);
+ FileChannel sourceChannel = fis.getChannel();
+ FileOutputStream fos = new FileOutputStream(dest);
+ FileChannel destinationChannel = fos.getChannel()) {
+ sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
+ }
}
private void copyConfDirectory(File from, File dest) throws IOException {
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-fileserver/src/main/java/org/apache/activemq/util/IOHelper.java
----------------------------------------------------------------------
diff --git a/activemq-fileserver/src/main/java/org/apache/activemq/util/IOHelper.java b/activemq-fileserver/src/main/java/org/apache/activemq/util/IOHelper.java
index 90149f5..d9e8b0d 100644
--- a/activemq-fileserver/src/main/java/org/apache/activemq/util/IOHelper.java
+++ b/activemq-fileserver/src/main/java/org/apache/activemq/util/IOHelper.java
@@ -24,7 +24,7 @@ import java.io.InputStream;
import java.io.OutputStream;
/**
- *
+ *
*/
public final class IOHelper {
protected static final int MAX_DIR_NAME_LENGTH;
@@ -53,7 +53,7 @@ public final class IOHelper {
return "";
}
}
-
+
public static boolean deleteFile(File fileToDelete) {
if (fileToDelete == null || !fileToDelete.exists()) {
return true;
@@ -62,7 +62,7 @@ public final class IOHelper {
result &= fileToDelete.delete();
return result;
}
-
+
public static boolean deleteChildren(File parent) {
if (parent == null || !parent.exists()) {
return false;
@@ -87,46 +87,49 @@ public final class IOHelper {
}
}
}
-
+
return result;
}
-
-
+
+
public static void moveFile(File src, File targetDirectory) throws IOException {
if (!src.renameTo(new File(targetDirectory, src.getName()))) {
throw new IOException("Failed to move " + src + " to " + targetDirectory);
}
}
-
+
public static void copyFile(File src, File dest) throws IOException {
FileInputStream fileSrc = new FileInputStream(src);
FileOutputStream fileDest = new FileOutputStream(dest);
copyInputStream(fileSrc, fileDest);
}
-
+
public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
- int len = in.read(buffer);
- while (len >= 0) {
- out.write(buffer, 0, len);
- len = in.read(buffer);
+ try {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ int len = in.read(buffer);
+ while (len >= 0) {
+ out.write(buffer, 0, len);
+ len = in.read(buffer);
+ }
+ } finally {
+ in.close();
+ out.close();
}
- in.close();
- out.close();
}
-
+
static {
- MAX_DIR_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumDirNameLength","200")).intValue();
- MAX_FILE_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumFileNameLength","64")).intValue();
+ MAX_DIR_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumDirNameLength","200")).intValue();
+ MAX_FILE_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumFileNameLength","64")).intValue();
}
-
+
public static void mkdirs(File dir) throws IOException {
if (dir.exists()) {
if (!dir.isDirectory()) {
throw new IOException("Failed to create directory '" + dir +"', regular file already existed with that name");
}
-
+
} else {
if (!dir.mkdirs()) {
throw new IOException("Failed to create directory '" + dir+"'");
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-jaas/src/main/java/org/apache/activemq/jaas/TextFileCertificateLoginModule.java
----------------------------------------------------------------------
diff --git a/activemq-jaas/src/main/java/org/apache/activemq/jaas/TextFileCertificateLoginModule.java b/activemq-jaas/src/main/java/org/apache/activemq/jaas/TextFileCertificateLoginModule.java
index be00562..284eaba 100644
--- a/activemq-jaas/src/main/java/org/apache/activemq/jaas/TextFileCertificateLoginModule.java
+++ b/activemq-jaas/src/main/java/org/apache/activemq/jaas/TextFileCertificateLoginModule.java
@@ -40,7 +40,7 @@ import javax.security.auth.login.LoginException;
* org.apache.activemq.jaas.textfiledn.user properties respectively. NOTE: This
* class will re-read user and group files for every authentication (i.e it does
* live updates of allowed groups and users).
- *
+ *
* @author sepandm@gmail.com (Sepand)
*/
public class TextFileCertificateLoginModule extends CertificateLoginModule {
@@ -71,7 +71,7 @@ public class TextFileCertificateLoginModule extends CertificateLoginModule {
/**
* Overriding to allow DN authorization based on DNs specified in text
* files.
- *
+ *
* @param certs The certificate the incoming connection provided.
* @return The user's authenticated name or null if unable to authenticate
* the user.
@@ -88,10 +88,8 @@ public class TextFileCertificateLoginModule extends CertificateLoginModule {
Properties users = new Properties();
- try {
- java.io.FileInputStream in = new java.io.FileInputStream(usersFile);
+ try(java.io.FileInputStream in = new java.io.FileInputStream(usersFile)) {
users.load(in);
- in.close();
} catch (IOException ioe) {
throw new LoginException("Unable to load user properties file " + usersFile);
}
@@ -112,7 +110,7 @@ public class TextFileCertificateLoginModule extends CertificateLoginModule {
/**
* Overriding to allow for group discovery based on text files.
- *
+ *
* @param username The name of the user being examined. This is the same
* name returned by getUserNameForCertificates.
* @return A Set of name Strings for groups this user belongs to.
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/BlobJDBCAdapter.java
----------------------------------------------------------------------
diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/BlobJDBCAdapter.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/BlobJDBCAdapter.java
index e7e77be..6d6721c 100755
--- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/BlobJDBCAdapter.java
+++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/BlobJDBCAdapter.java
@@ -35,18 +35,18 @@ import org.apache.activemq.util.ByteArrayOutputStream;
* This JDBCAdapter inserts and extracts BLOB data using the getBlob()/setBlob()
* operations. This is a little more involved since to insert a blob you have
* to:
- *
+ *
* 1: insert empty blob. 2: select the blob 3: finally update the blob with data
* value.
- *
+ *
* The databases/JDBC drivers that use this adapter are:
* <ul>
* <li></li>
* </ul>
- *
+ *
* @org.apache.xbean.XBean element="blobJDBCAdapter"
- *
- *
+ *
+ *
*/
public class BlobJDBCAdapter extends DefaultJDBCAdapter {
@@ -139,18 +139,15 @@ public class BlobJDBCAdapter extends DefaultJDBCAdapter {
return null;
}
Blob blob = rs.getBlob(1);
- InputStream is = blob.getBinaryStream();
- ByteArrayOutputStream os = new ByteArrayOutputStream((int)blob.length());
- int ch;
- while ((ch = is.read()) >= 0) {
- os.write(ch);
+ try(InputStream is = blob.getBinaryStream();
+ ByteArrayOutputStream os = new ByteArrayOutputStream((int)blob.length())) {
+ int ch;
+ while ((ch = is.read()) >= 0) {
+ os.write(ch);
+ }
+ return os.toByteArray();
}
- is.close();
- os.close();
-
- return os.toByteArray();
-
} finally {
cleanupExclusiveLock.readLock().unlock();
close(rs);
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/StreamJDBCAdapter.java
----------------------------------------------------------------------
diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/StreamJDBCAdapter.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/StreamJDBCAdapter.java
index 43b7c25..c83600b 100755
--- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/StreamJDBCAdapter.java
+++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/StreamJDBCAdapter.java
@@ -28,15 +28,15 @@ import org.apache.activemq.util.ByteArrayInputStream;
/**
* This JDBCAdapter inserts and extracts BLOB data using the
* setBinaryStream()/getBinaryStream() operations.
- *
+ *
* The databases/JDBC drivers that use this adapter are:
* <ul>
* <li>Axion</li>
* </ul>
- *
+ *
* @org.apache.xbean.XBean element="streamJDBCAdapter"
- *
- *
+ *
+ *
*/
public class StreamJDBCAdapter extends DefaultJDBCAdapter {
@@ -47,16 +47,13 @@ public class StreamJDBCAdapter extends DefaultJDBCAdapter {
@Override
protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException {
- try {
- InputStream is = rs.getBinaryStream(index);
- ByteArrayOutputStream os = new ByteArrayOutputStream(1024 * 4);
+ try (InputStream is = rs.getBinaryStream(index);
+ ByteArrayOutputStream os = new ByteArrayOutputStream(1024 * 4)) {
int ch;
while ((ch = is.read()) >= 0) {
os.write(ch);
}
- is.close();
- os.close();
return os.toByteArray();
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
index dbd7dc8..8c5f0fe 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
@@ -196,10 +196,10 @@ public class PageFile {
public byte[] getDiskBound() throws IOException {
if (diskBound == null && diskBoundLocation != -1) {
diskBound = new byte[length];
- RandomAccessFile file = new RandomAccessFile(tmpFile, "r");
- file.seek(diskBoundLocation);
- file.read(diskBound);
- file.close();
+ try(RandomAccessFile file = new RandomAccessFile(tmpFile, "r")) {
+ file.seek(diskBoundLocation);
+ file.read(diskBound);
+ }
diskBoundLocation = -1;
}
return diskBound;
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/DiskBenchmark.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/DiskBenchmark.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/DiskBenchmark.java
index 641fe79..a3cbb27 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/DiskBenchmark.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/DiskBenchmark.java
@@ -17,11 +17,12 @@
package org.apache.activemq.store.kahadb.disk.util;
import java.io.File;
-import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Arrays;
+import org.apache.activemq.util.RecoverableRandomAccessFile;
+
/**
* This class is used to get a benchmark the raw disk performance.
*/
@@ -201,84 +202,88 @@ public class DiskBenchmark {
for (int i = 0; i < data.length; i++) {
data[i] = (byte) ('a' + (i % 26));
}
-
rc.size = data.length;
- RandomAccessFile raf = new RandomAccessFile(file, "rw");
- raf.setLength(size);
-
- // Figure out how many writes we can do in the sample interval.
- long start = System.currentTimeMillis();
- long now = System.currentTimeMillis();
- int ioCount = 0;
- while (true) {
- if ((now - start) > sampleInterval) {
- break;
- }
- raf.seek(0);
- for (long i = 0; i + data.length < size; i += data.length) {
- raf.write(data);
- ioCount++;
- now = System.currentTimeMillis();
+
+ long start;
+ long now;
+ int ioCount;
+
+ try(RecoverableRandomAccessFile raf = new RecoverableRandomAccessFile(file, "rw")) {
+ preallocateDataFile(raf, file.getParentFile());
+ start = System.currentTimeMillis();
+ now = System.currentTimeMillis();
+ ioCount = 0;
+
+ // Figure out how many writes we can do in the sample interval.
+ while (true) {
if ((now - start) > sampleInterval) {
break;
}
+ raf.seek(0);
+ for (long i = 0; i + data.length < size; i += data.length) {
+ raf.write(data);
+ ioCount++;
+ now = System.currentTimeMillis();
+ if ((now - start) > sampleInterval) {
+ break;
+ }
+ }
+ // Sync to disk so that the we actually write the data to disk..
+ // otherwise OS buffering might not really do the write.
+ raf.getChannel().force(!SKIP_METADATA_UPDATE);
}
- // Sync to disk so that the we actually write the data to disk..
- // otherwise OS buffering might not really do the write.
raf.getChannel().force(!SKIP_METADATA_UPDATE);
}
- raf.getChannel().force(!SKIP_METADATA_UPDATE);
- raf.close();
now = System.currentTimeMillis();
rc.size = data.length;
rc.writes = ioCount;
rc.writeDuration = (now - start);
- raf = new RandomAccessFile(file, "rw");
- start = System.currentTimeMillis();
- now = System.currentTimeMillis();
- ioCount = 0;
- while (true) {
- if ((now - start) > sampleInterval) {
- break;
- }
- for (long i = 0; i + data.length < size; i += data.length) {
- raf.seek(i);
- raf.write(data);
- raf.getChannel().force(false);
- ioCount++;
- now = System.currentTimeMillis();
+ try(RecoverableRandomAccessFile raf = new RecoverableRandomAccessFile(file, "rw")) {
+ start = System.currentTimeMillis();
+ now = System.currentTimeMillis();
+ ioCount = 0;
+ while (true) {
if ((now - start) > sampleInterval) {
break;
}
+ for (long i = 0; i + data.length < size; i += data.length) {
+ raf.seek(i);
+ raf.write(data);
+ raf.getChannel().force(!SKIP_METADATA_UPDATE);
+ ioCount++;
+ now = System.currentTimeMillis();
+ if ((now - start) > sampleInterval) {
+ break;
+ }
+ }
}
}
- raf.close();
now = System.currentTimeMillis();
rc.syncWrites = ioCount;
rc.syncWriteDuration = (now - start);
- raf = new RandomAccessFile(file, "rw");
- start = System.currentTimeMillis();
- now = System.currentTimeMillis();
- ioCount = 0;
- while (true) {
- if ((now - start) > sampleInterval) {
- break;
- }
- raf.seek(0);
- for (long i = 0; i + data.length < size; i += data.length) {
- raf.seek(i);
- raf.readFully(data);
- ioCount++;
- now = System.currentTimeMillis();
+ try(RecoverableRandomAccessFile raf = new RecoverableRandomAccessFile(file, "rw")) {
+ start = System.currentTimeMillis();
+ now = System.currentTimeMillis();
+ ioCount = 0;
+ while (true) {
if ((now - start) > sampleInterval) {
break;
}
+ raf.seek(0);
+ for (long i = 0; i + data.length < size; i += data.length) {
+ raf.seek(i);
+ raf.readFully(data);
+ ioCount++;
+ now = System.currentTimeMillis();
+ if ((now - start) > sampleInterval) {
+ break;
+ }
+ }
}
}
- raf.close();
rc.reads = ioCount;
rc.readDuration = (now - start);
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
----------------------------------------------------------------------
diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
index d366962..23fa40a 100644
--- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
+++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
@@ -83,15 +83,17 @@ public class ProtocolConverter {
private static final StompFrame ping = new StompFrame(Stomp.Commands.KEEPALIVE);
static {
- InputStream in = null;
String version = "5.6.0";
- if ((in = ProtocolConverter.class.getResourceAsStream("/org/apache/activemq/version.txt")) != null) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- try {
- version = reader.readLine();
- } catch(Exception e) {
+ try(InputStream in = ProtocolConverter.class.getResourceAsStream("/org/apache/activemq/version.txt")) {
+ if (in != null) {
+ try(InputStreamReader isr = new InputStreamReader(in);
+ BufferedReader reader = new BufferedReader(isr)) {
+ version = reader.readLine();
+ }
}
+ }catch(Exception e) {
}
+
BROKER_VERSION = version;
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java
----------------------------------------------------------------------
diff --git a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java
index 41cc864..58efb99 100644
--- a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java
+++ b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java
@@ -294,8 +294,10 @@ public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
Properties fileProps = new Properties();
try {
if (configFile != null) {
- LOG.info("Loading properties file: " + configFile.getAbsolutePath());
- fileProps.load(new FileInputStream(configFile));
+ try(FileInputStream inputStream = new FileInputStream(configFile)) {
+ LOG.info("Loading properties file: " + configFile.getAbsolutePath());
+ fileProps.load(inputStream);
+ }
}
} catch (IOException e) {
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
----------------------------------------------------------------------
diff --git a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
index 4595ef3..68ea5cb 100644
--- a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
+++ b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
@@ -376,13 +376,14 @@ public class JmsProducerClient extends AbstractJmsMeasurableClient {
}
// try to load file
- BufferedReader br = new BufferedReader(new FileReader(f));
StringBuffer payload = new StringBuffer();
- String tmp = null;
- while ((tmp = br.readLine()) != null) {
- payload.append(tmp);
+ try(FileReader fr = new FileReader(f);
+ BufferedReader br = new BufferedReader(fr)) {
+ String tmp = null;
+ while ((tmp = br.readLine()) != null) {
+ payload.append(tmp);
+ }
}
- br.close();
jmsTextMessage = getSession().createTextMessage(payload.toString());
return jmsTextMessage;
} catch (FileNotFoundException ex) {
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java
----------------------------------------------------------------------
diff --git a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java
index 520153a..130c2d0 100644
--- a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java
+++ b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java
@@ -195,22 +195,25 @@ public class XmlFilePerfReportWriter extends AbstractPerfReportWriter {
xmlFileWriter.println("<property name='performanceData'>");
xmlFileWriter.println("<list>");
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempLogFile)));
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.startsWith("[TP-DATA]")) {
- handleCsvData(REPORT_PLUGIN_THROUGHPUT, line.substring("[TP-DATA]".length()));
- parsePerfCsvData("tpdata", line.substring("[TP-DATA]".length()));
- } else if (line.startsWith("[CPU-DATA]")) {
- handleCsvData(REPORT_PLUGIN_CPU, line.substring("[CPU-DATA]".length()));
- parsePerfCsvData("cpudata", line.substring("[CPU-DATA]".length()));
- } else if (line.startsWith("[INFO]")) {
- xmlFileWriter.println("<info>" + line + "</info>");
- } else {
- xmlFileWriter.println("<error>" + line + "</error>");
+ try (FileInputStream fileInputStream = new FileInputStream(tempLogFile);
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
+ BufferedReader reader = new BufferedReader(inputStreamReader)) {
+
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (line.startsWith("[TP-DATA]")) {
+ handleCsvData(REPORT_PLUGIN_THROUGHPUT, line.substring("[TP-DATA]".length()));
+ parsePerfCsvData("tpdata", line.substring("[TP-DATA]".length()));
+ } else if (line.startsWith("[CPU-DATA]")) {
+ handleCsvData(REPORT_PLUGIN_CPU, line.substring("[CPU-DATA]".length()));
+ parsePerfCsvData("cpudata", line.substring("[CPU-DATA]".length()));
+ } else if (line.startsWith("[INFO]")) {
+ xmlFileWriter.println("<info>" + line + "</info>");
+ } else {
+ xmlFileWriter.println("<error>" + line + "</error>");
+ }
}
}
-
xmlFileWriter.println("</list>");
xmlFileWriter.println("</property>");
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/42d9fd11/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java
----------------------------------------------------------------------
diff --git a/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java
index b29bf05..80f9c3c 100644
--- a/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java
+++ b/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java
@@ -3,7 +3,7 @@
//------------------------------------------------------------------------
//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
+//You may obtain a copy of the License at
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
@@ -64,19 +64,19 @@ public class AjaxServlet extends MessageListenerServlet {
byte[] data = jsCache.get(resource);
if (data == null) {
- InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
- if (in != null) {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buf = new byte[4096];
- int len = in.read(buf);
- while (len >= 0) {
- out.write(buf, 0, len);
- len = in.read(buf);
+ try(InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) {
+ if (in != null) {
+ try(ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+ byte[] buf = new byte[4096];
+ int len = in.read(buf);
+ while (len >= 0) {
+ out.write(buf, 0, len);
+ len = in.read(buf);
+ }
+ data = out.toByteArray();
+ jsCache.put(resource, data);
+ }
}
- in.close();
- out.close();
- data = out.toByteArray();
- jsCache.put(resource, data);
}
}