Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
3e797c32
Commit
3e797c32
authored
Jan 20, 2017
by
rajadilipkolli
Committed by
Andy Wilkinson
May 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use try-with-resources to close resources automatically
See gh-8045
parent
291f44f5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
19 additions
and
61 deletions
+19
-61
HeapdumpMvcEndpoint.java
...mework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpoint.java
+4
-15
CacheStatisticsAutoConfigurationTests.java
.../autoconfigure/CacheStatisticsAutoConfigurationTests.java
+1
-5
InfinispanCacheConfiguration.java
...oot/autoconfigure/cache/InfinispanCacheConfiguration.java
+2
-6
EmbeddedLdapAutoConfiguration.java
...onfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java
+1
-5
ApplicationHome.java
...c/main/java/org/springframework/boot/ApplicationHome.java
+6
-14
ImageBanner.java
...t/src/main/java/org/springframework/boot/ImageBanner.java
+2
-5
FileSessionPersistence.java
...rk/boot/web/embedded/undertow/FileSessionPersistence.java
+2
-6
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+1
-5
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpoint.java
View file @
3e797c32
...
@@ -51,6 +51,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
...
@@ -51,6 +51,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
*
*
* @author Lari Hotari
* @author Lari Hotari
* @author Phillip Webb
* @author Phillip Webb
* @author rajakolli
* @since 1.4.0
* @since 1.4.0
*/
*/
@ConfigurationProperties
(
prefix
=
"endpoints.heapdump"
)
@ConfigurationProperties
(
prefix
=
"endpoints.heapdump"
)
...
@@ -144,24 +145,12 @@ public class HeapdumpMvcEndpoint extends AbstractNamedMvcEndpoint {
...
@@ -144,24 +145,12 @@ public class HeapdumpMvcEndpoint extends AbstractNamedMvcEndpoint {
response
.
setContentType
(
"application/octet-stream"
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
(
heapDumpFile
.
getName
()
+
".gz"
)
+
"\""
);
"attachment; filename=\""
+
(
heapDumpFile
.
getName
()
+
".gz"
)
+
"\""
);
try
{
try
(
InputStream
in
=
new
FileInputStream
(
heapDumpFile
);
InputStream
in
=
new
FileInputStream
(
heapDumpFile
);
GZIPOutputStream
out
=
new
GZIPOutputStream
(
response
.
getOutputStream
()))
{
try
{
GZIPOutputStream
out
=
new
GZIPOutputStream
(
response
.
getOutputStream
());
StreamUtils
.
copy
(
in
,
out
);
StreamUtils
.
copy
(
in
,
out
);
out
.
finish
();
out
.
finish
();
}
catch
(
NullPointerException
ex
)
{
}
finally
{
try
{
in
.
close
();
}
catch
(
Throwable
ex
)
{
}
}
}
}
catch
(
FileNotFoundException
ex
)
{
catch
(
NullPointerException
|
FileNotFoundException
ex
)
{
}
}
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfigurationTests.java
View file @
3e797c32
...
@@ -270,13 +270,9 @@ public class CacheStatisticsAutoConfigurationTests {
...
@@ -270,13 +270,9 @@ public class CacheStatisticsAutoConfigurationTests {
@Bean
@Bean
public
EmbeddedCacheManager
embeddedCacheManager
()
throws
IOException
{
public
EmbeddedCacheManager
embeddedCacheManager
()
throws
IOException
{
Resource
resource
=
new
ClassPathResource
(
"cache/test-infinispan.xml"
);
Resource
resource
=
new
ClassPathResource
(
"cache/test-infinispan.xml"
);
InputStream
in
=
resource
.
getInputStream
();
try
(
InputStream
in
=
resource
.
getInputStream
())
{
try
{
return
new
DefaultCacheManager
(
in
);
return
new
DefaultCacheManager
(
in
);
}
}
finally
{
in
.
close
();
}
}
}
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/InfinispanCacheConfiguration.java
View file @
3e797c32
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -88,13 +88,9 @@ public class InfinispanCacheConfiguration {
...
@@ -88,13 +88,9 @@ public class InfinispanCacheConfiguration {
Resource
location
=
this
.
cacheProperties
Resource
location
=
this
.
cacheProperties
.
resolveConfigLocation
(
this
.
cacheProperties
.
getInfinispan
().
getConfig
());
.
resolveConfigLocation
(
this
.
cacheProperties
.
getInfinispan
().
getConfig
());
if
(
location
!=
null
)
{
if
(
location
!=
null
)
{
InputStream
in
=
location
.
getInputStream
();
try
(
InputStream
in
=
location
.
getInputStream
())
{
try
{
return
new
DefaultCacheManager
(
in
);
return
new
DefaultCacheManager
(
in
);
}
}
finally
{
in
.
close
();
}
}
}
return
new
DefaultCacheManager
();
return
new
DefaultCacheManager
();
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java
View file @
3e797c32
...
@@ -154,13 +154,9 @@ public class EmbeddedLdapAutoConfiguration {
...
@@ -154,13 +154,9 @@ public class EmbeddedLdapAutoConfiguration {
try
{
try
{
Resource
resource
=
this
.
applicationContext
.
getResource
(
location
);
Resource
resource
=
this
.
applicationContext
.
getResource
(
location
);
if
(
resource
.
exists
())
{
if
(
resource
.
exists
())
{
InputStream
inputStream
=
resource
.
getInputStream
();
try
(
InputStream
inputStream
=
resource
.
getInputStream
())
{
try
{
this
.
server
.
importFromLDIF
(
true
,
new
LDIFReader
(
inputStream
));
this
.
server
.
importFromLDIF
(
true
,
new
LDIFReader
(
inputStream
));
}
}
finally
{
inputStream
.
close
();
}
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/ApplicationHome.java
View file @
3e797c32
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -72,19 +72,11 @@ public class ApplicationHome {
...
@@ -72,19 +72,11 @@ public class ApplicationHome {
private
Class
<?>
getStartClass
(
Enumeration
<
URL
>
manifestResources
)
{
private
Class
<?>
getStartClass
(
Enumeration
<
URL
>
manifestResources
)
{
while
(
manifestResources
.
hasMoreElements
())
{
while
(
manifestResources
.
hasMoreElements
())
{
try
{
try
(
InputStream
inputStream
=
manifestResources
.
nextElement
().
openStream
())
{
InputStream
inputStream
=
manifestResources
.
nextElement
().
openStream
();
Manifest
manifest
=
new
Manifest
(
inputStream
);
try
{
String
startClass
=
manifest
.
getMainAttributes
().
getValue
(
"Start-Class"
);
Manifest
manifest
=
new
Manifest
(
inputStream
);
if
(
startClass
!=
null
)
{
String
startClass
=
manifest
.
getMainAttributes
()
return
ClassUtils
.
forName
(
startClass
,
getClass
().
getClassLoader
());
.
getValue
(
"Start-Class"
);
if
(
startClass
!=
null
)
{
return
ClassUtils
.
forName
(
startClass
,
getClass
().
getClassLoader
());
}
}
finally
{
inputStream
.
close
();
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/ImageBanner.java
View file @
3e797c32
...
@@ -101,14 +101,11 @@ public class ImageBanner implements Banner {
...
@@ -101,14 +101,11 @@ public class ImageBanner implements Banner {
}
}
private
BufferedImage
readImage
(
int
width
,
int
height
)
throws
IOException
{
private
BufferedImage
readImage
(
int
width
,
int
height
)
throws
IOException
{
InputStream
inputStream
=
this
.
image
.
getInputStream
();
try
(
InputStream
inputStream
=
this
.
image
.
getInputStream
())
{
try
{
BufferedImage
image
=
ImageIO
.
read
(
inputStream
);
BufferedImage
image
=
ImageIO
.
read
(
inputStream
);
return
resizeImage
(
image
,
width
,
height
);
return
resizeImage
(
image
,
width
,
height
);
}
}
finally
{
inputStream
.
close
();
}
}
}
private
BufferedImage
resizeImage
(
BufferedImage
image
,
int
width
,
int
height
)
{
private
BufferedImage
resizeImage
(
BufferedImage
image
,
int
width
,
int
height
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java
View file @
3e797c32
...
@@ -95,14 +95,10 @@ class FileSessionPersistence implements SessionPersistenceManager {
...
@@ -95,14 +95,10 @@ class FileSessionPersistence implements SessionPersistenceManager {
private
Map
<
String
,
PersistentSession
>
load
(
File
file
,
ClassLoader
classLoader
)
private
Map
<
String
,
PersistentSession
>
load
(
File
file
,
ClassLoader
classLoader
)
throws
IOException
,
ClassNotFoundException
{
throws
IOException
,
ClassNotFoundException
{
ObjectInputStream
stream
=
new
ConfigurableObjectInputStream
(
try
(
ObjectInputStream
stream
=
new
ConfigurableObjectInputStream
(
new
FileInputStream
(
file
),
classLoader
);
new
FileInputStream
(
file
),
classLoader
))
{
try
{
return
load
(
stream
);
return
load
(
stream
);
}
}
finally
{
stream
.
close
();
}
}
}
private
Map
<
String
,
PersistentSession
>
load
(
ObjectInputStream
stream
)
private
Map
<
String
,
PersistentSession
>
load
(
ObjectInputStream
stream
)
...
...
spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
3e797c32
...
@@ -1196,14 +1196,10 @@ public abstract class AbstractServletWebServerFactoryTests {
...
@@ -1196,14 +1196,10 @@ public abstract class AbstractServletWebServerFactoryTests {
NoSuchAlgorithmException
,
CertificateException
{
NoSuchAlgorithmException
,
CertificateException
{
KeyStore
keyStore
=
KeyStore
.
getInstance
(
"JKS"
);
KeyStore
keyStore
=
KeyStore
.
getInstance
(
"JKS"
);
Resource
resource
=
new
ClassPathResource
(
"test.jks"
);
Resource
resource
=
new
ClassPathResource
(
"test.jks"
);
InputStream
inputStream
=
resource
.
getInputStream
();
try
(
InputStream
inputStream
=
resource
.
getInputStream
())
{
try
{
keyStore
.
load
(
inputStream
,
"secret"
.
toCharArray
());
keyStore
.
load
(
inputStream
,
"secret"
.
toCharArray
());
return
keyStore
;
return
keyStore
;
}
}
finally
{
inputStream
.
close
();
}
}
}
private
class
TestGzipInputStreamFactory
implements
InputStreamFactory
{
private
class
TestGzipInputStreamFactory
implements
InputStreamFactory
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment