Skip to content

Commit

Permalink
Refactor. Move C2BConverter creation into a dedicated method.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1701020 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Sep 3, 2015
1 parent 756b6fe commit 9c14922
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions java/org/apache/catalina/connector/OutputBuffer.java
Expand Up @@ -572,28 +572,33 @@ protected void setConverter() throws IOException {
conv = encoders.get(charset);

if (conv == null) {
if (Globals.IS_SECURITY_ENABLED){
try {
conv = AccessController.doPrivileged(
new PrivilegedExceptionAction<C2BConverter>(){

@Override
public C2BConverter run() throws IOException{
return new C2BConverter(charset);
}
conv = createNewConverter(charset);
encoders.put(charset, conv);
}
}


private static C2BConverter createNewConverter(Charset charset) throws IOException {
if (Globals.IS_SECURITY_ENABLED){
try {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<C2BConverter>(){
@Override
public C2BConverter run() throws IOException{
return new C2BConverter(charset);
}
);
} catch (PrivilegedActionException ex) {
Exception e = ex.getException();
if (e instanceof IOException) {
throw (IOException)e;
}
}
);
} catch (PrivilegedActionException ex) {
Exception e = ex.getException();
if (e instanceof IOException) {
throw (IOException) e;
} else {
throw new IOException(ex);
}
} else {
conv = new C2BConverter(charset);
}

encoders.put(charset, conv);
} else {
return new C2BConverter(charset);
}
}

Expand Down

0 comments on commit 9c14922

Please sign in to comment.