From 27c12809493954a7521819cc623fc7873ecf2f4f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 11 Feb 2016 22:24:13 +0100 Subject: [PATCH] Consider negative contentLength() result as not resolvable Issue: SPR-13571 --- .../http/converter/AbstractHttpMessageConverter.java | 4 ++-- .../http/converter/ResourceHttpMessageConverter.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java index 68289532451..33e9a84b62b 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -217,7 +217,7 @@ public abstract class AbstractHttpMessageConverter implements HttpMessageConv headers.setContentType(contentTypeToUse); } } - if (headers.getContentLength() == -1) { + if (headers.getContentLength() < 0) { Long contentLength = getContentLength(t, headers.getContentType()); if (contentLength != null) { headers.setContentLength(contentLength); diff --git a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java index cc8da3601a1..3d7db2fba54 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,11 @@ public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter