Hi
I have begun using the Spring 3.0.1 maintainence release and have noticed an issue with the org.springframework.http.MediaType class.
I had a bean definition of:
This bean was working successfully on Spring 3.0.0 Release but is now causing an issue. I am getting the following Exception:Code:<bean id="htmlMediaType" class="org.springframework.http.MediaType"> <constructor-arg value="text/html" /> </bean>
After looking at the code for the MediaType class however the check token method seems ok:Code:Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.MediaType]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Invalid token character '/' in token "text/html" at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:107) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:273) ... 39 more Caused by: java.lang.IllegalArgumentException: Invalid token character '/' in token "text/html"
The class defines the available seperators as:Code:/** * Checks the given token string for illegal characters, as defined in RFC 2616, section 2.2. * * @throws IllegalArgumentException in case of illegal characters * @see <a href="http://tools.ietf.org/html/rfc2616#section-2.2">HTTP 1.1, section 2.2</a> */ private void checkToken(String s) { for (int i=0; i < s.length(); i++ ) { char ch = s.charAt(i); if (!TOKEN.get(ch)) { throw new IllegalArgumentException("Invalid token character '" + ch + "' in token \"" + s + "\""); } } }
The forward slash seems to be in there so I'm not too sure why this exception is now being thrown?Code:BitSet separators = new BitSet(128); separators.set('('); separators.set(')'); separators.set('<'); separators.set('>'); separators.set('@'); separators.set(','); separators.set(';'); separators.set(':'); separators.set('\\'); separators.set('\"'); separators.set('/'); separators.set('['); separators.set(']'); separators.set('?'); separators.set('='); separators.set('{'); separators.set('}'); separators.set(' '); separators.set('\t');
Any ideas ??
Eggsy


Reply With Quote
