Got it, thanks for the explanation.

Willem

Claus Ibsen wrote:
> On Sat, May 23, 2009 at 4:12 AM, Willem Jiang <willem.ji...@gmail.com> wrote:
>> Hi Claus,
>>
>> I don't know why did you remove the checking codes of 'is' (the instance
>> of InputStream). Do I miss something ?
> Hi
> 
> We have the mandatoryConvertTo method that will throw a exception if
> Camel cannot converter to the given type.
> People should use this method instead of doing their own == null check.
> 
> So I changed from convertTo to the mandatoryConvertTo method.
> And removed the if == null check.
> 
> 
>> Thanks,
>>
>> Willem
>> davscl...@apache.org wrote:
>>> Author: davsclaus
>>> Date: Fri May 22 18:52:13 2009
>>> New Revision: 777655
>>>
>>> URL: http://svn.apache.org/viewvc?rev=777655&view=rev
>>> Log:
>>> polished code
>>>
>>> Modified:
>>>     
>>> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
>>>
>>> Modified: 
>>> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
>>> URL: 
>>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java?rev=777655&r1=777654&r2=777655&view=diff
>>> ==============================================================================
>>> --- 
>>> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
>>>  (original)
>>> +++ 
>>> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GzipDataFormat.java
>>>  Fri May 22 18:52:13 2009
>>> @@ -29,12 +29,8 @@
>>>
>>>  public class GzipDataFormat implements DataFormat {
>>>
>>> -    public void marshal(Exchange exchange, Object graph, OutputStream 
>>> stream)
>>> -        throws Exception {
>>> -        InputStream is = 
>>> exchange.getContext().getTypeConverter().convertTo(InputStream.class, 
>>> graph);
>>> -        if (is == null) {
>>> -            throw new IllegalArgumentException("Cannot get the inputstream 
>>> for GzipDataFormat mashalling");
>>> -        }
>>> +    public void marshal(Exchange exchange, Object graph, OutputStream 
>>> stream) throws Exception {
>>> +        InputStream is = 
>>> exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class,
>>>  graph);
>>>
>>>          GZIPOutputStream zipOutput = new GZIPOutputStream(stream);
>>>          try {
>>> @@ -45,8 +41,7 @@
>>>
>>>      }
>>>
>>> -    public Object unmarshal(Exchange exchange, InputStream stream)
>>> -        throws Exception {
>>> +    public Object unmarshal(Exchange exchange, InputStream stream) throws 
>>> Exception {
>>>          InputStream is = ExchangeHelper.getMandatoryInBody(exchange, 
>>> InputStream.class);
>>>          GZIPInputStream unzipInput = new GZIPInputStream(is);
>>>
>>>
>>>
>>>
>>
> 
> 
> 

Reply via email to