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
c82de832
Commit
c82de832
authored
May 08, 2021
by
nguyensach
Committed by
Stephane Nicoll
May 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use try-with-resources statement
See gh-26417
parent
217f6efa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
SampleAtomikosApplication.java
...in/java/smoketest/atomikos/SampleAtomikosApplication.java
+14
-16
No files found.
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/src/main/java/smoketest/atomikos/SampleAtomikosApplication.java
View file @
c82de832
...
...
@@ -16,30 +16,28 @@
package
smoketest
.
atomikos
;
import
java.io.Closeable
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.
Configurable
ApplicationContext
;
@SpringBootApplication
public
class
SampleAtomikosApplication
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ApplicationContext
context
=
SpringApplication
.
run
(
SampleAtomikosApplication
.
class
,
args
);
AccountService
service
=
context
.
getBean
(
AccountService
.
class
);
AccountRepository
repository
=
context
.
getBean
(
AccountRepository
.
class
);
service
.
createAccountAndNotify
(
"josh"
);
System
.
out
.
println
(
"Count is "
+
repository
.
count
());
try
{
service
.
createAccountAndNotify
(
"error"
);
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
.
getMessage
());
try
(
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
SampleAtomikosApplication
.
class
,
args
))
{
AccountService
service
=
context
.
getBean
(
AccountService
.
class
);
AccountRepository
repository
=
context
.
getBean
(
AccountRepository
.
class
);
service
.
createAccountAndNotify
(
"josh"
);
System
.
out
.
println
(
"Count is "
+
repository
.
count
());
try
{
service
.
createAccountAndNotify
(
"error"
);
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
.
getMessage
());
}
System
.
out
.
println
(
"Count is "
+
repository
.
count
());
Thread
.
sleep
(
100
);
}
System
.
out
.
println
(
"Count is "
+
repository
.
count
());
Thread
.
sleep
(
100
);
((
Closeable
)
context
).
close
();
}
}
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