Skip to content

Commit

Permalink
use output stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Surya Gaddipati committed Mar 2, 2015
1 parent 1b42f48 commit aa62898
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/com/groupon/jenkins/util/JsonResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,21 @@
import org.kohsuke.stapler.export.Flavor;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import java.io.IOException;

public class JsonResponse {
public static void render(StaplerResponse rsp, Object output) throws IOException {
rsp.setContentType("application/json");
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
mapper.writeValue(rsp.getWriter(),output);
ServletOutputStream outputStream = null;
try {
rsp.setContentType("application/json");
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
outputStream = rsp.getOutputStream();
mapper.writeValue(outputStream, output);
// outputStream.flush();
} finally{
// if(outputStream!=null)
// outputStream.close();;
}
}
}

0 comments on commit aa62898

Please sign in to comment.