This is an automated email from the git hooks/post-receive script. tjaalton pushed a commit to branch master in repository jackson-jaxrs-providers.
commit 7590b755fcbc21f6443442553521d9122bd6aeb1 Author: Steven Schlansker <[email protected]> Date: Fri Apr 12 12:05:28 2013 -0700 Ensure that ProviderBase closes JsonGenerator. --- .../fasterxml/jackson/jaxrs/base/ProviderBase.java | 68 ++++++++++++---------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/base/src/main/java/com/fasterxml/jackson/jaxrs/base/ProviderBase.java b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/ProviderBase.java index 221d168..c7082f3 100644 --- a/base/src/main/java/com/fasterxml/jackson/jaxrs/base/ProviderBase.java +++ b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/ProviderBase.java @@ -397,49 +397,53 @@ public abstract class ProviderBase< } ObjectWriter writer = endpoint.getWriter(); - + /* 27-Feb-2009, tatu: Where can we find desired encoding? Within * HTTP headers? */ JsonEncoding enc = findEncoding(mediaType, httpHeaders); JsonGenerator jg = writer.getFactory().createGenerator(entityStream, enc); - // Want indentation? - if (writer.isEnabled(SerializationFeature.INDENT_OUTPUT)) { - jg.useDefaultPrettyPrinter(); - } - // 04-Mar-2010, tatu: How about type we were given? (if any) - JavaType rootType = null; - - if (genericType != null && value != null) { - /* 10-Jan-2011, tatu: as per [JACKSON-456], it's not safe to just force root - * type since it prevents polymorphic type serialization. Since we really - * just need this for generics, let's only use generic type if it's truly - * generic. - */ - if (genericType.getClass() != Class.class) { // generic types are other impls of 'java.lang.reflect.Type' - /* This is still not exactly right; should root type be further - * specialized with 'value.getClass()'? Let's see how well this works before - * trying to come up with more complete solution. - */ - rootType = writer.getTypeFactory().constructType(genericType); - /* 26-Feb-2011, tatu: To help with [JACKSON-518], we better recognize cases where - * type degenerates back into "Object.class" (as is the case with plain TypeVariable, - * for example), and not use that. + try { + // Want indentation? + if (writer.isEnabled(SerializationFeature.INDENT_OUTPUT)) { + jg.useDefaultPrettyPrinter(); + } + // 04-Mar-2010, tatu: How about type we were given? (if any) + JavaType rootType = null; + + if (genericType != null && value != null) { + /* 10-Jan-2011, tatu: as per [JACKSON-456], it's not safe to just force root + * type since it prevents polymorphic type serialization. Since we really + * just need this for generics, let's only use generic type if it's truly + * generic. */ - if (rootType.getRawClass() == Object.class) { - rootType = null; + if (genericType.getClass() != Class.class) { // generic types are other impls of 'java.lang.reflect.Type' + /* This is still not exactly right; should root type be further + * specialized with 'value.getClass()'? Let's see how well this works before + * trying to come up with more complete solution. + */ + rootType = writer.getTypeFactory().constructType(genericType); + /* 26-Feb-2011, tatu: To help with [JACKSON-518], we better recognize cases where + * type degenerates back into "Object.class" (as is the case with plain TypeVariable, + * for example), and not use that. + */ + if (rootType.getRawClass() == Object.class) { + rootType = null; + } } } - } - // Most of the configuration now handled through EndpointConfig, ObjectWriter - // but we may need to force root type: - if (rootType != null) { - writer = writer.withType(rootType); + // Most of the configuration now handled through EndpointConfig, ObjectWriter + // but we may need to force root type: + if (rootType != null) { + writer = writer.withType(rootType); + } + value = endpoint.modifyBeforeWrite(value); + writer.writeValue(jg, value); + } finally { + jg.close(); } - value = endpoint.modifyBeforeWrite(value); - writer.writeValue(jg, value); } /** -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-jaxrs-providers.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

