Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
GTNPORTAL-3094 Broken Double-Checked Lock in CodecInitializer
Browse files Browse the repository at this point in the history
  • Loading branch information
mposolda authored and bdaw committed Jun 3, 2013
1 parent 5940ad7 commit dc949d4
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -58,7 +58,7 @@ public class CodecInitializer {

private final String confDir;

private AbstractCodec codec;
private volatile AbstractCodec codec;

public CodecInitializer(InitParams initParams) {
ValueParam gateinConfParam = initParams.getValueParam("gatein.conf.dir");
Expand All @@ -71,14 +71,16 @@ public CodecInitializer(InitParams initParams) {
* @throws TokenServiceInitializationException if some error happen during codec initialization
*/
public AbstractCodec getCodec() throws TokenServiceInitializationException {
if (codec == null) {
AbstractCodec helper = codec;
if (helper == null) {
synchronized(this) {
if (codec == null) {
codec = initCodec();
helper = codec;
if (helper == null) {
this.codec = helper = initCodec();
}
}
}
return codec;
return helper;
}


Expand Down

0 comments on commit dc949d4

Please sign in to comment.