Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tp-4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pirkl-poo-2018
tp-4
Commits
06b6bd25
Commit
06b6bd25
authored
6 years ago
by
Alexis Durgnat
Browse files
Options
Downloads
Patches
Plain Diff
Try -> Try-with-ressources
parent
359b56f5
Branches
dev_messageQueue
No related tags found
1 merge request
!12
Try -> Try-with-ressources
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/ch/hepia/mq/MessageQueue.java
+8
-11
8 additions, 11 deletions
src/main/java/ch/hepia/mq/MessageQueue.java
with
8 additions
and
11 deletions
src/main/java/ch/hepia/mq/MessageQueue.java
+
8
−
11
View file @
06b6bd25
...
...
@@ -55,32 +55,29 @@ public abstract class MessageQueue {
}
public
static
<
T
extends
Serializable
>
byte
[]
serialize
(
T
object
){
ObjectOutputStream
oos
=
null
;
ByteArrayOutputStream
byteStream
=
new
ByteArrayOutputStream
();
try
{
oos
=
new
ObjectOutputStream
(
byteStream
);
try
(
ByteArrayOutputStream
byteStream
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
byteStream
)
)
{
oos
.
writeObject
(
object
);
oos
.
flush
();
return
byteStream
.
toByteArray
();
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
// TODO
System
.
exit
(
1
);
}
return
null
;
}
public
static
<
T
extends
Serializable
>
T
unserialize
(
byte
[]
serializedData
){
ByteArrayInputStream
inputStream
=
new
ByteArrayInputStream
(
serializedData
);
T
result
=
null
;
try
{
ObjectInputStream
ois
=
new
ObjectInputStream
(
inputStream
);
try
(
ByteArrayInputStream
inputStream
=
new
ByteArrayInputStream
(
serializedData
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
inputStream
)
)
{
result
=
(
T
)
ois
.
readObject
();
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
// TODO
System
.
exit
(
1
);
}
return
result
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment