Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
ipaaca
Commits
7afed74f
Commit
7afed74f
authored
8 years ago
by
Herwin van Welbergen
Browse files
Options
Downloads
Patches
Plain Diff
fixed thread safety of Payload
parent
447c64b4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ipaacalib/java/src/ipaaca/Payload.java
+20
-8
20 additions, 8 deletions
ipaacalib/java/src/ipaaca/Payload.java
with
20 additions
and
8 deletions
ipaacalib/java/src/ipaaca/Payload.java
+
20
−
8
View file @
7afed74f
...
...
@@ -36,7 +36,10 @@ import ipaaca.protobuf.Ipaaca.PayloadItem;
import
org.apache.commons.lang.StringEscapeUtils
;
import
com.google.common.collect.ImmutableSet
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -49,7 +52,7 @@ import java.util.Set;
*/
public
class
Payload
implements
Map
<
String
,
String
>
{
private
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
private
Map
<
String
,
String
>
map
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
String
>()
)
;
private
final
AbstractIU
iu
;
public
Payload
(
AbstractIU
iu
)
...
...
@@ -82,17 +85,23 @@ public class Payload implements Map<String, String>
public
void
set
(
Map
<
String
,
String
>
newPayload
,
String
writerName
)
{
iu
.
setPayload
(
newPayload
,
writerName
);
map
.
clear
();
map
.
putAll
(
newPayload
);
synchronized
(
map
)
{
map
.
clear
();
map
.
putAll
(
newPayload
);
}
}
public
void
set
(
List
<
PayloadItem
>
newPayload
,
String
writerName
)
{
iu
.
handlePayloadSetting
(
newPayload
,
writerName
);
map
.
clear
();
for
(
PayloadItem
item
:
newPayload
)
synchronized
(
map
)
{
map
.
put
(
item
.
getKey
(),
pseudoConvertFromJSON
(
item
.
getValue
(),
item
.
getType
()));
map
.
clear
();
for
(
PayloadItem
item
:
newPayload
)
{
map
.
put
(
item
.
getKey
(),
pseudoConvertFromJSON
(
item
.
getValue
(),
item
.
getType
()));
}
}
}
...
...
@@ -136,9 +145,12 @@ public class Payload implements Map<String, String>
return
map
.
containsValue
(
value
);
}
public
Set
<
java
.
util
.
Map
.
Entry
<
String
,
String
>>
entrySet
()
/**
* Provides an immutable copy of the entryset of the Payload
*/
public
ImmutableSet
<
java
.
util
.
Map
.
Entry
<
String
,
String
>>
entrySet
()
{
return
map
.
entrySet
();
return
ImmutableSet
.
copyOf
(
map
.
entrySet
()
)
;
}
public
boolean
equals
(
Object
o
)
...
...
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