From f4d155780a02a50b2444e192c3e454cdd7c771d5 Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Thu, 31 Aug 2023 13:55:11 +0800 Subject: [PATCH 01/16] add patch --- hessian-202308291450.patch | 95186 +++++++++++++++++++++++++++++++++++ hessian.spec | 11 +- 2 files changed, 95195 insertions(+), 2 deletions(-) create mode 100644 hessian-202308291450.patch diff --git a/hessian-202308291450.patch b/hessian-202308291450.patch new file mode 100644 index 0000000..9cd30bf --- /dev/null +++ b/hessian-202308291450.patch @@ -0,0 +1,95186 @@ +diff -uNr hessian-4.0.65-src/META-INF/MANIFEST.MF hessian-4.0.65-fix/META-INF/MANIFEST.MF +--- hessian-4.0.65-src/META-INF/MANIFEST.MF 2020-07-23 12:54:20.000000000 +0800 ++++ hessian-4.0.65-fix/META-INF/MANIFEST.MF 2023-08-15 18:39:22.000000000 +0800 +@@ -1,4 +1,5 @@ + Manifest-Version: 1.0 +-Ant-Version: Apache Ant 1.10.5 +-Created-By: 1.8.0_252-8u252-b09-1~18.04-b09 (Private Build) ++Implementation-Vendor: Caucho Technology, Inc. ++Implementation-Version: 3.1.0 ++Created-By: 1.7.0_25 (Oracle Corporation) + +diff -uNr hessian-4.0.65-src/META-INF/hessian/deserializers hessian-4.0.65-fix/META-INF/hessian/deserializers +--- hessian-4.0.65-src/META-INF/hessian/deserializers 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/META-INF/hessian/deserializers 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,3 @@ ++java.io.File=com.caucho.hessian.io.FileDeserializer ++java.math.BigDecimal=com.caucho.hessian.io.BigDecimalDeserializer ++javax.management.ObjectName=com.caucho.hessian.io.ObjectNameDeserializer +diff -uNr hessian-4.0.65-src/META-INF/hessian/serializers hessian-4.0.65-fix/META-INF/hessian/serializers +--- hessian-4.0.65-src/META-INF/hessian/serializers 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/META-INF/hessian/serializers 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,6 @@ ++com.caucho.hessian.io.HessianRemoteObject=com.caucho.hessian.io.RemoteSerializer ++com.caucho.burlap.io.BurlapRemoteObject=com.caucho.hessian.io.RemoteSerializer ++java.io.File=com.caucho.hessian.io.StringValueSerializer ++java.math.BigDecimal=com.caucho.hessian.io.StringValueSerializer ++java.util.Locale=com.caucho.hessian.io.LocaleSerializer ++javax.management.ObjectName=com.caucho.hessian.io.StringValueSerializer +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapMetaInfoAPI.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapMetaInfoAPI.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapMetaInfoAPI.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapMetaInfoAPI.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,66 +1,66 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-/** +- * API retrieving burlap meta information. +- */ +-public interface BurlapMetaInfoAPI { +- /** +- * Returns a service attribute. +- * +- * +- */ +- public Object _burlap_getAttribute(String name); +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++/** ++ * API retrieving burlap meta information. ++ */ ++public interface BurlapMetaInfoAPI { ++ /** ++ * Returns a service attribute. ++ * ++ * ++ */ ++ public Object _burlap_getAttribute(String name); ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProtocolException.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProtocolException.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProtocolException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProtocolException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,102 +1,102 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-import java.io.IOException; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroBurlapInput. +- */ +-public class BurlapProtocolException extends IOException { +- private Throwable rootCause; +- +- /** +- * Zero-arg constructor. +- */ +- public BurlapProtocolException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public BurlapProtocolException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public BurlapProtocolException(String message, Throwable rootCause) +- { +- super(message); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Create the exception. +- */ +- public BurlapProtocolException(Throwable rootCause) +- { +- super(String.valueOf(rootCause)); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getRootCause() +- { +- return rootCause; +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++import java.io.IOException; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroBurlapInput. ++ */ ++public class BurlapProtocolException extends IOException { ++ private Throwable rootCause; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public BurlapProtocolException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapProtocolException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapProtocolException(String message, Throwable rootCause) ++ { ++ super(message); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapProtocolException(Throwable rootCause) ++ { ++ super(String.valueOf(rootCause)); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getRootCause() ++ { ++ return rootCause; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxy.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxy.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxy.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxy.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,227 +1,227 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-import com.caucho.burlap.io.AbstractBurlapInput; +-import com.caucho.burlap.io.BurlapOutput; +- +-import java.io.FileNotFoundException; +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.lang.reflect.InvocationHandler; +-import java.lang.reflect.Method; +-import java.lang.reflect.Proxy; +-import java.net.HttpURLConnection; +-import java.net.URL; +-import java.net.URLConnection; +-import java.util.logging.*; +- +-/** +- * Proxy implementation for Burlap clients. Applications will generally +- * use BurlapProxyFactory to create proxy clients. +- */ +-public class BurlapProxy implements InvocationHandler { +- private static final Logger log +- = Logger.getLogger(BurlapProxy.class.getName()); +- +- private BurlapProxyFactory _factory; +- private URL _url; +- +- BurlapProxy(BurlapProxyFactory factory, URL url) +- { +- _factory = factory; +- _url = url; +- } +- +- /** +- * Returns the proxy's URL. +- */ +- public URL getURL() +- { +- return _url; +- } +- +- /** +- * Handles the object invocation. +- * +- * @param proxy the proxy object to invoke +- * @param method the method to call +- * @param args the arguments to the proxy object +- */ +- public Object invoke(Object proxy, Method method, Object []args) +- throws Throwable +- { +- String methodName = method.getName(); +- Class []params = method.getParameterTypes(); +- +- // equals and hashCode are special cased +- if (methodName.equals("equals") && +- params.length == 1 && params[0].equals(Object.class)) { +- Object value = args[0]; +- if (value == null || ! Proxy.isProxyClass(value.getClass())) +- return new Boolean(false); +- +- BurlapProxy handler = (BurlapProxy) Proxy.getInvocationHandler(value); +- +- return new Boolean(_url.equals(handler.getURL())); +- } +- else if (methodName.equals("hashCode") && params.length == 0) +- return new Integer(_url.hashCode()); +- else if (methodName.equals("getBurlapType")) +- return proxy.getClass().getInterfaces()[0].getName(); +- else if (methodName.equals("getBurlapURL")) +- return _url.toString(); +- else if (methodName.equals("toString") && params.length == 0) +- return getClass().getSimpleName() + "[" + _url + "]"; +- +- InputStream is = null; +- +- URLConnection conn = null; +- HttpURLConnection httpConn = null; +- try { +- conn = _factory.openConnection(_url); +- +- httpConn = (HttpURLConnection) conn; +- +- httpConn.setRequestMethod("POST"); +- conn.setRequestProperty("Content-Type", "text/xml"); +- +- OutputStream os; +- +- try { +- os = conn.getOutputStream(); +- } catch (Exception e) { +- throw new BurlapRuntimeException(e); +- } +- +- BurlapOutput out = _factory.getBurlapOutput(os); +- +- if (! _factory.isOverloadEnabled()) { +- } +- else if (args != null) +- methodName = methodName + "__" + args.length; +- else +- methodName = methodName + "__0"; +- +- if (log.isLoggable(Level.FINE)) +- log.fine(this + " calling " + methodName + " (" + method + ")"); +- +- out.call(methodName, args); +- +- try { +- os.flush(); +- } catch (Exception e) { +- throw new BurlapRuntimeException(e); +- } +- +- if (conn instanceof HttpURLConnection) { +- httpConn = (HttpURLConnection) conn; +- int code = 500; +- +- try { +- code = httpConn.getResponseCode(); +- } catch (Exception e) { +- } +- +- if (code != 200) { +- StringBuffer sb = new StringBuffer(); +- int ch; +- +- try { +- is = httpConn.getInputStream(); +- +- if (is != null) { +- while ((ch = is.read()) >= 0) +- sb.append((char) ch); +- +- is.close(); +- } +- +- is = httpConn.getErrorStream(); +- if (is != null) { +- while ((ch = is.read()) >= 0) +- sb.append((char) ch); +- } +- } catch (FileNotFoundException e) { +- throw new BurlapRuntimeException(code + ": " + String.valueOf(e)); +- } catch (IOException e) { +- } +- +- if (is != null) +- is.close(); +- +- throw new BurlapProtocolException(code + ": " + sb.toString()); +- } +- } +- +- is = conn.getInputStream(); +- +- AbstractBurlapInput in = _factory.getBurlapInput(is); +- +- return in.readReply(method.getReturnType()); +- } catch (BurlapProtocolException e) { +- throw new BurlapRuntimeException(e); +- } finally { +- try { +- if (is != null) +- is.close(); +- } catch (IOException e) { +- } +- +- if (httpConn != null) +- httpConn.disconnect(); +- } +- } +- +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _url + "]"; +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++import com.caucho.burlap.io.AbstractBurlapInput; ++import com.caucho.burlap.io.BurlapOutput; ++ ++import java.io.FileNotFoundException; ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.lang.reflect.InvocationHandler; ++import java.lang.reflect.Method; ++import java.lang.reflect.Proxy; ++import java.net.HttpURLConnection; ++import java.net.URL; ++import java.net.URLConnection; ++import java.util.logging.*; ++ ++/** ++ * Proxy implementation for Burlap clients. Applications will generally ++ * use BurlapProxyFactory to create proxy clients. ++ */ ++public class BurlapProxy implements InvocationHandler { ++ private static final Logger log ++ = Logger.getLogger(BurlapProxy.class.getName()); ++ ++ private BurlapProxyFactory _factory; ++ private URL _url; ++ ++ BurlapProxy(BurlapProxyFactory factory, URL url) ++ { ++ _factory = factory; ++ _url = url; ++ } ++ ++ /** ++ * Returns the proxy's URL. ++ */ ++ public URL getURL() ++ { ++ return _url; ++ } ++ ++ /** ++ * Handles the object invocation. ++ * ++ * @param proxy the proxy object to invoke ++ * @param method the method to call ++ * @param args the arguments to the proxy object ++ */ ++ public Object invoke(Object proxy, Method method, Object []args) ++ throws Throwable ++ { ++ String methodName = method.getName(); ++ Class []params = method.getParameterTypes(); ++ ++ // equals and hashCode are special cased ++ if (methodName.equals("equals") && ++ params.length == 1 && params[0].equals(Object.class)) { ++ Object value = args[0]; ++ if (value == null || ! Proxy.isProxyClass(value.getClass())) ++ return new Boolean(false); ++ ++ BurlapProxy handler = (BurlapProxy) Proxy.getInvocationHandler(value); ++ ++ return new Boolean(_url.equals(handler.getURL())); ++ } ++ else if (methodName.equals("hashCode") && params.length == 0) ++ return new Integer(_url.hashCode()); ++ else if (methodName.equals("getBurlapType")) ++ return proxy.getClass().getInterfaces()[0].getName(); ++ else if (methodName.equals("getBurlapURL")) ++ return _url.toString(); ++ else if (methodName.equals("toString") && params.length == 0) ++ return getClass().getSimpleName() + "[" + _url + "]"; ++ ++ InputStream is = null; ++ ++ URLConnection conn = null; ++ HttpURLConnection httpConn = null; ++ try { ++ conn = _factory.openConnection(_url); ++ ++ httpConn = (HttpURLConnection) conn; ++ ++ httpConn.setRequestMethod("POST"); ++ conn.setRequestProperty("Content-Type", "text/xml"); ++ ++ OutputStream os; ++ ++ try { ++ os = conn.getOutputStream(); ++ } catch (Exception e) { ++ throw new BurlapRuntimeException(e); ++ } ++ ++ BurlapOutput out = _factory.getBurlapOutput(os); ++ ++ if (! _factory.isOverloadEnabled()) { ++ } ++ else if (args != null) ++ methodName = methodName + "__" + args.length; ++ else ++ methodName = methodName + "__0"; ++ ++ if (log.isLoggable(Level.FINE)) ++ log.fine(this + " calling " + methodName + " (" + method + ")"); ++ ++ out.call(methodName, args); ++ ++ try { ++ os.flush(); ++ } catch (Exception e) { ++ throw new BurlapRuntimeException(e); ++ } ++ ++ if (conn instanceof HttpURLConnection) { ++ httpConn = (HttpURLConnection) conn; ++ int code = 500; ++ ++ try { ++ code = httpConn.getResponseCode(); ++ } catch (Exception e) { ++ } ++ ++ if (code != 200) { ++ StringBuffer sb = new StringBuffer(); ++ int ch; ++ ++ try { ++ is = httpConn.getInputStream(); ++ ++ if (is != null) { ++ while ((ch = is.read()) >= 0) ++ sb.append((char) ch); ++ ++ is.close(); ++ } ++ ++ is = httpConn.getErrorStream(); ++ if (is != null) { ++ while ((ch = is.read()) >= 0) ++ sb.append((char) ch); ++ } ++ } catch (FileNotFoundException e) { ++ throw new BurlapRuntimeException(code + ": " + String.valueOf(e)); ++ } catch (IOException e) { ++ } ++ ++ if (is != null) ++ is.close(); ++ ++ throw new BurlapProtocolException(code + ": " + sb.toString()); ++ } ++ } ++ ++ is = conn.getInputStream(); ++ ++ AbstractBurlapInput in = _factory.getBurlapInput(is); ++ ++ return in.readReply(method.getReturnType()); ++ } catch (BurlapProtocolException e) { ++ throw new BurlapRuntimeException(e); ++ } finally { ++ try { ++ if (is != null) ++ is.close(); ++ } catch (IOException e) { ++ } ++ ++ if (httpConn != null) ++ httpConn.disconnect(); ++ } ++ } ++ ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _url + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyFactory.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyFactory.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,384 +1,384 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-import com.caucho.burlap.io.AbstractBurlapInput; +-import com.caucho.burlap.io.BurlapInput; +-import com.caucho.burlap.io.BurlapOutput; +-import com.caucho.burlap.io.BurlapRemoteObject; +-import com.caucho.burlap.io.BurlapRemoteResolver; +-import com.caucho.services.client.ServiceProxyFactory; +- +-import javax.naming.Context; +-import javax.naming.Name; +-import javax.naming.NamingException; +-import javax.naming.RefAddr; +-import javax.naming.Reference; +-import javax.naming.spi.ObjectFactory; +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.lang.reflect.Proxy; +-import java.net.HttpURLConnection; +-import java.net.MalformedURLException; +-import java.net.URL; +-import java.net.URLConnection; +-import java.util.Hashtable; +- +-/** +- * Factory for creating Burlap client stubs. The returned stub will +- * call the remote object for all methods. +- * +- *
+- * String url = "http://localhost:8080/ejb/hello";
+- * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+- * 
+- * +- * After creation, the stub can be like a regular Java class. Because +- * it makes remote calls, it can throw more exceptions than a Java class. +- * In particular, it may throw protocol exceptions. +- * +- * The factory can also be configured as a JNDI resource. The factory +- * expects to parameters: "type" and "url", corresponding to the two +- * arguments to create +- * +- * In Resin 3.0, the above example would be configured as: +- *
+- * <reference>
+- *   <name>hessian/hello</name>
+- *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
+- *   <init url="http://localhost:8080/ejb/hello"/>
+- *         type="test.HelloHome"/>
+- * </reference>
+- * 
+- * +- * To get the above resource, use JNDI as follows: +- *
+- * Context ic = new InitialContext();
+- * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/burlap/hello");
+- *
+- * System.out.println("Hello: " + hello.helloWorld());
+- * 
+- * +- *

Authentication

+- * +- *

The proxy can use HTTP basic authentication if the user and the +- * password are set. +- */ +-public class BurlapProxyFactory implements ServiceProxyFactory, ObjectFactory { +- private BurlapRemoteResolver _resolver; +- +- private String _user; +- private String _password; +- private String _basicAuth; +- +- private long _readTimeout; +- private boolean _isOverloadEnabled = false; +- +- /** +- * Creates the new proxy factory. +- */ +- public BurlapProxyFactory() +- { +- _resolver = new BurlapProxyResolver(this); +- } +- +- /** +- * Sets the user. +- */ +- public void setUser(String user) +- { +- _user = user; +- _basicAuth = null; +- } +- +- /** +- * Sets the password. +- */ +- public void setPassword(String password) +- { +- _password = password; +- _basicAuth = null; +- } +- +- /** +- * Returns true if overloaded methods are allowed (using mangling) +- */ +- public boolean isOverloadEnabled() +- { +- return _isOverloadEnabled; +- } +- +- /** +- * set true if overloaded methods are allowed (using mangling) +- */ +- public void setOverloadEnabled(boolean isOverloadEnabled) +- { +- _isOverloadEnabled = isOverloadEnabled; +- } +- +- /** +- * Returns the remote resolver. +- */ +- public BurlapRemoteResolver getRemoteResolver() +- { +- return _resolver; +- } +- +- /** +- * Creates the URL connection. +- */ +- protected URLConnection openConnection(URL url) +- throws IOException +- { +- URLConnection conn = url.openConnection(); +- +- conn.setDoOutput(true); +- +- if (_basicAuth != null) +- conn.setRequestProperty("Authorization", _basicAuth); +- else if (_user != null && _password != null) { +- _basicAuth = "Basic " + base64(_user + ":" + _password); +- conn.setRequestProperty("Authorization", _basicAuth); +- } +- +- return conn; +- } +- +- /** +- * Creates a new proxy with the specified URL. The API class uses +- * the java.api.class value from _hessian_ +- * +- * @param url the URL where the client object is located. +- * +- * @return a proxy to the object with the specified interface. +- */ +- public Object create(String url) +- throws MalformedURLException, ClassNotFoundException +- { +- BurlapMetaInfoAPI metaInfo; +- +- metaInfo = (BurlapMetaInfoAPI) create(BurlapMetaInfoAPI.class, url); +- +- String apiClassName = +- (String) metaInfo._burlap_getAttribute("java.api.class"); +- +- if (apiClassName == null) +- throw new BurlapRuntimeException(url + " has an unknown api."); +- +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- +- Class apiClass = Class.forName(apiClassName, false, loader); +- +- return create(apiClass, url); +- } +- +- /** +- * Creates a new proxy with the specified URL. The returned object +- * is a proxy with the interface specified by api. +- * +- *

+-   * String url = "http://localhost:8080/ejb/hello");
+-   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+-   * 
+- * +- * @param api the interface the proxy class needs to implement +- * @param url the URL where the client object is located. +- * +- * @return a proxy to the object with the specified interface. +- */ +- public Object create(Class api, String urlName) +- throws MalformedURLException +- { +- if (api == null) +- throw new NullPointerException(); +- +- URL url = new URL(urlName); +- +- try { +- // clear old keepalive connections +- HttpURLConnection conn = (HttpURLConnection) url.openConnection(); +- +- conn.setConnectTimeout(10); +- conn.setReadTimeout(10); +- +- conn.setRequestProperty("Connection", "close"); +- +- InputStream is = conn.getInputStream(); +- +- is.close(); +- +- conn.disconnect(); +- } catch (IOException e) { +- } +- +- BurlapProxy handler = new BurlapProxy(this, url); +- +- return Proxy.newProxyInstance(api.getClassLoader(), +- new Class[] { api, +- BurlapRemoteObject.class }, +- handler); +- } +- +- public AbstractBurlapInput getBurlapInput(InputStream is) +- { +- AbstractBurlapInput in = new BurlapInput(is); +- in.setRemoteResolver(getRemoteResolver()); +- +- return in; +- } +- +- public BurlapOutput getBurlapOutput(OutputStream os) +- { +- BurlapOutput out = new BurlapOutput(os); +- +- return out; +- } +- +- /** +- * JNDI object factory so the proxy can be used as a resource. +- */ +- public Object getObjectInstance(Object obj, Name name, +- Context nameCtx, +- Hashtable environment) +- throws Exception +- { +- Reference ref = (Reference) obj; +- +- String api = null; +- String url = null; +- String user = null; +- String password = null; +- +- for (int i = 0; i < ref.size(); i++) { +- RefAddr addr = ref.get(i); +- +- String type = addr.getType(); +- String value = (String) addr.getContent(); +- +- if (type.equals("type")) +- api = value; +- else if (type.equals("url")) +- url = value; +- else if (type.equals("user")) +- setUser(value); +- else if (type.equals("password")) +- setPassword(value); +- } +- +- if (url == null) +- throw new NamingException("`url' must be configured for BurlapProxyFactory."); +- // XXX: could use meta protocol to grab this +- if (api == null) +- throw new NamingException("`type' must be configured for BurlapProxyFactory."); +- +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- Class apiClass = Class.forName(api, false, loader); +- +- return create(apiClass, url); +- } +- +- /** +- * Creates the Base64 value. +- */ +- private String base64(String value) +- { +- StringBuffer cb = new StringBuffer(); +- +- int i = 0; +- for (i = 0; i + 2 < value.length(); i += 3) { +- long chunk = (int) value.charAt(i); +- chunk = (chunk << 8) + (int) value.charAt(i + 1); +- chunk = (chunk << 8) + (int) value.charAt(i + 2); +- +- cb.append(encode(chunk >> 18)); +- cb.append(encode(chunk >> 12)); +- cb.append(encode(chunk >> 6)); +- cb.append(encode(chunk)); +- } +- +- if (i + 1 < value.length()) { +- long chunk = (int) value.charAt(i); +- chunk = (chunk << 8) + (int) value.charAt(i + 1); +- chunk <<= 8; +- +- cb.append(encode(chunk >> 18)); +- cb.append(encode(chunk >> 12)); +- cb.append(encode(chunk >> 6)); +- cb.append('='); +- } +- else if (i < value.length()) { +- long chunk = (int) value.charAt(i); +- chunk <<= 16; +- +- cb.append(encode(chunk >> 18)); +- cb.append(encode(chunk >> 12)); +- cb.append('='); +- cb.append('='); +- } +- +- return cb.toString(); +- } +- +- public static char encode(long d) +- { +- d &= 0x3f; +- if (d < 26) +- return (char) (d + 'A'); +- else if (d < 52) +- return (char) (d + 'a' - 26); +- else if (d < 62) +- return (char) (d + '0' - 52); +- else if (d == 62) +- return '+'; +- else +- return '/'; +- } +-} +- ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++import com.caucho.burlap.io.AbstractBurlapInput; ++import com.caucho.burlap.io.BurlapInput; ++import com.caucho.burlap.io.BurlapOutput; ++import com.caucho.burlap.io.BurlapRemoteObject; ++import com.caucho.burlap.io.BurlapRemoteResolver; ++import com.caucho.services.client.ServiceProxyFactory; ++ ++import javax.naming.Context; ++import javax.naming.Name; ++import javax.naming.NamingException; ++import javax.naming.RefAddr; ++import javax.naming.Reference; ++import javax.naming.spi.ObjectFactory; ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.lang.reflect.Proxy; ++import java.net.HttpURLConnection; ++import java.net.MalformedURLException; ++import java.net.URL; ++import java.net.URLConnection; ++import java.util.Hashtable; ++ ++/** ++ * Factory for creating Burlap client stubs. The returned stub will ++ * call the remote object for all methods. ++ * ++ *
++ * String url = "http://localhost:8080/ejb/hello";
++ * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++ * 
++ * ++ * After creation, the stub can be like a regular Java class. Because ++ * it makes remote calls, it can throw more exceptions than a Java class. ++ * In particular, it may throw protocol exceptions. ++ * ++ * The factory can also be configured as a JNDI resource. The factory ++ * expects to parameters: "type" and "url", corresponding to the two ++ * arguments to create ++ * ++ * In Resin 3.0, the above example would be configured as: ++ *
++ * <reference>
++ *   <name>hessian/hello</name>
++ *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
++ *   <init url="http://localhost:8080/ejb/hello"/>
++ *         type="test.HelloHome"/>
++ * </reference>
++ * 
++ * ++ * To get the above resource, use JNDI as follows: ++ *
++ * Context ic = new InitialContext();
++ * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/burlap/hello");
++ *
++ * System.out.println("Hello: " + hello.helloWorld());
++ * 
++ * ++ *

Authentication

++ * ++ *

The proxy can use HTTP basic authentication if the user and the ++ * password are set. ++ */ ++public class BurlapProxyFactory implements ServiceProxyFactory, ObjectFactory { ++ private BurlapRemoteResolver _resolver; ++ ++ private String _user; ++ private String _password; ++ private String _basicAuth; ++ ++ private long _readTimeout; ++ private boolean _isOverloadEnabled = false; ++ ++ /** ++ * Creates the new proxy factory. ++ */ ++ public BurlapProxyFactory() ++ { ++ _resolver = new BurlapProxyResolver(this); ++ } ++ ++ /** ++ * Sets the user. ++ */ ++ public void setUser(String user) ++ { ++ _user = user; ++ _basicAuth = null; ++ } ++ ++ /** ++ * Sets the password. ++ */ ++ public void setPassword(String password) ++ { ++ _password = password; ++ _basicAuth = null; ++ } ++ ++ /** ++ * Returns true if overloaded methods are allowed (using mangling) ++ */ ++ public boolean isOverloadEnabled() ++ { ++ return _isOverloadEnabled; ++ } ++ ++ /** ++ * set true if overloaded methods are allowed (using mangling) ++ */ ++ public void setOverloadEnabled(boolean isOverloadEnabled) ++ { ++ _isOverloadEnabled = isOverloadEnabled; ++ } ++ ++ /** ++ * Returns the remote resolver. ++ */ ++ public BurlapRemoteResolver getRemoteResolver() ++ { ++ return _resolver; ++ } ++ ++ /** ++ * Creates the URL connection. ++ */ ++ protected URLConnection openConnection(URL url) ++ throws IOException ++ { ++ URLConnection conn = url.openConnection(); ++ ++ conn.setDoOutput(true); ++ ++ if (_basicAuth != null) ++ conn.setRequestProperty("Authorization", _basicAuth); ++ else if (_user != null && _password != null) { ++ _basicAuth = "Basic " + base64(_user + ":" + _password); ++ conn.setRequestProperty("Authorization", _basicAuth); ++ } ++ ++ return conn; ++ } ++ ++ /** ++ * Creates a new proxy with the specified URL. The API class uses ++ * the java.api.class value from _hessian_ ++ * ++ * @param url the URL where the client object is located. ++ * ++ * @return a proxy to the object with the specified interface. ++ */ ++ public Object create(String url) ++ throws MalformedURLException, ClassNotFoundException ++ { ++ BurlapMetaInfoAPI metaInfo; ++ ++ metaInfo = (BurlapMetaInfoAPI) create(BurlapMetaInfoAPI.class, url); ++ ++ String apiClassName = ++ (String) metaInfo._burlap_getAttribute("java.api.class"); ++ ++ if (apiClassName == null) ++ throw new BurlapRuntimeException(url + " has an unknown api."); ++ ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ Class apiClass = Class.forName(apiClassName, false, loader); ++ ++ return create(apiClass, url); ++ } ++ ++ /** ++ * Creates a new proxy with the specified URL. The returned object ++ * is a proxy with the interface specified by api. ++ * ++ *

++   * String url = "http://localhost:8080/ejb/hello");
++   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++   * 
++ * ++ * @param api the interface the proxy class needs to implement ++ * @param url the URL where the client object is located. ++ * ++ * @return a proxy to the object with the specified interface. ++ */ ++ public Object create(Class api, String urlName) ++ throws MalformedURLException ++ { ++ if (api == null) ++ throw new NullPointerException(); ++ ++ URL url = new URL(urlName); ++ ++ try { ++ // clear old keepalive connections ++ HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ++ ++ conn.setConnectTimeout(10); ++ conn.setReadTimeout(10); ++ ++ conn.setRequestProperty("Connection", "close"); ++ ++ InputStream is = conn.getInputStream(); ++ ++ is.close(); ++ ++ conn.disconnect(); ++ } catch (IOException e) { ++ } ++ ++ BurlapProxy handler = new BurlapProxy(this, url); ++ ++ return Proxy.newProxyInstance(api.getClassLoader(), ++ new Class[] { api, ++ BurlapRemoteObject.class }, ++ handler); ++ } ++ ++ public AbstractBurlapInput getBurlapInput(InputStream is) ++ { ++ AbstractBurlapInput in = new BurlapInput(is); ++ in.setRemoteResolver(getRemoteResolver()); ++ ++ return in; ++ } ++ ++ public BurlapOutput getBurlapOutput(OutputStream os) ++ { ++ BurlapOutput out = new BurlapOutput(os); ++ ++ return out; ++ } ++ ++ /** ++ * JNDI object factory so the proxy can be used as a resource. ++ */ ++ public Object getObjectInstance(Object obj, Name name, ++ Context nameCtx, ++ Hashtable environment) ++ throws Exception ++ { ++ Reference ref = (Reference) obj; ++ ++ String api = null; ++ String url = null; ++ String user = null; ++ String password = null; ++ ++ for (int i = 0; i < ref.size(); i++) { ++ RefAddr addr = ref.get(i); ++ ++ String type = addr.getType(); ++ String value = (String) addr.getContent(); ++ ++ if (type.equals("type")) ++ api = value; ++ else if (type.equals("url")) ++ url = value; ++ else if (type.equals("user")) ++ setUser(value); ++ else if (type.equals("password")) ++ setPassword(value); ++ } ++ ++ if (url == null) ++ throw new NamingException("`url' must be configured for BurlapProxyFactory."); ++ // XXX: could use meta protocol to grab this ++ if (api == null) ++ throw new NamingException("`type' must be configured for BurlapProxyFactory."); ++ ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ Class apiClass = Class.forName(api, false, loader); ++ ++ return create(apiClass, url); ++ } ++ ++ /** ++ * Creates the Base64 value. ++ */ ++ private String base64(String value) ++ { ++ StringBuffer cb = new StringBuffer(); ++ ++ int i = 0; ++ for (i = 0; i + 2 < value.length(); i += 3) { ++ long chunk = (int) value.charAt(i); ++ chunk = (chunk << 8) + (int) value.charAt(i + 1); ++ chunk = (chunk << 8) + (int) value.charAt(i + 2); ++ ++ cb.append(encode(chunk >> 18)); ++ cb.append(encode(chunk >> 12)); ++ cb.append(encode(chunk >> 6)); ++ cb.append(encode(chunk)); ++ } ++ ++ if (i + 1 < value.length()) { ++ long chunk = (int) value.charAt(i); ++ chunk = (chunk << 8) + (int) value.charAt(i + 1); ++ chunk <<= 8; ++ ++ cb.append(encode(chunk >> 18)); ++ cb.append(encode(chunk >> 12)); ++ cb.append(encode(chunk >> 6)); ++ cb.append('='); ++ } ++ else if (i < value.length()) { ++ long chunk = (int) value.charAt(i); ++ chunk <<= 16; ++ ++ cb.append(encode(chunk >> 18)); ++ cb.append(encode(chunk >> 12)); ++ cb.append('='); ++ cb.append('='); ++ } ++ ++ return cb.toString(); ++ } ++ ++ public static char encode(long d) ++ { ++ d &= 0x3f; ++ if (d < 26) ++ return (char) (d + 'A'); ++ else if (d < 52) ++ return (char) (d + 'a' - 26); ++ else if (d < 62) ++ return (char) (d + '0' - 52); ++ else if (d == 62) ++ return '+'; ++ else ++ return '/'; ++ } ++} ++ +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyResolver.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyResolver.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyResolver.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyResolver.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,85 +1,85 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-import com.caucho.burlap.io.BurlapRemoteResolver; +- +-import java.io.IOException; +- +-/** +- * Looks up remote objects in the proxy. +- */ +-public class BurlapProxyResolver implements BurlapRemoteResolver { +- private BurlapProxyFactory factory; +- +- /** +- * Creates an uninitialized Burlap remote resolver. +- */ +- public BurlapProxyResolver(BurlapProxyFactory factory) +- { +- this.factory = factory; +- } +- +- /** +- * Looks up a proxy object. +- */ +- public Object lookup(String type, String url) +- throws IOException +- { +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- +- try { +- Class api = Class.forName(type, false, loader); +- +- return factory.create(api, url); +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++import com.caucho.burlap.io.BurlapRemoteResolver; ++ ++import java.io.IOException; ++ ++/** ++ * Looks up remote objects in the proxy. ++ */ ++public class BurlapProxyResolver implements BurlapRemoteResolver { ++ private BurlapProxyFactory factory; ++ ++ /** ++ * Creates an uninitialized Burlap remote resolver. ++ */ ++ public BurlapProxyResolver(BurlapProxyFactory factory) ++ { ++ this.factory = factory; ++ } ++ ++ /** ++ * Looks up a proxy object. ++ */ ++ public Object lookup(String type, String url) ++ throws IOException ++ { ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ try { ++ Class api = Class.forName(type, false, loader); ++ ++ return factory.create(api, url); ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapRemote.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRemote.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapRemote.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRemote.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,130 +1,130 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-/** +- * Encapsulates a remote address when no stub is available, e.g. for +- * Java MicroEdition. +- */ +-public class BurlapRemote { +- private String type; +- private String url; +- +- /** +- * Creates a new Burlap remote object. +- * +- * @param type the remote stub interface +- * @param url the remote url +- */ +- public BurlapRemote(String type, String url) +- { +- this.type = type; +- this.url = url; +- } +- +- /** +- * Creates an uninitialized Burlap remote. +- */ +- public BurlapRemote() +- { +- } +- +- /** +- * Returns the remote api class name. +- */ +- public String getType() +- { +- return type; +- } +- +- /** +- * Returns the remote URL. +- */ +- public String getURL() +- { +- return url; +- } +- +- /** +- * Sets the remote URL. +- */ +- public void setURL(String url) +- { +- this.url = url; +- } +- +- /** +- * Defines the hashcode. +- */ +- public int hashCode() +- { +- return url.hashCode(); +- } +- +- /** +- * Defines equality +- */ +- public boolean equals(Object obj) +- { +- if (! (obj instanceof BurlapRemote)) +- return false; +- +- BurlapRemote remote = (BurlapRemote) obj; +- +- return url.equals(remote.url); +- } +- +- /** +- * Readable version of the remote. +- */ +- public String toString() +- { +- return "[Remote " + url + "]"; +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++/** ++ * Encapsulates a remote address when no stub is available, e.g. for ++ * Java MicroEdition. ++ */ ++public class BurlapRemote { ++ private String type; ++ private String url; ++ ++ /** ++ * Creates a new Burlap remote object. ++ * ++ * @param type the remote stub interface ++ * @param url the remote url ++ */ ++ public BurlapRemote(String type, String url) ++ { ++ this.type = type; ++ this.url = url; ++ } ++ ++ /** ++ * Creates an uninitialized Burlap remote. ++ */ ++ public BurlapRemote() ++ { ++ } ++ ++ /** ++ * Returns the remote api class name. ++ */ ++ public String getType() ++ { ++ return type; ++ } ++ ++ /** ++ * Returns the remote URL. ++ */ ++ public String getURL() ++ { ++ return url; ++ } ++ ++ /** ++ * Sets the remote URL. ++ */ ++ public void setURL(String url) ++ { ++ this.url = url; ++ } ++ ++ /** ++ * Defines the hashcode. ++ */ ++ public int hashCode() ++ { ++ return url.hashCode(); ++ } ++ ++ /** ++ * Defines equality ++ */ ++ public boolean equals(Object obj) ++ { ++ if (! (obj instanceof BurlapRemote)) ++ return false; ++ ++ BurlapRemote remote = (BurlapRemote) obj; ++ ++ return url.equals(remote.url); ++ } ++ ++ /** ++ * Readable version of the remote. ++ */ ++ public String toString() ++ { ++ return "[Remote " + url + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapRuntimeException.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRuntimeException.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapRuntimeException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRuntimeException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,107 +1,107 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-/** +- * Wrapper for protocol exceptions thrown in the proxy. +- */ +-public class BurlapRuntimeException extends RuntimeException { +- private Throwable rootCause; +- +- /** +- * Zero-arg constructor. +- */ +- public BurlapRuntimeException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public BurlapRuntimeException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public BurlapRuntimeException(String message, Throwable rootCause) +- { +- super(message); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Create the exception. +- */ +- public BurlapRuntimeException(Throwable rootCause) +- { +- super(String.valueOf(rootCause)); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getRootCause() +- { +- return this.rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getCause() +- { +- return this.rootCause; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++/** ++ * Wrapper for protocol exceptions thrown in the proxy. ++ */ ++public class BurlapRuntimeException extends RuntimeException { ++ private Throwable rootCause; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public BurlapRuntimeException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapRuntimeException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapRuntimeException(String message, Throwable rootCause) ++ { ++ super(message); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapRuntimeException(Throwable rootCause) ++ { ++ super(String.valueOf(rootCause)); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getRootCause() ++ { ++ return this.rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getCause() ++ { ++ return this.rootCause; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapServiceException.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapServiceException.java +--- hessian-4.0.65-src/com/caucho/burlap/client/BurlapServiceException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapServiceException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,91 +1,91 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroBurlapInput. +- */ +-public class BurlapServiceException extends Exception { +- private String code; +- private Object detail; +- +- /** +- * Zero-arg constructor. +- */ +- public BurlapServiceException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public BurlapServiceException(String message, String code, Object detail) +- { +- super(message); +- this.code = code; +- this.detail = detail; +- } +- +- /** +- * Returns the code. +- */ +- public String getCode() +- { +- return code; +- } +- +- /** +- * Returns the detail. +- */ +- public Object getDetail() +- { +- return detail; +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroBurlapInput. ++ */ ++public class BurlapServiceException extends Exception { ++ private String code; ++ private Object detail; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public BurlapServiceException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapServiceException(String message, String code, Object detail) ++ { ++ super(message); ++ this.code = code; ++ this.detail = detail; ++ } ++ ++ /** ++ * Returns the code. ++ */ ++ public String getCode() ++ { ++ return code; ++ } ++ ++ /** ++ * Returns the detail. ++ */ ++ public Object getDetail() ++ { ++ return detail; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapInput.java hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapInput.java +--- hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,1031 +1,1031 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-import java.io.ByteArrayOutputStream; +-import java.io.IOException; +-import java.io.InputStream; +-import java.util.Calendar; +-import java.util.Date; +-import java.util.Hashtable; +-import java.util.TimeZone; +-import java.util.Vector; +- +-/** +- * Input stream for Burlap requests, compatible with microedition +- * Java. It only uses classes and types available to J2ME. In +- * particular, it does not have any support for the <double> type. +- * +- *

MicroBurlapInput does not depend on any classes other than +- * in J2ME, so it can be extracted independently into a smaller package. +- * +- *

MicroBurlapInput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * InputStream is = ...; // from http connection
+- * MicroBurlapInput in = new MicroBurlapInput(is);
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-public class MicroBurlapInput { +- private static int base64Decode[]; +- +- private InputStream is; +- protected int peek; +- protected boolean peekTag; +- protected Date date; +- protected Calendar utcCalendar; +- private Calendar localCalendar; +- protected Vector refs; +- protected String method; +- protected StringBuffer sbuf = new StringBuffer(); +- protected StringBuffer entity = new StringBuffer(); +- +- /** +- * Creates a new Burlap input stream, initialized with an +- * underlying input stream. +- * +- * @param is the underlying input stream. +- */ +- public MicroBurlapInput(InputStream is) +- { +- init(is); +- } +- +- /** +- * Creates an uninitialized Burlap input stream. +- */ +- public MicroBurlapInput() +- { +- } +- +- /** +- * Returns a call's method. +- */ +- public String getMethod() +- { +- return method; +- } +- +- /** +- * Initialize the Burlap input stream with a new underlying stream. +- * Applications can use init(InputStream) to reuse +- * MicroBurlapInput to save garbage collection. +- */ +- public void init(InputStream is) +- { +- this.is = is; +- this.refs = null; +- } +- +- /** +- * Starts reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * <burlap:call>
+-   * <method>method</method>
+-   * 
+- */ +- public void startCall() +- throws IOException +- { +- expectStartTag("burlap:call"); +- expectStartTag("method"); +- method = parseString(); +- expectEndTag("method"); +- this.refs = null; +- } +- +- /** +- * Completes reading the call. +- * +- *
+-   * </burlap:call>
+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- expectEndTag("burlap:call"); +- } +- +- /** +- * Reads a reply as an object. +- * If the reply has a fault, throws the exception. +- */ +- public Object readReply(Class expectedClass) +- throws Exception +- { +- if (startReply()) { +- Object value = readObject(expectedClass); +- completeReply(); +- return value; +- } +- else { +- Hashtable fault = readFault(); +- +- Object detail = fault.get("detail"); +- if (detail instanceof Exception) +- throw (Exception) detail; +- +- else { +- String code = (String) fault.get("code"); +- String message = (String) fault.get("message"); +- +- throw new BurlapServiceException(message, code, detail); +- } +- } +- } +- +- /** +- * Starts reading the reply. +- * +- *

A successful completion will have a single value. An unsuccessful +- * one will have a fault: +- * +- *

+-   * <burlap:reply>
+-   * 
+- * +- * @return true if success, false for fault. +- */ +- public boolean startReply() +- throws IOException +- { +- this.refs = null; +- +- expectStartTag("burlap:reply"); +- +- if (! parseTag()) +- throw new BurlapProtocolException("expected "); +- +- String tag = sbuf.toString(); +- if (tag.equals("fault")) { +- peekTag = true; +- return false; +- } +- else { +- peekTag = true; +- return true; +- } +- } +- +- /** +- * Completes reading the reply. +- * +- *
+-   * </burlap:reply>
+-   * 
+- */ +- public void completeReply() +- throws IOException +- { +- expectEndTag("burlap:reply"); +- } +- +- /** +- * Reads a boolean value from the input stream. +- */ +- public boolean readBoolean() +- throws IOException +- { +- expectStartTag("boolean"); +- +- int value = parseInt(); +- +- expectEndTag("boolean"); +- +- return value != 0; +- } +- +- /** +- * Reads an integer value from the input stream. +- */ +- public int readInt() +- throws IOException +- { +- expectStartTag("int"); +- +- int value = parseInt(); +- +- expectEndTag("int"); +- +- return value; +- } +- +- /** +- * Reads a long value from the input stream. +- */ +- public long readLong() +- throws IOException +- { +- expectStartTag("long"); +- +- long value = parseLong(); +- +- expectEndTag("long"); +- +- return value; +- } +- +- /** +- * Reads a date value from the input stream. +- */ +- public long readUTCDate() +- throws IOException +- { +- expectStartTag("date"); +- +- if (utcCalendar == null) +- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); +- +- long value = parseDate(utcCalendar); +- +- expectEndTag("date"); +- +- return value; +- } +- +- /** +- * Reads a date value from the input stream. +- */ +- public long readLocalDate() +- throws IOException +- { +- expectStartTag("date"); +- +- if (localCalendar == null) +- localCalendar = Calendar.getInstance(); +- +- long value = parseDate(localCalendar); +- +- expectEndTag("date"); +- +- return value; +- } +- +- /** +- * Reads a remote value from the input stream. +- */ +- public BurlapRemote readRemote() +- throws IOException +- { +- expectStartTag("remote"); +- +- String type = readType(); +- String url = readString(); +- +- expectEndTag("remote"); +- +- return new BurlapRemote(type, url); +- } +- +- /** +- * Reads a string value from the input stream. +- * +- *

The two valid possibilities are either a <null> +- * or a <string>. The string value is encoded in utf-8, and +- * understands the basic XML escapes: "&123;", "<", ">", +- * "'", """. +- * +- *

+-   * <null></null>
+-   * <string>a utf-8 encoded string</string>
+-   * 
+- */ +- public String readString() +- throws IOException +- { +- if (! parseTag()) +- throw new BurlapProtocolException("expected "); +- +- String tag = sbuf.toString(); +- if (tag.equals("null")) { +- expectEndTag("null"); +- return null; +- } +- else if (tag.equals("string")) { +- sbuf.setLength(0); +- parseString(sbuf); +- String value = sbuf.toString(); +- expectEndTag("string"); +- return value; +- } +- else +- throw expectBeginTag("string", tag); +- } +- +- /** +- * Reads a byte array from the input stream. +- * +- *

The two valid possibilities are either a <null> +- * or a <base64>. +- */ +- public byte []readBytes() +- throws IOException +- { +- if (! parseTag()) +- throw new BurlapProtocolException("expected "); +- +- String tag = sbuf.toString(); +- if (tag.equals("null")) { +- expectEndTag("null"); +- return null; +- } +- else if (tag.equals("base64")) { +- sbuf.setLength(0); +- byte []value = parseBytes(); +- expectEndTag("base64"); +- return value; +- } +- else +- throw expectBeginTag("base64", tag); +- } +- +- /** +- * Reads an arbitrary object the input stream. +- */ +- public Object readObject(Class expectedClass) +- throws IOException +- { +- if (! parseTag()) +- throw new BurlapProtocolException("expected "); +- +- String tag = sbuf.toString(); +- if (tag.equals("null")) { +- expectEndTag("null"); +- return null; +- } +- else if (tag.equals("boolean")) { +- int value = parseInt(); +- expectEndTag("boolean"); +- return new Boolean(value != 0); +- } +- else if (tag.equals("int")) { +- int value = parseInt(); +- expectEndTag("int"); +- return new Integer(value); +- } +- else if (tag.equals("long")) { +- long value = parseLong(); +- expectEndTag("long"); +- return new Long(value); +- } +- else if (tag.equals("string")) { +- sbuf.setLength(0); +- parseString(sbuf); +- String value = sbuf.toString(); +- expectEndTag("string"); +- return value; +- } +- else if (tag.equals("xml")) { +- sbuf.setLength(0); +- parseString(sbuf); +- String value = sbuf.toString(); +- expectEndTag("xml"); +- return value; +- } +- else if (tag.equals("date")) { +- if (utcCalendar == null) +- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); +- +- long value = parseDate(utcCalendar); +- expectEndTag("date"); +- return new Date(value); +- } +- else if (tag.equals("map")) { +- String type = readType(); +- +- return readMap(expectedClass, type); +- } +- else if (tag.equals("list")) { +- String type = readType(); +- +- int length = readLength(); +- +- return readList(expectedClass, type, length); +- } +- else if (tag.equals("ref")) { +- int value = parseInt(); +- expectEndTag("ref"); +- +- return refs.elementAt(value); +- } +- else if (tag.equals("remote")) { +- String type = readType(); +- String url = readString(); +- +- expectEndTag("remote"); +- +- return resolveRemote(type, url); +- } +- else +- return readExtensionObject(expectedClass, tag); +- } +- +- /** +- * Reads a type value from the input stream. +- * +- *

+-   * <type>a utf-8 encoded string</type>
+-   * 
+- */ +- public String readType() +- throws IOException +- { +- if (! parseTag()) +- throw new BurlapProtocolException("expected "); +- +- String tag = sbuf.toString(); +- if (! tag.equals("type")) +- throw new BurlapProtocolException("expected "); +- +- sbuf.setLength(0); +- parseString(sbuf); +- String value = sbuf.toString(); +- expectEndTag("type"); +- +- return value; +- } +- +- /** +- * Reads a length value from the input stream. If the length isn't +- * specified, returns -1. +- * +- *
+-   * <length>integer</length>
+-   * 
+- */ +- public int readLength() +- throws IOException +- { +- expectStartTag("length"); +- +- int ch = skipWhitespace(); +- +- peek = ch; +- +- if (ch == '<') { +- expectEndTag("length"); +- return -1; +- } +- +- int value = parseInt(); +- +- expectEndTag("length"); +- +- return value; +- } +- +- /** +- * Resolves a remote object. +- */ +- public Object resolveRemote(String type, String url) +- throws IOException +- { +- return new BurlapRemote(type, url); +- } +- +- /** +- * Reads a fault. +- */ +- public Hashtable readFault() +- throws IOException +- { +- expectStartTag("fault"); +- +- Hashtable map = new Hashtable(); +- +- while (parseTag()) { +- peekTag = true; +- Object key = readObject(null); +- Object value = readObject(null); +- +- if (key != null && value != null) +- map.put(key, value); +- } +- +- if (! sbuf.toString().equals("fault")) +- throw new BurlapProtocolException("expected "); +- +- return map; +- } +- +- /** +- * Reads an object from the input stream. +- * +- * @param expectedClass the calling routine's expected class +- * @param type the type from the stream +- */ +- public Object readMap(Class expectedClass, String type) +- throws IOException +- { +- Hashtable map = new Hashtable(); +- if (refs == null) +- refs = new Vector(); +- refs.addElement(map); +- +- while (parseTag()) { +- peekTag = true; +- Object key = readObject(null); +- Object value = readObject(null); +- +- map.put(key, value); +- } +- if (! sbuf.toString().equals("map")) +- throw new BurlapProtocolException("expected "); +- +- return map; +- } +- +- /** +- * Reads object unknown to MicroBurlapInput. +- */ +- protected Object readExtensionObject(Class expectedClass, String tag) +- throws IOException +- { +- throw new BurlapProtocolException("unknown object tag <" + tag + ">"); +- } +- +- /** +- * Reads a list object from the input stream. +- * +- * @param expectedClass the calling routine's expected class +- * @param type the type from the stream +- * @param length the expected length, -1 for unspecified length +- */ +- public Object readList(Class expectedClass, String type, int length) +- throws IOException +- { +- Vector list = new Vector(); +- if (refs == null) +- refs = new Vector(); +- refs.addElement(list); +- +- while (parseTag()) { +- peekTag = true; +- Object value = readObject(null); +- +- list.addElement(value); +- } +- +- if (! sbuf.toString().equals("list")) +- throw new BurlapProtocolException("expected "); +- +- return list; +- } +- +- /** +- * Parses an integer value from the stream. +- */ +- protected int parseInt() +- throws IOException +- { +- int sign = 1; +- int value = 0; +- +- int ch = skipWhitespace(); +- if (ch == '+') +- ch = read(); +- else if (ch == '-') { +- sign = -1; +- ch = read(); +- } +- +- for (; ch >= '0' && ch <= '9'; ch = read()) +- value = 10 * value + ch - '0'; +- +- peek = ch; +- +- return sign * value; +- } +- +- /** +- * Parses a long value from the stream. +- */ +- protected long parseLong() +- throws IOException +- { +- long sign = 1; +- long value = 0; +- +- int ch = skipWhitespace(); +- if (ch == '+') +- ch = read(); +- else if (ch == '-') { +- sign = -1; +- ch = read(); +- } +- +- for (; ch >= '0' && ch <= '9'; ch = read()) { +- value = 10 * value + ch - '0'; +- } +- +- peek = ch; +- +- return sign * value; +- } +- +- /** +- * Parses a date value from the stream. +- */ +- protected long parseDate(Calendar calendar) +- throws IOException +- { +- int ch = skipWhitespace(); +- +- int year = 0; +- for (int i = 0; i < 4; i++) { +- if (ch >= '0' && ch <= '9') +- year = 10 * year + ch - '0'; +- else +- throw expectedChar("year", ch); +- +- ch = read(); +- } +- +- int month = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- month = 10 * month + ch - '0'; +- else +- throw expectedChar("month", ch); +- +- ch = read(); +- } +- +- int day = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- day = 10 * day + ch - '0'; +- else +- throw expectedChar("day", ch); +- +- ch = read(); +- } +- +- if (ch != 'T') +- throw expectedChar("`T'", ch); +- +- ch = read(); +- +- int hour = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- hour = 10 * hour + ch - '0'; +- else +- throw expectedChar("hour", ch); +- +- ch = read(); +- } +- +- int minute = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- minute = 10 * minute + ch - '0'; +- else +- throw expectedChar("minute", ch); +- +- ch = read(); +- } +- +- int second = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- second = 10 * second + ch - '0'; +- else +- throw expectedChar("second", ch); +- +- ch = read(); +- } +- +- for (; ch > 0 && ch != '<'; ch = read()) { +- } +- +- peek = ch; +- +- calendar.set(Calendar.YEAR, year); +- calendar.set(Calendar.MONTH, month - 1); +- calendar.set(Calendar.DAY_OF_MONTH, day); +- calendar.set(Calendar.HOUR_OF_DAY, hour); +- calendar.set(Calendar.MINUTE, minute); +- calendar.set(Calendar.SECOND, second); +- calendar.set(Calendar.MILLISECOND, 0); +- +- return calendar.getTime().getTime(); +- } +- +- /** +- * Parses a string value from the stream. +- * string buffer is used for the result. +- */ +- protected String parseString() +- throws IOException +- { +- StringBuffer sbuf = new StringBuffer(); +- +- return parseString(sbuf).toString(); +- } +- +- /** +- * Parses a string value from the stream. The burlap object's +- * string buffer is used for the result. +- */ +- protected StringBuffer parseString(StringBuffer sbuf) +- throws IOException +- { +- int ch = read(); +- +- for (; ch >= 0 && ch != '<'; ch = read()) { +- if (ch == '&') { +- ch = read(); +- +- if (ch == '#') { +- ch = read(); +- +- if (ch >= '0' && ch <= '9') { +- int v = 0; +- for (; ch >= '0' && ch <= '9'; ch = read()) { +- v = 10 * v + ch - '0'; +- } +- +- sbuf.append((char) v); +- } +- } +- else { +- StringBuffer entityBuffer = new StringBuffer(); +- +- for (; ch >= 'a' && ch <= 'z'; ch = read()) +- entityBuffer.append((char) ch); +- +- String entity = entityBuffer.toString(); +- if (entity.equals("amp")) +- sbuf.append('&'); +- else if (entity.equals("apos")) +- sbuf.append('\''); +- else if (entity.equals("quot")) +- sbuf.append('"'); +- else if (entity.equals("lt")) +- sbuf.append('<'); +- else if (entity.equals("gt")) +- sbuf.append('>'); +- else +- throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); +- } +- +- if (ch != ';') +- throw expectedChar("';'", ch); +- } +- else if (ch < 0x80) +- sbuf.append((char) ch); +- else if ((ch & 0xe0) == 0xc0) { +- int ch1 = read(); +- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); +- +- sbuf.append((char) v); +- } +- else if ((ch & 0xf0) == 0xe0) { +- int ch1 = read(); +- int ch2 = read(); +- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); +- +- sbuf.append((char) v); +- } +- else +- throw new BurlapProtocolException("bad utf-8 encoding"); +- } +- +- peek = ch; +- +- return sbuf; +- } +- +- /** +- * Parses a byte array. +- */ +- protected byte []parseBytes() +- throws IOException +- { +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- parseBytes(bos); +- +- return bos.toByteArray(); +- } +- +- /** +- * Parses a byte array. +- */ +- protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) +- throws IOException +- { +- int ch; +- for (ch = read(); ch >= 0 && ch != '<'; ch = read()) { +- int b1 = ch; +- int b2 = read(); +- int b3 = read(); +- int b4 = read(); +- +- if (b4 != '=') { +- int chunk = ((base64Decode[b1] << 18) + +- (base64Decode[b2] << 12) + +- (base64Decode[b3] << 6) + +- (base64Decode[b4])); +- +- bos.write(chunk >> 16); +- bos.write(chunk >> 8); +- bos.write(chunk); +- } +- else if (b3 != '=') { +- int chunk = ((base64Decode[b1] << 12) + +- (base64Decode[b2] << 6) + +- (base64Decode[b3])); +- +- bos.write(chunk >> 8); +- bos.write(chunk); +- } +- else { +- int chunk = ((base64Decode[b1] << 6) + +- (base64Decode[b2])); +- +- bos.write(chunk); +- } +- } +- +- if (ch == '<') +- peek = ch; +- +- return bos; +- } +- +- protected void expectStartTag(String tag) +- throws IOException +- { +- if (! parseTag()) +- throw new BurlapProtocolException("expected <" + tag + ">"); +- +- if (! sbuf.toString().equals(tag)) +- throw new BurlapProtocolException("expected <" + tag + "> at <" + sbuf + ">"); +- } +- +- protected void expectEndTag(String tag) +- throws IOException +- { +- if (parseTag()) +- throw new BurlapProtocolException("expected "); +- +- if (! sbuf.toString().equals(tag)) +- throw new BurlapProtocolException("expected at "); +- } +- +- /** +- * Parses a tag. Returns true if it's a start tag. +- */ +- protected boolean parseTag() +- throws IOException +- { +- if (peekTag) { +- peekTag = false; +- return true; +- } +- +- int ch = skipWhitespace(); +- boolean isStartTag = true; +- +- if (ch != '<') +- throw expectedChar("'<'", ch); +- +- ch = read(); +- if (ch == '/') { +- isStartTag = false; +- ch = is.read(); +- } +- +- if (! isTagChar(ch)) +- throw expectedChar("tag", ch); +- +- sbuf.setLength(0); +- for (; isTagChar(ch); ch = read()) +- sbuf.append((char) ch); +- +- if (ch != '>') +- throw expectedChar("'>'", ch); +- +- return isStartTag; +- } +- +- protected IOException expectedChar(String expect, int actualChar) +- { +- return new BurlapProtocolException("expected " + expect + " at " + +- (char) actualChar + "'"); +- } +- +- protected IOException expectBeginTag(String expect, String tag) +- { +- return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); +- } +- +- private boolean isTagChar(int ch) +- { +- return (ch >= 'a' && ch <= 'z' || +- ch >= 'A' && ch <= 'Z' || +- ch >= '0' && ch <= '9' || +- ch == ':' || ch == '-'); +- } +- +- protected int skipWhitespace() +- throws IOException +- { +- int ch = read(); +- +- for (; +- ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; +- ch = read()) { +- } +- +- return ch; +- } +- +- protected boolean isWhitespace(int ch) +- throws IOException +- { +- return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; +- } +- +- protected int read() +- throws IOException +- { +- if (peek > 0) { +- int value = peek; +- peek = 0; +- return value; +- } +- +- return is.read(); +- } +- +- static { +- base64Decode = new int[256]; +- for (int i = 'A'; i <= 'Z'; i++) +- base64Decode[i] = i - 'A'; +- for (int i = 'a'; i <= 'z'; i++) +- base64Decode[i] = i - 'a' + 26; +- for (int i = '0'; i <= '9'; i++) +- base64Decode[i] = i - '0' + 52; +- base64Decode['+'] = 62; +- base64Decode['/'] = 63; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++import java.io.ByteArrayOutputStream; ++import java.io.IOException; ++import java.io.InputStream; ++import java.util.Calendar; ++import java.util.Date; ++import java.util.Hashtable; ++import java.util.TimeZone; ++import java.util.Vector; ++ ++/** ++ * Input stream for Burlap requests, compatible with microedition ++ * Java. It only uses classes and types available to J2ME. In ++ * particular, it does not have any support for the <double> type. ++ * ++ *

MicroBurlapInput does not depend on any classes other than ++ * in J2ME, so it can be extracted independently into a smaller package. ++ * ++ *

MicroBurlapInput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * InputStream is = ...; // from http connection
++ * MicroBurlapInput in = new MicroBurlapInput(is);
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++public class MicroBurlapInput { ++ private static int base64Decode[]; ++ ++ private InputStream is; ++ protected int peek; ++ protected boolean peekTag; ++ protected Date date; ++ protected Calendar utcCalendar; ++ private Calendar localCalendar; ++ protected Vector refs; ++ protected String method; ++ protected StringBuffer sbuf = new StringBuffer(); ++ protected StringBuffer entity = new StringBuffer(); ++ ++ /** ++ * Creates a new Burlap input stream, initialized with an ++ * underlying input stream. ++ * ++ * @param is the underlying input stream. ++ */ ++ public MicroBurlapInput(InputStream is) ++ { ++ init(is); ++ } ++ ++ /** ++ * Creates an uninitialized Burlap input stream. ++ */ ++ public MicroBurlapInput() ++ { ++ } ++ ++ /** ++ * Returns a call's method. ++ */ ++ public String getMethod() ++ { ++ return method; ++ } ++ ++ /** ++ * Initialize the Burlap input stream with a new underlying stream. ++ * Applications can use init(InputStream) to reuse ++ * MicroBurlapInput to save garbage collection. ++ */ ++ public void init(InputStream is) ++ { ++ this.is = is; ++ this.refs = null; ++ } ++ ++ /** ++ * Starts reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * <burlap:call>
++   * <method>method</method>
++   * 
++ */ ++ public void startCall() ++ throws IOException ++ { ++ expectStartTag("burlap:call"); ++ expectStartTag("method"); ++ method = parseString(); ++ expectEndTag("method"); ++ this.refs = null; ++ } ++ ++ /** ++ * Completes reading the call. ++ * ++ *
++   * </burlap:call>
++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ expectEndTag("burlap:call"); ++ } ++ ++ /** ++ * Reads a reply as an object. ++ * If the reply has a fault, throws the exception. ++ */ ++ public Object readReply(Class expectedClass) ++ throws Exception ++ { ++ if (startReply()) { ++ Object value = readObject(expectedClass); ++ completeReply(); ++ return value; ++ } ++ else { ++ Hashtable fault = readFault(); ++ ++ Object detail = fault.get("detail"); ++ if (detail instanceof Exception) ++ throw (Exception) detail; ++ ++ else { ++ String code = (String) fault.get("code"); ++ String message = (String) fault.get("message"); ++ ++ throw new BurlapServiceException(message, code, detail); ++ } ++ } ++ } ++ ++ /** ++ * Starts reading the reply. ++ * ++ *

A successful completion will have a single value. An unsuccessful ++ * one will have a fault: ++ * ++ *

++   * <burlap:reply>
++   * 
++ * ++ * @return true if success, false for fault. ++ */ ++ public boolean startReply() ++ throws IOException ++ { ++ this.refs = null; ++ ++ expectStartTag("burlap:reply"); ++ ++ if (! parseTag()) ++ throw new BurlapProtocolException("expected "); ++ ++ String tag = sbuf.toString(); ++ if (tag.equals("fault")) { ++ peekTag = true; ++ return false; ++ } ++ else { ++ peekTag = true; ++ return true; ++ } ++ } ++ ++ /** ++ * Completes reading the reply. ++ * ++ *
++   * </burlap:reply>
++   * 
++ */ ++ public void completeReply() ++ throws IOException ++ { ++ expectEndTag("burlap:reply"); ++ } ++ ++ /** ++ * Reads a boolean value from the input stream. ++ */ ++ public boolean readBoolean() ++ throws IOException ++ { ++ expectStartTag("boolean"); ++ ++ int value = parseInt(); ++ ++ expectEndTag("boolean"); ++ ++ return value != 0; ++ } ++ ++ /** ++ * Reads an integer value from the input stream. ++ */ ++ public int readInt() ++ throws IOException ++ { ++ expectStartTag("int"); ++ ++ int value = parseInt(); ++ ++ expectEndTag("int"); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a long value from the input stream. ++ */ ++ public long readLong() ++ throws IOException ++ { ++ expectStartTag("long"); ++ ++ long value = parseLong(); ++ ++ expectEndTag("long"); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a date value from the input stream. ++ */ ++ public long readUTCDate() ++ throws IOException ++ { ++ expectStartTag("date"); ++ ++ if (utcCalendar == null) ++ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); ++ ++ long value = parseDate(utcCalendar); ++ ++ expectEndTag("date"); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a date value from the input stream. ++ */ ++ public long readLocalDate() ++ throws IOException ++ { ++ expectStartTag("date"); ++ ++ if (localCalendar == null) ++ localCalendar = Calendar.getInstance(); ++ ++ long value = parseDate(localCalendar); ++ ++ expectEndTag("date"); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a remote value from the input stream. ++ */ ++ public BurlapRemote readRemote() ++ throws IOException ++ { ++ expectStartTag("remote"); ++ ++ String type = readType(); ++ String url = readString(); ++ ++ expectEndTag("remote"); ++ ++ return new BurlapRemote(type, url); ++ } ++ ++ /** ++ * Reads a string value from the input stream. ++ * ++ *

The two valid possibilities are either a <null> ++ * or a <string>. The string value is encoded in utf-8, and ++ * understands the basic XML escapes: "&123;", "<", ">", ++ * "'", """. ++ * ++ *

++   * <null></null>
++   * <string>a utf-8 encoded string</string>
++   * 
++ */ ++ public String readString() ++ throws IOException ++ { ++ if (! parseTag()) ++ throw new BurlapProtocolException("expected "); ++ ++ String tag = sbuf.toString(); ++ if (tag.equals("null")) { ++ expectEndTag("null"); ++ return null; ++ } ++ else if (tag.equals("string")) { ++ sbuf.setLength(0); ++ parseString(sbuf); ++ String value = sbuf.toString(); ++ expectEndTag("string"); ++ return value; ++ } ++ else ++ throw expectBeginTag("string", tag); ++ } ++ ++ /** ++ * Reads a byte array from the input stream. ++ * ++ *

The two valid possibilities are either a <null> ++ * or a <base64>. ++ */ ++ public byte []readBytes() ++ throws IOException ++ { ++ if (! parseTag()) ++ throw new BurlapProtocolException("expected "); ++ ++ String tag = sbuf.toString(); ++ if (tag.equals("null")) { ++ expectEndTag("null"); ++ return null; ++ } ++ else if (tag.equals("base64")) { ++ sbuf.setLength(0); ++ byte []value = parseBytes(); ++ expectEndTag("base64"); ++ return value; ++ } ++ else ++ throw expectBeginTag("base64", tag); ++ } ++ ++ /** ++ * Reads an arbitrary object the input stream. ++ */ ++ public Object readObject(Class expectedClass) ++ throws IOException ++ { ++ if (! parseTag()) ++ throw new BurlapProtocolException("expected "); ++ ++ String tag = sbuf.toString(); ++ if (tag.equals("null")) { ++ expectEndTag("null"); ++ return null; ++ } ++ else if (tag.equals("boolean")) { ++ int value = parseInt(); ++ expectEndTag("boolean"); ++ return new Boolean(value != 0); ++ } ++ else if (tag.equals("int")) { ++ int value = parseInt(); ++ expectEndTag("int"); ++ return new Integer(value); ++ } ++ else if (tag.equals("long")) { ++ long value = parseLong(); ++ expectEndTag("long"); ++ return new Long(value); ++ } ++ else if (tag.equals("string")) { ++ sbuf.setLength(0); ++ parseString(sbuf); ++ String value = sbuf.toString(); ++ expectEndTag("string"); ++ return value; ++ } ++ else if (tag.equals("xml")) { ++ sbuf.setLength(0); ++ parseString(sbuf); ++ String value = sbuf.toString(); ++ expectEndTag("xml"); ++ return value; ++ } ++ else if (tag.equals("date")) { ++ if (utcCalendar == null) ++ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); ++ ++ long value = parseDate(utcCalendar); ++ expectEndTag("date"); ++ return new Date(value); ++ } ++ else if (tag.equals("map")) { ++ String type = readType(); ++ ++ return readMap(expectedClass, type); ++ } ++ else if (tag.equals("list")) { ++ String type = readType(); ++ ++ int length = readLength(); ++ ++ return readList(expectedClass, type, length); ++ } ++ else if (tag.equals("ref")) { ++ int value = parseInt(); ++ expectEndTag("ref"); ++ ++ return refs.elementAt(value); ++ } ++ else if (tag.equals("remote")) { ++ String type = readType(); ++ String url = readString(); ++ ++ expectEndTag("remote"); ++ ++ return resolveRemote(type, url); ++ } ++ else ++ return readExtensionObject(expectedClass, tag); ++ } ++ ++ /** ++ * Reads a type value from the input stream. ++ * ++ *

++   * <type>a utf-8 encoded string</type>
++   * 
++ */ ++ public String readType() ++ throws IOException ++ { ++ if (! parseTag()) ++ throw new BurlapProtocolException("expected "); ++ ++ String tag = sbuf.toString(); ++ if (! tag.equals("type")) ++ throw new BurlapProtocolException("expected "); ++ ++ sbuf.setLength(0); ++ parseString(sbuf); ++ String value = sbuf.toString(); ++ expectEndTag("type"); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a length value from the input stream. If the length isn't ++ * specified, returns -1. ++ * ++ *
++   * <length>integer</length>
++   * 
++ */ ++ public int readLength() ++ throws IOException ++ { ++ expectStartTag("length"); ++ ++ int ch = skipWhitespace(); ++ ++ peek = ch; ++ ++ if (ch == '<') { ++ expectEndTag("length"); ++ return -1; ++ } ++ ++ int value = parseInt(); ++ ++ expectEndTag("length"); ++ ++ return value; ++ } ++ ++ /** ++ * Resolves a remote object. ++ */ ++ public Object resolveRemote(String type, String url) ++ throws IOException ++ { ++ return new BurlapRemote(type, url); ++ } ++ ++ /** ++ * Reads a fault. ++ */ ++ public Hashtable readFault() ++ throws IOException ++ { ++ expectStartTag("fault"); ++ ++ Hashtable map = new Hashtable(); ++ ++ while (parseTag()) { ++ peekTag = true; ++ Object key = readObject(null); ++ Object value = readObject(null); ++ ++ if (key != null && value != null) ++ map.put(key, value); ++ } ++ ++ if (! sbuf.toString().equals("fault")) ++ throw new BurlapProtocolException("expected "); ++ ++ return map; ++ } ++ ++ /** ++ * Reads an object from the input stream. ++ * ++ * @param expectedClass the calling routine's expected class ++ * @param type the type from the stream ++ */ ++ public Object readMap(Class expectedClass, String type) ++ throws IOException ++ { ++ Hashtable map = new Hashtable(); ++ if (refs == null) ++ refs = new Vector(); ++ refs.addElement(map); ++ ++ while (parseTag()) { ++ peekTag = true; ++ Object key = readObject(null); ++ Object value = readObject(null); ++ ++ map.put(key, value); ++ } ++ if (! sbuf.toString().equals("map")) ++ throw new BurlapProtocolException("expected "); ++ ++ return map; ++ } ++ ++ /** ++ * Reads object unknown to MicroBurlapInput. ++ */ ++ protected Object readExtensionObject(Class expectedClass, String tag) ++ throws IOException ++ { ++ throw new BurlapProtocolException("unknown object tag <" + tag + ">"); ++ } ++ ++ /** ++ * Reads a list object from the input stream. ++ * ++ * @param expectedClass the calling routine's expected class ++ * @param type the type from the stream ++ * @param length the expected length, -1 for unspecified length ++ */ ++ public Object readList(Class expectedClass, String type, int length) ++ throws IOException ++ { ++ Vector list = new Vector(); ++ if (refs == null) ++ refs = new Vector(); ++ refs.addElement(list); ++ ++ while (parseTag()) { ++ peekTag = true; ++ Object value = readObject(null); ++ ++ list.addElement(value); ++ } ++ ++ if (! sbuf.toString().equals("list")) ++ throw new BurlapProtocolException("expected "); ++ ++ return list; ++ } ++ ++ /** ++ * Parses an integer value from the stream. ++ */ ++ protected int parseInt() ++ throws IOException ++ { ++ int sign = 1; ++ int value = 0; ++ ++ int ch = skipWhitespace(); ++ if (ch == '+') ++ ch = read(); ++ else if (ch == '-') { ++ sign = -1; ++ ch = read(); ++ } ++ ++ for (; ch >= '0' && ch <= '9'; ch = read()) ++ value = 10 * value + ch - '0'; ++ ++ peek = ch; ++ ++ return sign * value; ++ } ++ ++ /** ++ * Parses a long value from the stream. ++ */ ++ protected long parseLong() ++ throws IOException ++ { ++ long sign = 1; ++ long value = 0; ++ ++ int ch = skipWhitespace(); ++ if (ch == '+') ++ ch = read(); ++ else if (ch == '-') { ++ sign = -1; ++ ch = read(); ++ } ++ ++ for (; ch >= '0' && ch <= '9'; ch = read()) { ++ value = 10 * value + ch - '0'; ++ } ++ ++ peek = ch; ++ ++ return sign * value; ++ } ++ ++ /** ++ * Parses a date value from the stream. ++ */ ++ protected long parseDate(Calendar calendar) ++ throws IOException ++ { ++ int ch = skipWhitespace(); ++ ++ int year = 0; ++ for (int i = 0; i < 4; i++) { ++ if (ch >= '0' && ch <= '9') ++ year = 10 * year + ch - '0'; ++ else ++ throw expectedChar("year", ch); ++ ++ ch = read(); ++ } ++ ++ int month = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ month = 10 * month + ch - '0'; ++ else ++ throw expectedChar("month", ch); ++ ++ ch = read(); ++ } ++ ++ int day = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ day = 10 * day + ch - '0'; ++ else ++ throw expectedChar("day", ch); ++ ++ ch = read(); ++ } ++ ++ if (ch != 'T') ++ throw expectedChar("`T'", ch); ++ ++ ch = read(); ++ ++ int hour = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ hour = 10 * hour + ch - '0'; ++ else ++ throw expectedChar("hour", ch); ++ ++ ch = read(); ++ } ++ ++ int minute = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ minute = 10 * minute + ch - '0'; ++ else ++ throw expectedChar("minute", ch); ++ ++ ch = read(); ++ } ++ ++ int second = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ second = 10 * second + ch - '0'; ++ else ++ throw expectedChar("second", ch); ++ ++ ch = read(); ++ } ++ ++ for (; ch > 0 && ch != '<'; ch = read()) { ++ } ++ ++ peek = ch; ++ ++ calendar.set(Calendar.YEAR, year); ++ calendar.set(Calendar.MONTH, month - 1); ++ calendar.set(Calendar.DAY_OF_MONTH, day); ++ calendar.set(Calendar.HOUR_OF_DAY, hour); ++ calendar.set(Calendar.MINUTE, minute); ++ calendar.set(Calendar.SECOND, second); ++ calendar.set(Calendar.MILLISECOND, 0); ++ ++ return calendar.getTime().getTime(); ++ } ++ ++ /** ++ * Parses a string value from the stream. ++ * string buffer is used for the result. ++ */ ++ protected String parseString() ++ throws IOException ++ { ++ StringBuffer sbuf = new StringBuffer(); ++ ++ return parseString(sbuf).toString(); ++ } ++ ++ /** ++ * Parses a string value from the stream. The burlap object's ++ * string buffer is used for the result. ++ */ ++ protected StringBuffer parseString(StringBuffer sbuf) ++ throws IOException ++ { ++ int ch = read(); ++ ++ for (; ch >= 0 && ch != '<'; ch = read()) { ++ if (ch == '&') { ++ ch = read(); ++ ++ if (ch == '#') { ++ ch = read(); ++ ++ if (ch >= '0' && ch <= '9') { ++ int v = 0; ++ for (; ch >= '0' && ch <= '9'; ch = read()) { ++ v = 10 * v + ch - '0'; ++ } ++ ++ sbuf.append((char) v); ++ } ++ } ++ else { ++ StringBuffer entityBuffer = new StringBuffer(); ++ ++ for (; ch >= 'a' && ch <= 'z'; ch = read()) ++ entityBuffer.append((char) ch); ++ ++ String entity = entityBuffer.toString(); ++ if (entity.equals("amp")) ++ sbuf.append('&'); ++ else if (entity.equals("apos")) ++ sbuf.append('\''); ++ else if (entity.equals("quot")) ++ sbuf.append('"'); ++ else if (entity.equals("lt")) ++ sbuf.append('<'); ++ else if (entity.equals("gt")) ++ sbuf.append('>'); ++ else ++ throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); ++ } ++ ++ if (ch != ';') ++ throw expectedChar("';'", ch); ++ } ++ else if (ch < 0x80) ++ sbuf.append((char) ch); ++ else if ((ch & 0xe0) == 0xc0) { ++ int ch1 = read(); ++ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); ++ ++ sbuf.append((char) v); ++ } ++ else if ((ch & 0xf0) == 0xe0) { ++ int ch1 = read(); ++ int ch2 = read(); ++ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); ++ ++ sbuf.append((char) v); ++ } ++ else ++ throw new BurlapProtocolException("bad utf-8 encoding"); ++ } ++ ++ peek = ch; ++ ++ return sbuf; ++ } ++ ++ /** ++ * Parses a byte array. ++ */ ++ protected byte []parseBytes() ++ throws IOException ++ { ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ parseBytes(bos); ++ ++ return bos.toByteArray(); ++ } ++ ++ /** ++ * Parses a byte array. ++ */ ++ protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) ++ throws IOException ++ { ++ int ch; ++ for (ch = read(); ch >= 0 && ch != '<'; ch = read()) { ++ int b1 = ch; ++ int b2 = read(); ++ int b3 = read(); ++ int b4 = read(); ++ ++ if (b4 != '=') { ++ int chunk = ((base64Decode[b1] << 18) + ++ (base64Decode[b2] << 12) + ++ (base64Decode[b3] << 6) + ++ (base64Decode[b4])); ++ ++ bos.write(chunk >> 16); ++ bos.write(chunk >> 8); ++ bos.write(chunk); ++ } ++ else if (b3 != '=') { ++ int chunk = ((base64Decode[b1] << 12) + ++ (base64Decode[b2] << 6) + ++ (base64Decode[b3])); ++ ++ bos.write(chunk >> 8); ++ bos.write(chunk); ++ } ++ else { ++ int chunk = ((base64Decode[b1] << 6) + ++ (base64Decode[b2])); ++ ++ bos.write(chunk); ++ } ++ } ++ ++ if (ch == '<') ++ peek = ch; ++ ++ return bos; ++ } ++ ++ protected void expectStartTag(String tag) ++ throws IOException ++ { ++ if (! parseTag()) ++ throw new BurlapProtocolException("expected <" + tag + ">"); ++ ++ if (! sbuf.toString().equals(tag)) ++ throw new BurlapProtocolException("expected <" + tag + "> at <" + sbuf + ">"); ++ } ++ ++ protected void expectEndTag(String tag) ++ throws IOException ++ { ++ if (parseTag()) ++ throw new BurlapProtocolException("expected "); ++ ++ if (! sbuf.toString().equals(tag)) ++ throw new BurlapProtocolException("expected at "); ++ } ++ ++ /** ++ * Parses a tag. Returns true if it's a start tag. ++ */ ++ protected boolean parseTag() ++ throws IOException ++ { ++ if (peekTag) { ++ peekTag = false; ++ return true; ++ } ++ ++ int ch = skipWhitespace(); ++ boolean isStartTag = true; ++ ++ if (ch != '<') ++ throw expectedChar("'<'", ch); ++ ++ ch = read(); ++ if (ch == '/') { ++ isStartTag = false; ++ ch = is.read(); ++ } ++ ++ if (! isTagChar(ch)) ++ throw expectedChar("tag", ch); ++ ++ sbuf.setLength(0); ++ for (; isTagChar(ch); ch = read()) ++ sbuf.append((char) ch); ++ ++ if (ch != '>') ++ throw expectedChar("'>'", ch); ++ ++ return isStartTag; ++ } ++ ++ protected IOException expectedChar(String expect, int actualChar) ++ { ++ return new BurlapProtocolException("expected " + expect + " at " + ++ (char) actualChar + "'"); ++ } ++ ++ protected IOException expectBeginTag(String expect, String tag) ++ { ++ return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); ++ } ++ ++ private boolean isTagChar(int ch) ++ { ++ return (ch >= 'a' && ch <= 'z' || ++ ch >= 'A' && ch <= 'Z' || ++ ch >= '0' && ch <= '9' || ++ ch == ':' || ch == '-'); ++ } ++ ++ protected int skipWhitespace() ++ throws IOException ++ { ++ int ch = read(); ++ ++ for (; ++ ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; ++ ch = read()) { ++ } ++ ++ return ch; ++ } ++ ++ protected boolean isWhitespace(int ch) ++ throws IOException ++ { ++ return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; ++ } ++ ++ protected int read() ++ throws IOException ++ { ++ if (peek > 0) { ++ int value = peek; ++ peek = 0; ++ return value; ++ } ++ ++ return is.read(); ++ } ++ ++ static { ++ base64Decode = new int[256]; ++ for (int i = 'A'; i <= 'Z'; i++) ++ base64Decode[i] = i - 'A'; ++ for (int i = 'a'; i <= 'z'; i++) ++ base64Decode[i] = i - 'a' + 26; ++ for (int i = '0'; i <= '9'; i++) ++ base64Decode[i] = i - '0' + 52; ++ base64Decode['+'] = 62; ++ base64Decode['/'] = 63; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapOutput.java hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapOutput.java +--- hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,694 +1,694 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.client; +- +-import java.io.IOException; +-import java.io.OutputStream; +-import java.util.Calendar; +-import java.util.Date; +-import java.util.Enumeration; +-import java.util.Hashtable; +-import java.util.TimeZone; +-import java.util.Vector; +- +-/** +- * Output stream for Burlap requests, compatible with microedition +- * Java. It only uses classes and types available to J2ME. In +- * particular, it does not have any support for the <double> type. +- * +- *

MicroBurlapOutput does not depend on any classes other than +- * in J2ME, so it can be extracted independently into a smaller package. +- * +- *

MicroBurlapOutput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * OutputStream os = ...; // from http connection
+- * MicroBurlapOutput out = new MicroBurlapOutput(os);
+- * String value;
+- *
+- * out.startCall("hello");  // start hello call
+- * out.writeString("arg1"); // write a string argument
+- * out.completeCall();      // complete the call
+- * 
+- */ +-public class MicroBurlapOutput { +- private OutputStream os; +- private Date date; +- private Calendar utcCalendar; +- private Calendar localCalendar; +- +- /** +- * Creates a new Burlap output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public MicroBurlapOutput(OutputStream os) +- { +- init(os); +- } +- +- /** +- * Creates an uninitialized Burlap output stream. +- */ +- public MicroBurlapOutput() +- { +- } +- +- public void init(OutputStream os) +- { +- this.os = os; +- } +- +- /** +- * Writes a complete method call. +- */ +- public void call(String method, Object []args) +- throws IOException +- { +- startCall(method); +- +- if (args != null) { +- for (int i = 0; i < args.length; i++) +- writeObject(args[i]); +- } +- +- completeCall(); +- } +- +- /** +- * Writes the method call: +- * +- *
+-   * <burlap:request>
+-   *   <method>add</method>
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void startCall(String method) +- throws IOException +- { +- print(""); +- print(method); +- print(""); +- } +- +- /** +- * Writes the method call: +- * +- *
+-   * </burlap:request>
+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- print("
"); +- } +- +- /** +- * Writes a boolean value to the stream. The boolean will be written +- * with the following syntax: +- * +- *
+-   * <boolean>1</boolean>
+-   * 
+- * +- * @param value the boolean value to write. +- */ +- public void writeBoolean(boolean value) +- throws IOException +- { +- print(""); +- printInt(value ? 1 : 0); +- print(""); +- } +- +- /** +- * Writes an integer value to the stream. The integer will be written +- * with the following syntax: +- * +- *
+-   * <int>123</int>
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeInt(int value) +- throws IOException +- { +- print(""); +- printInt(value); +- print(""); +- } +- +- /** +- * Writes a long value to the stream. The long will be written +- * with the following syntax: +- * +- *
+-   * <long>123</long>
+-   * 
+- * +- * @param value the long value to write. +- */ +- public void writeLong(long value) +- throws IOException +- { +- print(""); +- printLong(value); +- print(""); +- } +- +- /** +- * Writes a null value to the stream. +- * The null will be written with the following syntax +- * +- *
+-   * <null></null>
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeNull() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * <string>12.3e10</string>
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * <null></null>
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(String value) +- throws IOException +- { +- if (value == null) { +- print(""); +- } +- else { +- print(""); +- printString(value); +- print(""); +- } +- } +- +- /** +- * Writes a byte array to the stream using base64 encoding. +- * The array will be written with the following syntax: +- * +- *
+-   * <base64>dJmO==</base64>
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * <null></null>
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- print(""); +- } +- else { +- print(""); +- printBytes(buffer, offset, length); +- print(""); +- } +- } +- +- /** +- * Writes a date to the stream using ISO8609. +- * +- *
+-   * <date>19980508T095131Z</date>
+-   * 
+- * +- * @param value the date in milliseconds from the epoch in UTC +- */ +- public void writeUTCDate(long time) +- throws IOException +- { +- print(""); +- if (utcCalendar == null) { +- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); +- date = new Date(); +- } +- +- date.setTime(time); +- utcCalendar.setTime(date); +- +- printDate(utcCalendar); +- print(""); +- } +- +- /** +- * Writes a date to the stream using ISO8609. +- * +- *
+-   * <date>19980508T095131Z</date>
+-   * 
+- * +- * @param value the date in milliseconds from the epoch in local timezone +- */ +- public void writeLocalDate(long time) +- throws IOException +- { +- print(""); +- if (localCalendar == null) { +- localCalendar = Calendar.getInstance(); +- date = new Date(); +- } +- +- date.setTime(time); +- localCalendar.setTime(date); +- +- printDate(localCalendar); +- print(""); +- } +- +- /** +- * Writes a reference. +- * +- *
+-   * <ref>123</ref>
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeRef(int value) +- throws IOException +- { +- print(""); +- printInt(value); +- print(""); +- } +- +- /** +- * Writes a generic object. writeObject understands the following types: +- * +- *
    +- *
  • null +- *
  • java.lang.String +- *
  • java.lang.Boolean +- *
  • java.lang.Integer +- *
  • java.lang.Long +- *
  • java.util.Date +- *
  • byte[] +- *
  • java.util.Vector +- *
  • java.util.Hashtable +- *
+- * +- * Unknown objects will call writeCustomObject. +- */ +- public void writeObject(Object object) +- throws IOException +- { +- if (object == null) +- writeNull(); +- else if (object instanceof String) +- writeString((String) object); +- else if (object instanceof Boolean) +- writeBoolean(((Boolean) object).booleanValue()); +- else if (object instanceof Integer) +- writeInt(((Integer) object).intValue()); +- else if (object instanceof Long) +- writeLong(((Long) object).longValue()); +- else if (object instanceof Date) +- writeUTCDate(((Date) object).getTime()); +- else if (object instanceof byte[]) { +- byte []data = (byte []) object; +- writeBytes(data, 0, data.length); +- } +- else if (object instanceof Vector) { +- Vector vector = (Vector) object; +- +- int size = vector.size(); +- writeListBegin(size, null); +- for (int i = 0; i < size; i++) +- writeObject(vector.elementAt(i)); +- +- writeListEnd(); +- } +- else if (object instanceof Hashtable) { +- Hashtable hashtable = (Hashtable) object; +- +- writeMapBegin(null); +- Enumeration e = hashtable.keys(); +- while (e.hasMoreElements()) { +- Object key = e.nextElement(); +- Object value = hashtable.get(key); +- +- writeObject(key); +- writeObject(value); +- } +- writeMapEnd(); +- } +- else +- writeCustomObject(object); +- } +- +- /** +- * Applications which override this can do custom serialization. +- * +- * @param object the object to write. +- */ +- public void writeCustomObject(Object object) +- throws IOException +- { +- throw new IOException("unexpected object: " + object); +- } +- +- /** +- * Writes the list header to the stream. List writers will call +- * writeListBegin followed by the list contents and then +- * call writeListEnd. +- * +- *
+-   * <list>
+-   *   <type>java.util.ArrayList</type>
+-   *   <length>3</length>
+-   *   <int>1</int>
+-   *   <int>2</int>
+-   *   <int>3</int>
+-   * </list>
+-   * 
+- */ +- public void writeListBegin(int length, String type) +- throws IOException +- { +- print(""); +- if (type != null) +- print(type); +- print(""); +- printInt(length); +- print(""); +- } +- +- /** +- * Writes the tail of the list to the stream. +- */ +- public void writeListEnd() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Writes the map header to the stream. Map writers will call +- * writeMapBegin followed by the map contents and then +- * call writeMapEnd. +- * +- *
+-   * <map>
+-   *   <type>java.util.Hashtable</type>
+-   *   <string>a</string;<int>1</int>
+-   *   <string>b</string;<int>2</int>
+-   *   <string>c</string;<int>3</int>
+-   * </map>
+-   * 
+- */ +- public void writeMapBegin(String type) +- throws IOException +- { +- print(""); +- if (type != null) +- print(type); +- print(""); +- } +- +- /** +- * Writes the tail of the map to the stream. +- */ +- public void writeMapEnd() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Writes a remote object reference to the stream. The type is the +- * type of the remote interface. +- * +- *
+-   * <remote>
+-   *   <type>test.account.Account</type>
+-   *   <string>http://caucho.com/foo;ejbid=bar</string>
+-   * </remote>
+-   * 
+- */ +- public void writeRemote(String type, String url) +- throws IOException +- { +- print(""); +- if (type != null) +- print(type); +- print(""); +- print(url); +- print(""); +- } +- +- /** +- * Prints an integer to the stream. +- * +- * @param v the integer to print. +- */ +- public void printInt(int v) +- throws IOException +- { +- print(String.valueOf(v)); +- } +- +- /** +- * Prints a long to the stream. +- * +- * @param v the long to print. +- */ +- public void printLong(long v) +- throws IOException +- { +- print(String.valueOf(v)); +- } +- +- /** +- * Prints a string to the stream, properly encoded. +- * +- * @param v the string to print. +- */ +- public void printString(String v) +- throws IOException +- { +- int len = v.length(); +- +- for (int i = 0; i < len; i++) { +- char ch = v.charAt(i); +- +- switch (ch) { +- case '<': +- print("<"); +- break; +- +- case '&': +- print("&"); +- break; +- +- case '\r': +- print(" "); +- break; +- +- default: +- if (ch < 0x80) +- os.write(ch); +- else if (ch < 0x800) { +- os.write(0xc0 + ((ch >> 6) & 0x1f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- else { +- os.write(0xe0 + ((ch >> 12) & 0xf)); +- os.write(0x80 + ((ch >> 6) & 0x3f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- break; +- } +- } +- } +- +- /** +- * Prints a byte array to the stream, properly encoded in base64. +- * +- * @param data the bytes to print. +- */ +- public void printBytes(byte []data, int offset, int length) +- throws IOException +- { +- int i; +- +- for (; length >= 3; length -= 3) { +- int chunk = (((data[offset] & 0xff) << 16) + +- ((data[offset + 1] & 0xff) << 8) + +- (data[offset + 2] & 0xff)); +- +- os.write(base64encode(chunk >> 18)); +- os.write(base64encode(chunk >> 12)); +- os.write(base64encode(chunk >> 6)); +- os.write(base64encode(chunk)); +- +- offset += 3; +- } +- +- if (length == 2) { +- int chunk = ((data[offset] & 0xff) << 8) + (data[offset + 1] & 0xff); +- +- os.write(base64encode(chunk >> 12)); +- os.write(base64encode(chunk >> 6)); +- os.write(base64encode(chunk)); +- os.write('='); +- } else if (length == 1) { +- int chunk = data[offset] & 0xff; +- os.write(base64encode(chunk >> 6)); +- os.write(base64encode(chunk)); +- os.write('='); +- os.write('='); +- } +- } +- +- /** +- * Converts the digit to its base64 encoding. +- */ +- public static char base64encode(int d) +- { +- d &= 0x3f; +- if (d < 26) +- return (char) (d + 'A'); +- else if (d < 52) +- return (char) (d + 'a' - 26); +- else if (d < 62) +- return (char) (d + '0' - 52); +- else if (d == 62) +- return '+'; +- else +- return '/'; +- } +- +- /** +- * Prints a date. +- * +- * @param date the date to print. +- */ +- public void printDate(Calendar calendar) +- throws IOException +- { +- int year = calendar.get(Calendar.YEAR); +- +- os.write((char) ('0' + (year / 1000 % 10))); +- os.write((char) ('0' + (year / 100 % 10))); +- os.write((char) ('0' + (year / 10 % 10))); +- os.write((char) ('0' + (year % 10))); +- +- int month = calendar.get(Calendar.MONTH) + 1; +- os.write((char) ('0' + (month / 10 % 10))); +- os.write((char) ('0' + (month % 10))); +- +- int day = calendar.get(Calendar.DAY_OF_MONTH); +- os.write((char) ('0' + (day / 10 % 10))); +- os.write((char) ('0' + (day % 10))); +- +- os.write('T'); +- +- int hour = calendar.get(Calendar.HOUR_OF_DAY); +- os.write((char) ('0' + (hour / 10 % 10))); +- os.write((char) ('0' + (hour % 10))); +- +- int minute = calendar.get(Calendar.MINUTE); +- os.write((char) ('0' + (minute / 10 % 10))); +- os.write((char) ('0' + (minute % 10))); +- +- int second = calendar.get(Calendar.SECOND); +- os.write((char) ('0' + (second / 10 % 10))); +- os.write((char) ('0' + (second % 10))); +- +- os.write('Z'); +- } +- +- /** +- * Prints a string as ascii to the stream. Used for tags, etc. +- * that are known to the ascii. +- * +- * @param s the ascii string to print. +- */ +- public void print(String s) +- throws IOException +- { +- int len = s.length(); +- for (int i = 0; i < len; i++) { +- int ch = s.charAt(i); +- +- os.write(ch); +- } +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.client; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++import java.util.Calendar; ++import java.util.Date; ++import java.util.Enumeration; ++import java.util.Hashtable; ++import java.util.TimeZone; ++import java.util.Vector; ++ ++/** ++ * Output stream for Burlap requests, compatible with microedition ++ * Java. It only uses classes and types available to J2ME. In ++ * particular, it does not have any support for the <double> type. ++ * ++ *

MicroBurlapOutput does not depend on any classes other than ++ * in J2ME, so it can be extracted independently into a smaller package. ++ * ++ *

MicroBurlapOutput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * OutputStream os = ...; // from http connection
++ * MicroBurlapOutput out = new MicroBurlapOutput(os);
++ * String value;
++ *
++ * out.startCall("hello");  // start hello call
++ * out.writeString("arg1"); // write a string argument
++ * out.completeCall();      // complete the call
++ * 
++ */ ++public class MicroBurlapOutput { ++ private OutputStream os; ++ private Date date; ++ private Calendar utcCalendar; ++ private Calendar localCalendar; ++ ++ /** ++ * Creates a new Burlap output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public MicroBurlapOutput(OutputStream os) ++ { ++ init(os); ++ } ++ ++ /** ++ * Creates an uninitialized Burlap output stream. ++ */ ++ public MicroBurlapOutput() ++ { ++ } ++ ++ public void init(OutputStream os) ++ { ++ this.os = os; ++ } ++ ++ /** ++ * Writes a complete method call. ++ */ ++ public void call(String method, Object []args) ++ throws IOException ++ { ++ startCall(method); ++ ++ if (args != null) { ++ for (int i = 0; i < args.length; i++) ++ writeObject(args[i]); ++ } ++ ++ completeCall(); ++ } ++ ++ /** ++ * Writes the method call: ++ * ++ *
++   * <burlap:request>
++   *   <method>add</method>
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void startCall(String method) ++ throws IOException ++ { ++ print(""); ++ print(method); ++ print(""); ++ } ++ ++ /** ++ * Writes the method call: ++ * ++ *
++   * </burlap:request>
++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ print("
"); ++ } ++ ++ /** ++ * Writes a boolean value to the stream. The boolean will be written ++ * with the following syntax: ++ * ++ *
++   * <boolean>1</boolean>
++   * 
++ * ++ * @param value the boolean value to write. ++ */ ++ public void writeBoolean(boolean value) ++ throws IOException ++ { ++ print(""); ++ printInt(value ? 1 : 0); ++ print(""); ++ } ++ ++ /** ++ * Writes an integer value to the stream. The integer will be written ++ * with the following syntax: ++ * ++ *
++   * <int>123</int>
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeInt(int value) ++ throws IOException ++ { ++ print(""); ++ printInt(value); ++ print(""); ++ } ++ ++ /** ++ * Writes a long value to the stream. The long will be written ++ * with the following syntax: ++ * ++ *
++   * <long>123</long>
++   * 
++ * ++ * @param value the long value to write. ++ */ ++ public void writeLong(long value) ++ throws IOException ++ { ++ print(""); ++ printLong(value); ++ print(""); ++ } ++ ++ /** ++ * Writes a null value to the stream. ++ * The null will be written with the following syntax ++ * ++ *
++   * <null></null>
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeNull() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * <string>12.3e10</string>
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * <null></null>
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(String value) ++ throws IOException ++ { ++ if (value == null) { ++ print(""); ++ } ++ else { ++ print(""); ++ printString(value); ++ print(""); ++ } ++ } ++ ++ /** ++ * Writes a byte array to the stream using base64 encoding. ++ * The array will be written with the following syntax: ++ * ++ *
++   * <base64>dJmO==</base64>
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * <null></null>
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ print(""); ++ } ++ else { ++ print(""); ++ printBytes(buffer, offset, length); ++ print(""); ++ } ++ } ++ ++ /** ++ * Writes a date to the stream using ISO8609. ++ * ++ *
++   * <date>19980508T095131Z</date>
++   * 
++ * ++ * @param value the date in milliseconds from the epoch in UTC ++ */ ++ public void writeUTCDate(long time) ++ throws IOException ++ { ++ print(""); ++ if (utcCalendar == null) { ++ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); ++ date = new Date(); ++ } ++ ++ date.setTime(time); ++ utcCalendar.setTime(date); ++ ++ printDate(utcCalendar); ++ print(""); ++ } ++ ++ /** ++ * Writes a date to the stream using ISO8609. ++ * ++ *
++   * <date>19980508T095131Z</date>
++   * 
++ * ++ * @param value the date in milliseconds from the epoch in local timezone ++ */ ++ public void writeLocalDate(long time) ++ throws IOException ++ { ++ print(""); ++ if (localCalendar == null) { ++ localCalendar = Calendar.getInstance(); ++ date = new Date(); ++ } ++ ++ date.setTime(time); ++ localCalendar.setTime(date); ++ ++ printDate(localCalendar); ++ print(""); ++ } ++ ++ /** ++ * Writes a reference. ++ * ++ *
++   * <ref>123</ref>
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeRef(int value) ++ throws IOException ++ { ++ print(""); ++ printInt(value); ++ print(""); ++ } ++ ++ /** ++ * Writes a generic object. writeObject understands the following types: ++ * ++ *
    ++ *
  • null ++ *
  • java.lang.String ++ *
  • java.lang.Boolean ++ *
  • java.lang.Integer ++ *
  • java.lang.Long ++ *
  • java.util.Date ++ *
  • byte[] ++ *
  • java.util.Vector ++ *
  • java.util.Hashtable ++ *
++ * ++ * Unknown objects will call writeCustomObject. ++ */ ++ public void writeObject(Object object) ++ throws IOException ++ { ++ if (object == null) ++ writeNull(); ++ else if (object instanceof String) ++ writeString((String) object); ++ else if (object instanceof Boolean) ++ writeBoolean(((Boolean) object).booleanValue()); ++ else if (object instanceof Integer) ++ writeInt(((Integer) object).intValue()); ++ else if (object instanceof Long) ++ writeLong(((Long) object).longValue()); ++ else if (object instanceof Date) ++ writeUTCDate(((Date) object).getTime()); ++ else if (object instanceof byte[]) { ++ byte []data = (byte []) object; ++ writeBytes(data, 0, data.length); ++ } ++ else if (object instanceof Vector) { ++ Vector vector = (Vector) object; ++ ++ int size = vector.size(); ++ writeListBegin(size, null); ++ for (int i = 0; i < size; i++) ++ writeObject(vector.elementAt(i)); ++ ++ writeListEnd(); ++ } ++ else if (object instanceof Hashtable) { ++ Hashtable hashtable = (Hashtable) object; ++ ++ writeMapBegin(null); ++ Enumeration e = hashtable.keys(); ++ while (e.hasMoreElements()) { ++ Object key = e.nextElement(); ++ Object value = hashtable.get(key); ++ ++ writeObject(key); ++ writeObject(value); ++ } ++ writeMapEnd(); ++ } ++ else ++ writeCustomObject(object); ++ } ++ ++ /** ++ * Applications which override this can do custom serialization. ++ * ++ * @param object the object to write. ++ */ ++ public void writeCustomObject(Object object) ++ throws IOException ++ { ++ throw new IOException("unexpected object: " + object); ++ } ++ ++ /** ++ * Writes the list header to the stream. List writers will call ++ * writeListBegin followed by the list contents and then ++ * call writeListEnd. ++ * ++ *
++   * <list>
++   *   <type>java.util.ArrayList</type>
++   *   <length>3</length>
++   *   <int>1</int>
++   *   <int>2</int>
++   *   <int>3</int>
++   * </list>
++   * 
++ */ ++ public void writeListBegin(int length, String type) ++ throws IOException ++ { ++ print(""); ++ if (type != null) ++ print(type); ++ print(""); ++ printInt(length); ++ print(""); ++ } ++ ++ /** ++ * Writes the tail of the list to the stream. ++ */ ++ public void writeListEnd() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Writes the map header to the stream. Map writers will call ++ * writeMapBegin followed by the map contents and then ++ * call writeMapEnd. ++ * ++ *
++   * <map>
++   *   <type>java.util.Hashtable</type>
++   *   <string>a</string;<int>1</int>
++   *   <string>b</string;<int>2</int>
++   *   <string>c</string;<int>3</int>
++   * </map>
++   * 
++ */ ++ public void writeMapBegin(String type) ++ throws IOException ++ { ++ print(""); ++ if (type != null) ++ print(type); ++ print(""); ++ } ++ ++ /** ++ * Writes the tail of the map to the stream. ++ */ ++ public void writeMapEnd() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Writes a remote object reference to the stream. The type is the ++ * type of the remote interface. ++ * ++ *
++   * <remote>
++   *   <type>test.account.Account</type>
++   *   <string>http://caucho.com/foo;ejbid=bar</string>
++   * </remote>
++   * 
++ */ ++ public void writeRemote(String type, String url) ++ throws IOException ++ { ++ print(""); ++ if (type != null) ++ print(type); ++ print(""); ++ print(url); ++ print(""); ++ } ++ ++ /** ++ * Prints an integer to the stream. ++ * ++ * @param v the integer to print. ++ */ ++ public void printInt(int v) ++ throws IOException ++ { ++ print(String.valueOf(v)); ++ } ++ ++ /** ++ * Prints a long to the stream. ++ * ++ * @param v the long to print. ++ */ ++ public void printLong(long v) ++ throws IOException ++ { ++ print(String.valueOf(v)); ++ } ++ ++ /** ++ * Prints a string to the stream, properly encoded. ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v) ++ throws IOException ++ { ++ int len = v.length(); ++ ++ for (int i = 0; i < len; i++) { ++ char ch = v.charAt(i); ++ ++ switch (ch) { ++ case '<': ++ print("<"); ++ break; ++ ++ case '&': ++ print("&"); ++ break; ++ ++ case '\r': ++ print(" "); ++ break; ++ ++ default: ++ if (ch < 0x80) ++ os.write(ch); ++ else if (ch < 0x800) { ++ os.write(0xc0 + ((ch >> 6) & 0x1f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ else { ++ os.write(0xe0 + ((ch >> 12) & 0xf)); ++ os.write(0x80 + ((ch >> 6) & 0x3f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ break; ++ } ++ } ++ } ++ ++ /** ++ * Prints a byte array to the stream, properly encoded in base64. ++ * ++ * @param data the bytes to print. ++ */ ++ public void printBytes(byte []data, int offset, int length) ++ throws IOException ++ { ++ int i; ++ ++ for (; length >= 3; length -= 3) { ++ int chunk = (((data[offset] & 0xff) << 16) + ++ ((data[offset + 1] & 0xff) << 8) + ++ (data[offset + 2] & 0xff)); ++ ++ os.write(base64encode(chunk >> 18)); ++ os.write(base64encode(chunk >> 12)); ++ os.write(base64encode(chunk >> 6)); ++ os.write(base64encode(chunk)); ++ ++ offset += 3; ++ } ++ ++ if (length == 2) { ++ int chunk = ((data[offset] & 0xff) << 8) + (data[offset + 1] & 0xff); ++ ++ os.write(base64encode(chunk >> 12)); ++ os.write(base64encode(chunk >> 6)); ++ os.write(base64encode(chunk)); ++ os.write('='); ++ } else if (length == 1) { ++ int chunk = data[offset] & 0xff; ++ os.write(base64encode(chunk >> 6)); ++ os.write(base64encode(chunk)); ++ os.write('='); ++ os.write('='); ++ } ++ } ++ ++ /** ++ * Converts the digit to its base64 encoding. ++ */ ++ public static char base64encode(int d) ++ { ++ d &= 0x3f; ++ if (d < 26) ++ return (char) (d + 'A'); ++ else if (d < 52) ++ return (char) (d + 'a' - 26); ++ else if (d < 62) ++ return (char) (d + '0' - 52); ++ else if (d == 62) ++ return '+'; ++ else ++ return '/'; ++ } ++ ++ /** ++ * Prints a date. ++ * ++ * @param date the date to print. ++ */ ++ public void printDate(Calendar calendar) ++ throws IOException ++ { ++ int year = calendar.get(Calendar.YEAR); ++ ++ os.write((char) ('0' + (year / 1000 % 10))); ++ os.write((char) ('0' + (year / 100 % 10))); ++ os.write((char) ('0' + (year / 10 % 10))); ++ os.write((char) ('0' + (year % 10))); ++ ++ int month = calendar.get(Calendar.MONTH) + 1; ++ os.write((char) ('0' + (month / 10 % 10))); ++ os.write((char) ('0' + (month % 10))); ++ ++ int day = calendar.get(Calendar.DAY_OF_MONTH); ++ os.write((char) ('0' + (day / 10 % 10))); ++ os.write((char) ('0' + (day % 10))); ++ ++ os.write('T'); ++ ++ int hour = calendar.get(Calendar.HOUR_OF_DAY); ++ os.write((char) ('0' + (hour / 10 % 10))); ++ os.write((char) ('0' + (hour % 10))); ++ ++ int minute = calendar.get(Calendar.MINUTE); ++ os.write((char) ('0' + (minute / 10 % 10))); ++ os.write((char) ('0' + (minute % 10))); ++ ++ int second = calendar.get(Calendar.SECOND); ++ os.write((char) ('0' + (second / 10 % 10))); ++ os.write((char) ('0' + (second % 10))); ++ ++ os.write('Z'); ++ } ++ ++ /** ++ * Prints a string as ascii to the stream. Used for tags, etc. ++ * that are known to the ascii. ++ * ++ * @param s the ascii string to print. ++ */ ++ public void print(String s) ++ throws IOException ++ { ++ int len = s.length(); ++ for (int i = 0; i < len; i++) { ++ int ch = s.charAt(i); ++ ++ os.write(ch); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/package.html hessian-4.0.65-fix/com/caucho/burlap/client/package.html +--- hessian-4.0.65-src/com/caucho/burlap/client/package.html 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/client/package.html 2023-08-15 18:39:22.000000000 +0800 +@@ -1,59 +1,59 @@ +- +- +-Portable client code for using Burlap services. Since this package is +-independent of all Resin code, its classes can be copied to a +-non-Resin client jar. +- +-

RPC Proxy Clients - BurlapProxyFactory

+- +-Most application clients will use BurlapProxyFactory to +-create stub objects. The stub objects can be called with normal +-Java calls. Because the objects are remote, the client application needs +-to be able to deal with IOException caused by an unavailable server or +-a protocol error. +- +-
+-import com.caucho.burlap.client.BurlapProxyFactory;
+-
+-...
+-
+-URL url = new URL("http://localhost:8080/ejb/hello");
+-HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+-
+-System.out.println("hello: " + hello.hello());
+-
+- +-

Serialization

+- +-Since the Burlap protocol serializes Java objects to XML, the +-BurlapSerializerOutput and BurlapSerializerInput +-can be used for serialization. +- +-

Serialization

+-
+-OutputStream os = new FileOutputStream("test.xml");
+-BurlapOutput out = new BurlapSerializerOutput(os);
+-
+-out.writeObject(obj);
+-os.close();
+-
+- +-

Deserialization

+-
+-InputStream is = new FileInputStream("test.xml");
+-BurlapInput in = new BurlapSerializerInput(in);
+-
+-Object obj = in.readObject();
+-
+-is.close();
+-
+- +-

MicroBurlapInput and MicroBurlapOutput

+- +-These two classes only require classes from Java MicroEdition. So they +-can be extracted separately into a burlap-micro.jar. Because of this +-restriction and their small size, these two classes +-are ideal for limited size devices like mobile phones and PDAs. +- +- ++ ++ ++Portable client code for using Burlap services. Since this package is ++independent of all Resin code, its classes can be copied to a ++non-Resin client jar. ++ ++

RPC Proxy Clients - BurlapProxyFactory

++ ++Most application clients will use BurlapProxyFactory to ++create stub objects. The stub objects can be called with normal ++Java calls. Because the objects are remote, the client application needs ++to be able to deal with IOException caused by an unavailable server or ++a protocol error. ++ ++
++import com.caucho.burlap.client.BurlapProxyFactory;
++
++...
++
++URL url = new URL("http://localhost:8080/ejb/hello");
++HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++
++System.out.println("hello: " + hello.hello());
++
++ ++

Serialization

++ ++Since the Burlap protocol serializes Java objects to XML, the ++BurlapSerializerOutput and BurlapSerializerInput ++can be used for serialization. ++ ++

Serialization

++
++OutputStream os = new FileOutputStream("test.xml");
++BurlapOutput out = new BurlapSerializerOutput(os);
++
++out.writeObject(obj);
++os.close();
++
++ ++

Deserialization

++
++InputStream is = new FileInputStream("test.xml");
++BurlapInput in = new BurlapSerializerInput(in);
++
++Object obj = in.readObject();
++
++is.close();
++
++ ++

MicroBurlapInput and MicroBurlapOutput

++ ++These two classes only require classes from Java MicroEdition. So they ++can be extracted separately into a burlap-micro.jar. Because of this ++restriction and their small size, these two classes ++are ideal for limited size devices like mobile phones and PDAs. ++ ++ + +\ No newline at end of file +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapInput.java hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapInput.java +--- hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,69 +1,69 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import com.caucho.hessian.io.AbstractHessianInput; +- +-/** +- * Abstract base class for Burlap requests. Burlap users should only +- * need to use the methods in this class. +- * +- *

Note, this class is just an extension of AbstractHessianInput. +- * +- *

+- * AbstractBurlapInput in = ...; // get input
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-abstract public class AbstractBurlapInput extends AbstractHessianInput { +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++/** ++ * Abstract base class for Burlap requests. Burlap users should only ++ * need to use the methods in this class. ++ * ++ *

Note, this class is just an extension of AbstractHessianInput. ++ * ++ *

++ * AbstractBurlapInput in = ...; // get input
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++abstract public class AbstractBurlapInput extends AbstractHessianInput { ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapOutput.java hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapOutput.java +--- hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,77 +1,77 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import com.caucho.hessian.io.AbstractHessianOutput; +-import java.io.IOException; +- +-/** +- * Abstract output stream for Burlap requests. +- * +- *
+- * OutputStream os = ...; // from http connection
+- * AbstractOutput out = new BurlapSerializerOutput(os);
+- * String value;
+- *
+- * out.startCall("hello");  // start hello call
+- * out.writeString("arg1"); // write a string argument
+- * out.completeCall();      // complete the call
+- * 
+- */ +-abstract public class AbstractBurlapOutput extends AbstractHessianOutput { +- @Override +- public void startCall(String method, int length) +- throws IOException +- { +- startCall(method); +- } +- +- abstract void startCall(String method) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import com.caucho.hessian.io.AbstractHessianOutput; ++import java.io.IOException; ++ ++/** ++ * Abstract output stream for Burlap requests. ++ * ++ *
++ * OutputStream os = ...; // from http connection
++ * AbstractOutput out = new BurlapSerializerOutput(os);
++ * String value;
++ *
++ * out.startCall("hello");  // start hello call
++ * out.writeString("arg1"); // write a string argument
++ * out.completeCall();      // complete the call
++ * 
++ */ ++abstract public class AbstractBurlapOutput extends AbstractHessianOutput { ++ @Override ++ public void startCall(String method, int length) ++ throws IOException ++ { ++ startCall(method); ++ } ++ ++ abstract void startCall(String method) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapResolver.java hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapResolver.java +--- hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapResolver.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapResolver.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,65 +1,65 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import java.io.IOException; +- +-/** +- * Looks up remote objects. The default just returns a BurlapRemote object. +- */ +-public class AbstractBurlapResolver implements BurlapRemoteResolver { +- /** +- * Looks up a proxy object. +- */ +- public Object lookup(String type, String url) +- throws IOException +- { +- return new BurlapRemote(type, url); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import java.io.IOException; ++ ++/** ++ * Looks up remote objects. The default just returns a BurlapRemote object. ++ */ ++public class AbstractBurlapResolver implements BurlapRemoteResolver { ++ /** ++ * Looks up a proxy object. ++ */ ++ public Object lookup(String type, String url) ++ throws IOException ++ { ++ return new BurlapRemote(type, url); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapInput.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapInput.java +--- hessian-4.0.65-src/com/caucho/burlap/io/BurlapInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,1817 +1,1817 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import com.caucho.hessian.io.Deserializer; +-import com.caucho.hessian.io.HessianRemoteResolver; +-import com.caucho.hessian.io.SerializerFactory; +- +-import java.io.ByteArrayOutputStream; +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.Reader; +-import java.lang.reflect.Field; +-import java.util.ArrayList; +-import java.util.Calendar; +-import java.util.Date; +-import java.util.HashMap; +-import java.util.TimeZone; +- +-/** +- * Input stream for Burlap requests. +- * +- *

BurlapInput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * InputStream is = ...; // from http connection
+- * BurlapInput in = new BurlapInput(is);
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-public class BurlapInput extends AbstractBurlapInput { +- private static int []base64Decode; +- +- public final static int TAG_EOF = -1; +- +- public final static int TAG_NULL = 0; +- public final static int TAG_BOOLEAN = 1; +- public final static int TAG_INT = 2; +- public final static int TAG_LONG = 3; +- public final static int TAG_DOUBLE = 4; +- public final static int TAG_DATE = 5; +- public final static int TAG_STRING = 6; +- public final static int TAG_XML = 7; +- public final static int TAG_BASE64 = 8; +- public final static int TAG_MAP = 9; +- public final static int TAG_LIST = 10; +- public final static int TAG_TYPE = 11; +- public final static int TAG_LENGTH = 12; +- +- public final static int TAG_REF = 13; +- public final static int TAG_REMOTE = 14; +- +- public final static int TAG_CALL = 15; +- public final static int TAG_REPLY = 16; +- public final static int TAG_FAULT = 17; +- public final static int TAG_METHOD = 18; +- public final static int TAG_HEADER = 19; +- +- public final static int TAG_NULL_END = TAG_NULL + 100; +- public final static int TAG_BOOLEAN_END = TAG_BOOLEAN + 100; +- public final static int TAG_INT_END = TAG_INT + 100; +- public final static int TAG_LONG_END = TAG_LONG + 100; +- public final static int TAG_DOUBLE_END = TAG_DOUBLE + 100; +- public final static int TAG_DATE_END = TAG_DATE + 100; +- public final static int TAG_STRING_END = TAG_STRING + 100; +- public final static int TAG_XML_END = TAG_XML + 100; +- public final static int TAG_BASE64_END = TAG_BASE64 + 100; +- public final static int TAG_MAP_END = TAG_MAP + 100; +- public final static int TAG_LIST_END = TAG_LIST + 100; +- public final static int TAG_TYPE_END = TAG_TYPE + 100; +- public final static int TAG_LENGTH_END = TAG_LENGTH + 100; +- +- public final static int TAG_REF_END = TAG_REF + 100; +- public final static int TAG_REMOTE_END = TAG_REMOTE + 100; +- +- public final static int TAG_CALL_END = TAG_CALL + 100; +- public final static int TAG_REPLY_END = TAG_REPLY + 100; +- public final static int TAG_FAULT_END = TAG_FAULT + 100; +- public final static int TAG_METHOD_END = TAG_METHOD + 100; +- public final static int TAG_HEADER_END = TAG_HEADER + 100; +- +- private static HashMap _tagMap; +- +- private static Field _detailMessageField; +- +- protected SerializerFactory _serializerFactory; +- +- protected ArrayList _refs; +- +- // the underlying input stream +- private InputStream _is; +- // a peek character +- protected int _peek = -1; +- +- // the method for a call +- private String _method; +- +- private int _peekTag; +- +- private Throwable _replyFault; +- +- protected StringBuffer _sbuf = new StringBuffer(); +- protected StringBuffer _entityBuffer = new StringBuffer(); +- +- protected Calendar _utcCalendar; +- protected Calendar _localCalendar; +- +- /** +- * Creates an uninitialized Burlap input stream. +- */ +- public BurlapInput() +- { +- } +- +- /** +- * Creates a new Burlap input stream, initialized with an +- * underlying input stream. +- * +- * @param is the underlying input stream. +- */ +- public BurlapInput(InputStream is) +- { +- init(is); +- } +- +- /** +- * Sets the serializer factory. +- */ +- public void setSerializerFactory(SerializerFactory factory) +- { +- _serializerFactory = factory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- public SerializerFactory getSerializerFactory() +- { +- return _serializerFactory; +- } +- +- /** +- * Initialize the burlap stream with the underlying input stream. +- */ +- public void init(InputStream is) +- { +- _is = is; +- _method = null; +- _peek = -1; +- _peekTag = -1; +- _refs = null; +- _replyFault = null; +- +- if (_serializerFactory == null) +- _serializerFactory = new SerializerFactory(); +- } +- +- /** +- * Returns the calls method +- */ +- public String getMethod() +- { +- return _method; +- } +- +- /** +- * Returns any reply fault. +- */ +- public Throwable getReplyFault() +- { +- return _replyFault; +- } +- +- /** +- * Starts reading the call +- * +- *
+-   * <burlap:call>
+-   * <method>method</method>
+-   * 
+- */ +- public void startCall() +- throws IOException +- { +- readCall(); +- +- while ((readHeader() != null)) +- readObject(); +- +- readMethod(); +- } +- +- /** +- * Starts reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * <burlap:call>
+-   * 
+- */ +- public int readCall() +- throws IOException +- { +- expectTag(TAG_CALL); +- +- int major = 1; +- int minor = 0; +- +- return (major << 16) + minor; +- } +- +- /** +- * Reads the method +- * +- *
+-   * <method>method</method>
+-   * 
+- */ +- public String readMethod() +- throws IOException +- { +- expectTag(TAG_METHOD); +- +- _method = parseString(); +- +- expectTag(TAG_METHOD_END); +- +- return _method; +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * </burlap:call>
+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- expectTag(TAG_CALL_END); +- } +- +- /** +- * Reads a reply as an object. +- * If the reply has a fault, throws the exception. +- */ +- public Object readReply(Class expectedClass) +- throws Throwable +- { +- expectTag(TAG_REPLY); +- +- int tag = parseTag(); +- +- if (tag == TAG_FAULT) +- throw prepareFault(); +- else { +- _peekTag = tag; +- Object value = readObject(expectedClass); +- +- expectTag(TAG_REPLY_END); +- +- return value; +- } +- } +- +- /** +- * Starts reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * <burlap:reply>
+-   * <value>
+-   * 
+- */ +- public void startReply() +- throws Throwable +- { +- expectTag(TAG_REPLY); +- +- int tag = parseTag(); +- if (tag == TAG_FAULT) +- throw prepareFault(); +- else +- _peekTag = tag; +- } +- +- /** +- * Prepares the fault. +- */ +- private Throwable prepareFault() +- throws IOException +- { +- HashMap fault = readFault(); +- +- Object detail = fault.get("detail"); +- String message = (String) fault.get("message"); +- +- if (detail instanceof Throwable) { +- _replyFault = (Throwable) detail; +- +- Field detailMessageField = getDetailMessageField(); +- +- if (message != null && detailMessageField != null) { +- try { +- detailMessageField.set(_replyFault, message); +- } catch (Throwable e) { +- } +- } +- +- return _replyFault; +- } +- +- else { +- String code = (String) fault.get("code"); +- +- _replyFault = new BurlapServiceException(message, code, detail); +- +- return _replyFault; +- } +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * </burlap:reply>
+-   * 
+- */ +- public void completeReply() +- throws IOException +- { +- expectTag(TAG_REPLY_END); +- } +- +- /** +- * Reads a header, returning null if there are no headers. +- * +- *
+-   * <header>value</header>
+-   * 
+- */ +- public String readHeader() +- throws IOException +- { +- int tag = parseTag(); +- +- if (tag == TAG_HEADER) { +- _sbuf.setLength(0); +- String value = parseString(_sbuf).toString(); +- expectTag(TAG_HEADER_END); +- return value; +- } +- +- _peekTag = tag; +- +- return null; +- } +- +- /** +- * Reads a null +- * +- *
+-   * <null></null>
+-   * 
+- */ +- public void readNull() +- throws IOException +- { +- int tag = parseTag(); +- +- switch (tag) { +- case TAG_NULL: +- expectTag(TAG_NULL_END); +- return; +- +- default: +- throw expectedTag("null", tag); +- } +- } +- +- /** +- * Reads a boolean +- * +- *
+-   * <boolean>0</boolean>
+-   * <boolean>1</boolean>
+-   * 
+- */ +- public boolean readBoolean() +- throws IOException +- { +- int tag = parseTag(); +- +- boolean value; +- +- switch (tag) { +- case TAG_NULL: +- value = false; +- expectTag(TAG_NULL_END); +- return value; +- +- case TAG_BOOLEAN: +- value = parseInt() != 0; +- expectTag(TAG_BOOLEAN_END); +- return value; +- +- case TAG_INT: +- value = parseInt() != 0; +- expectTag(TAG_INT_END); +- return value; +- +- case TAG_LONG: +- value = parseLong() != 0; +- expectTag(TAG_LONG_END); +- return value; +- +- case TAG_DOUBLE: +- value = parseDouble() != 0; +- expectTag(TAG_DOUBLE_END); +- return value; +- +- default: +- throw expectedTag("boolean", tag); +- } +- } +- +- /** +- * Reads a byte +- * +- *
+-   * <int>value</int>
+-   * 
+- */ +- public byte readByte() +- throws IOException +- { +- return (byte) readInt(); +- } +- +- /** +- * Reads a short +- * +- *
+-   * <int>value</int>
+-   * 
+- */ +- public short readShort() +- throws IOException +- { +- return (short) readInt(); +- } +- +- /** +- * Reads an integer +- * +- *
+-   * <int>value</int>
+-   * 
+- */ +- public int readInt() +- throws IOException +- { +- int tag = parseTag(); +- +- int value; +- +- switch (tag) { +- case TAG_NULL: +- value = 0; +- expectTag(TAG_NULL_END); +- return value; +- +- case TAG_BOOLEAN: +- value = parseInt(); +- expectTag(TAG_BOOLEAN_END); +- return value; +- +- case TAG_INT: +- value = parseInt(); +- expectTag(TAG_INT_END); +- return value; +- +- case TAG_LONG: +- value = (int) parseLong(); +- expectTag(TAG_LONG_END); +- return value; +- +- case TAG_DOUBLE: +- value = (int) parseDouble(); +- expectTag(TAG_DOUBLE_END); +- return value; +- +- default: +- throw expectedTag("int", tag); +- } +- } +- +- /** +- * Reads a long +- * +- *
+-   * <long>value</long>
+-   * 
+- */ +- public long readLong() +- throws IOException +- { +- int tag = parseTag(); +- +- long value; +- +- switch (tag) { +- case TAG_NULL: +- value = 0; +- expectTag(TAG_NULL_END); +- return value; +- +- case TAG_BOOLEAN: +- value = parseInt(); +- expectTag(TAG_BOOLEAN_END); +- return value; +- +- case TAG_INT: +- value = parseInt(); +- expectTag(TAG_INT_END); +- return value; +- +- case TAG_LONG: +- value = parseLong(); +- expectTag(TAG_LONG_END); +- return value; +- +- case TAG_DOUBLE: +- value = (long) parseDouble(); +- expectTag(TAG_DOUBLE_END); +- return value; +- +- default: +- throw expectedTag("long", tag); +- } +- } +- +- /** +- * Reads a float +- * +- *
+-   * <double>value</double>
+-   * 
+- */ +- public float readFloat() +- throws IOException +- { +- return (float) readDouble(); +- } +- +- /** +- * Reads a double +- * +- *
+-   * <double>value</double>
+-   * 
+- */ +- public double readDouble() +- throws IOException +- { +- int tag = parseTag(); +- +- double value; +- +- switch (tag) { +- case TAG_NULL: +- value = 0; +- expectTag(TAG_NULL_END); +- return value; +- +- case TAG_BOOLEAN: +- value = parseInt(); +- expectTag(TAG_BOOLEAN_END); +- return value; +- +- case TAG_INT: +- value = parseInt(); +- expectTag(TAG_INT_END); +- return value; +- +- case TAG_LONG: +- value = parseLong(); +- expectTag(TAG_LONG_END); +- return value; +- +- case TAG_DOUBLE: +- value = parseDouble(); +- expectTag(TAG_DOUBLE_END); +- return value; +- +- default: +- throw expectedTag("double", tag); +- } +- } +- +- /** +- * Reads a date. +- * +- *
+-   * <date>ISO-8609 date</date>
+-   * 
+- */ +- public long readUTCDate() +- throws IOException +- { +- int tag = parseTag(); +- +- if (tag != TAG_DATE) +- throw error("expected date"); +- +- if (_utcCalendar == null) +- _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); +- +- long value = parseDate(_utcCalendar); +- +- expectTag(TAG_DATE_END); +- +- return value; +- } +- +- /** +- * Reads a date. +- * +- *
+-   * <date>ISO-8609 date</date>
+-   * 
+- */ +- public long readLocalDate() +- throws IOException +- { +- int tag = parseTag(); +- +- if (tag != TAG_DATE) +- throw error("expected date"); +- +- if (_localCalendar == null) +- _localCalendar = Calendar.getInstance(); +- +- long value = parseDate(_localCalendar); +- +- expectTag(TAG_DATE_END); +- +- return value; +- } +- +- /** +- * Reads a string +- * +- *
+-   * <string>value</string>
+-   * 
+- */ +- public String readString() +- throws IOException +- { +- int tag = parseTag(); +- +- String value; +- +- switch (tag) { +- case TAG_NULL: +- expectTag(TAG_NULL_END); +- return null; +- +- case TAG_STRING: +- _sbuf.setLength(0); +- value = parseString(_sbuf).toString(); +- expectTag(TAG_STRING_END); +- return value; +- +- case TAG_XML: +- _sbuf.setLength(0); +- value = parseString(_sbuf).toString(); +- expectTag(TAG_XML_END); +- return value; +- +- default: +- throw expectedTag("string", tag); +- } +- } +- +- /** +- * Reads an XML node. +- * +- *
+-   * &xml;xml string</xml>
+-   * 
+- */ +- public org.w3c.dom.Node readNode() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'S': +- case 's': +- case 'X': +- case 'x': +- throw error("can't cope"); +- +- default: +- throw expectedTag("string", tag); +- } +- } +- +- /** +- * Reads a byte array +- * +- *
+-   * <base64>...</base64>
+-   * 
+- */ +- public byte []readBytes() +- throws IOException +- { +- int tag = parseTag(); +- +- switch (tag) { +- case TAG_NULL: +- expectTag(TAG_NULL_END); +- return null; +- +- case TAG_BASE64: +- byte []data = parseBytes(); +- expectTag(TAG_BASE64_END); +- +- return data; +- +- default: +- throw expectedTag("bytes", tag); +- } +- } +- +- /** +- * Reads a length +- * +- *
+-   * <length>value</length>
+-   * 
+- */ +- public int readLength() +- throws IOException +- { +- int tag = parseTag(); +- +- if (tag != TAG_LENGTH) { +- _peekTag = tag; +- return -1; +- } +- +- int value = parseInt(); +- +- expectTag(TAG_LENGTH_END); +- +- return value; +- } +- +- /** +- * Reads a fault. +- */ +- private HashMap readFault() +- throws IOException +- { +- HashMap map = new HashMap(); +- +- int code = parseTag(); +- for (; code >= 0 && code != TAG_FAULT_END; code = parseTag()) { +- _peekTag = code; +- +- Object key = readObject(); +- Object value = readObject(); +- +- if (key != null && value != null) +- map.put(key, value); +- } +- +- if (code != TAG_FAULT_END) +- throw expectedTag("fault", code); +- +- return map; +- } +- +- /** +- * Reads an object from the input stream with an expected type. +- */ +- public Object readObject(Class cl) +- throws IOException +- { +- if (cl == null || cl.equals(Object.class)) +- return readObject(); +- +- int tag = parseTag(); +- +- switch (tag) { +- case TAG_NULL: +- expectTag(TAG_NULL_END); +- return null; +- +- case TAG_MAP: +- { +- String type = readType(); +- Deserializer reader; +- +- reader = _serializerFactory.getObjectDeserializer(type, cl); +- +- return reader.readMap(this); +- } +- +- case TAG_LIST: +- { +- String type = readType(); +- int length = readLength(); +- +- Deserializer reader; +- reader = _serializerFactory.getObjectDeserializer(type, cl); +- +- return reader.readList(this, length); +- } +- +- case TAG_REF: +- { +- int ref = parseInt(); +- +- expectTag(TAG_REF_END); +- +- return _refs.get(ref); +- } +- +- case TAG_REMOTE: +- { +- String type = readType(); +- String url = readString(); +- +- expectTag(TAG_REMOTE_END); +- +- Object remote = resolveRemote(type, url); +- +- return remote; +- } +- } +- +- _peekTag = tag; +- +- Object value = _serializerFactory.getDeserializer(cl).readObject(this); +- +- return value; +- } +- +- /** +- * Reads an arbitrary object from the input stream when the type +- * is unknown. +- */ +- public Object readObject() +- throws IOException +- { +- int tag = parseTag(); +- +- switch (tag) { +- case TAG_NULL: +- expectTag(TAG_NULL_END); +- return null; +- +- case TAG_BOOLEAN: +- { +- int value = parseInt(); +- expectTag(TAG_BOOLEAN_END); +- return new Boolean(value != 0); +- } +- +- case TAG_INT: +- { +- int value = parseInt(); +- expectTag(TAG_INT_END); +- return new Integer(value); +- } +- +- case TAG_LONG: +- { +- long value = parseLong(); +- expectTag(TAG_LONG_END); +- return new Long(value); +- } +- +- case TAG_DOUBLE: +- { +- double value = parseDouble(); +- expectTag(TAG_DOUBLE_END); +- return new Double(value); +- } +- +- case TAG_DATE: +- { +- long value = parseDate(); +- expectTag(TAG_DATE_END); +- return new Date(value); +- } +- +- case TAG_XML: +- { +- return parseXML(); +- } +- +- case TAG_STRING: +- { +- _sbuf.setLength(0); +- +- String value = parseString(_sbuf).toString(); +- +- expectTag(TAG_STRING_END); +- +- return value; +- } +- +- case TAG_BASE64: +- { +- byte []data = parseBytes(); +- +- expectTag(TAG_BASE64_END); +- +- return data; +- } +- +- case TAG_LIST: +- { +- String type = readType(); +- int length = readLength(); +- +- return _serializerFactory.readList(this, length, type); +- } +- +- case TAG_MAP: +- { +- String type = readType(); +- Deserializer deserializer; +- deserializer = _serializerFactory.getObjectDeserializer(type); +- +- return deserializer.readMap(this); +- } +- +- case TAG_REF: +- { +- int ref = parseInt(); +- +- expectTag(TAG_REF_END); +- +- return _refs.get(ref); +- } +- +- case TAG_REMOTE: +- { +- String type = readType(); +- String url = readString(); +- +- expectTag(TAG_REMOTE_END); +- +- return resolveRemote(type, url); +- } +- +- default: +- throw error("unknown code:" + tagName(tag)); +- } +- } +- +- /** +- * Reads a remote object. +- */ +- public Object readRemote() +- throws IOException +- { +- String type = readType(); +- String url = readString(); +- +- return resolveRemote(type, url); +- } +- +- /** +- * Reads a reference. +- */ +- public Object readRef() +- throws IOException +- { +- return _refs.get(parseInt()); +- } +- +- /** +- * Reads the start of a list. +- */ +- public int readListStart() +- throws IOException +- { +- return parseTag(); +- } +- +- /** +- * Reads the start of a map. +- */ +- public int readMapStart() +- throws IOException +- { +- return parseTag(); +- } +- +- /** +- * Returns true if this is the end of a list or a map. +- */ +- public boolean isEnd() +- throws IOException +- { +- int code = parseTag(); +- +- _peekTag = code; +- +- return (code < 0 || code >= 100); +- } +- +- /** +- * Reads the end byte. +- */ +- public void readEnd() +- throws IOException +- { +- int code = parseTag(); +- +- if (code < 100) +- throw error("unknown code:" + (char) code); +- } +- +- /** +- * Reads the end of the map +- */ +- public void readMapEnd() +- throws IOException +- { +- expectTag(TAG_MAP_END); +- } +- +- /** +- * Reads the end of the map +- */ +- public void readListEnd() +- throws IOException +- { +- expectTag(TAG_LIST_END); +- } +- +- /** +- * Adds a list/map reference. +- */ +- public int addRef(Object ref) +- { +- if (_refs == null) +- _refs = new ArrayList(); +- +- _refs.add(ref); +- +- return _refs.size() - 1; +- } +- +- /** +- * Adds a list/map reference. +- */ +- public void setRef(int i, Object ref) +- { +- _refs.set(i, ref); +- } +- +- /** +- * Resolves a remote object. +- */ +- public Object resolveRemote(String type, String url) +- throws IOException +- { +- HessianRemoteResolver resolver = getRemoteResolver(); +- +- if (resolver != null) +- return resolver.lookup(type, url); +- else +- return new BurlapRemote(type, url); +- } +- +- /** +- * Parses a type from the stream. +- * +- *
+-   * <type>type</type>
+-   * 
+- */ +- public String readType() +- throws IOException +- { +- int code = parseTag(); +- +- if (code != TAG_TYPE) { +- _peekTag = code; +- return ""; +- } +- +- _sbuf.setLength(0); +- int ch; +- while ((ch = readChar()) >= 0) +- _sbuf.append((char) ch); +- String type = _sbuf.toString(); +- +- expectTag(TAG_TYPE_END); +- +- return type; +- } +- +- /** +- * Parses a 32-bit integer value from the stream. +- */ +- private int parseInt() +- throws IOException +- { +- int sign = 1; +- +- int ch = read(); +- if (ch == '-') { +- sign = -1; +- ch = read(); +- } +- +- int value = 0; +- for (; ch >= '0' && ch <= '9'; ch = read()) +- value = 10 * value + ch - '0'; +- +- _peek = ch; +- +- return sign * value; +- } +- +- /** +- * Parses a 64-bit long value from the stream. +- */ +- private long parseLong() +- throws IOException +- { +- int sign = 1; +- +- int ch = read(); +- if (ch == '-') { +- sign = -1; +- ch = read(); +- } +- +- long value = 0; +- for (; ch >= '0' && ch <= '9'; ch = read()) +- value = 10 * value + ch - '0'; +- +- _peek = ch; +- +- return sign * value; +- } +- +- /** +- * Parses a 64-bit double value from the stream. +- * +- *
+-   * b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- private double parseDouble() +- throws IOException +- { +- int ch = skipWhitespace(); +- +- _sbuf.setLength(0); +- +- for (; ! isWhitespace(ch) && ch != '<'; ch = read()) +- _sbuf.append((char) ch); +- +- _peek = ch; +- +- return new Double(_sbuf.toString()).doubleValue(); +- } +- +- /** +- * Parses a date value from the stream. +- */ +- protected long parseDate() +- throws IOException +- { +- if (_utcCalendar == null) +- _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); +- +- return parseDate(_utcCalendar); +- } +- +- /** +- * Parses a date value from the stream. +- */ +- protected long parseDate(Calendar calendar) +- throws IOException +- { +- int ch = skipWhitespace(); +- +- int year = 0; +- for (int i = 0; i < 4; i++) { +- if (ch >= '0' && ch <= '9') +- year = 10 * year + ch - '0'; +- else +- throw expectedChar("year", ch); +- +- ch = read(); +- } +- +- int month = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- month = 10 * month + ch - '0'; +- else +- throw expectedChar("month", ch); +- +- ch = read(); +- } +- +- int day = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- day = 10 * day + ch - '0'; +- else +- throw expectedChar("day", ch); +- +- ch = read(); +- } +- +- if (ch != 'T') +- throw expectedChar("`T'", ch); +- +- ch = read(); +- +- int hour = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- hour = 10 * hour + ch - '0'; +- else +- throw expectedChar("hour", ch); +- +- ch = read(); +- } +- +- int minute = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- minute = 10 * minute + ch - '0'; +- else +- throw expectedChar("minute", ch); +- +- ch = read(); +- } +- +- int second = 0; +- for (int i = 0; i < 2; i++) { +- if (ch >= '0' && ch <= '9') +- second = 10 * second + ch - '0'; +- else +- throw expectedChar("second", ch); +- +- ch = read(); +- } +- +- int ms = 0; +- if (ch == '.') { +- ch = read(); +- +- while (ch >= '0' && ch <= '9') { +- ms = 10 * ms + ch - '0'; +- +- ch = read(); +- } +- } +- +- for (; ch > 0 && ch != '<'; ch = read()) { +- } +- +- _peek = ch; +- +- calendar.set(Calendar.YEAR, year); +- calendar.set(Calendar.MONTH, month - 1); +- calendar.set(Calendar.DAY_OF_MONTH, day); +- calendar.set(Calendar.HOUR_OF_DAY, hour); +- calendar.set(Calendar.MINUTE, minute); +- calendar.set(Calendar.SECOND, second); +- calendar.set(Calendar.MILLISECOND, ms); +- +- return calendar.getTime().getTime(); +- } +- +- protected String parseString() +- throws IOException +- { +- _sbuf.setLength(0); +- +- return parseString(_sbuf).toString(); +- } +- +- /** +- * Parses a string value from the stream. The burlap object's +- * string buffer is used for the result. +- */ +- protected StringBuffer parseString(StringBuffer sbuf) +- throws IOException +- { +- int ch; +- +- while ((ch = readChar()) >= 0) +- sbuf.append((char) ch); +- +- return sbuf; +- } +- +- org.w3c.dom.Node parseXML() +- throws IOException +- { +- throw error("help!"); +- } +- +- /** +- * Reads a character from the underlying stream. +- */ +- int readChar() +- throws IOException +- { +- int ch = read(); +- +- if (ch == '<' || ch < 0) { +- _peek = ch; +- return -1; +- } +- +- if (ch == '&') { +- ch = read(); +- +- if (ch == '#') { +- ch = read(); +- +- if (ch >= '0' && ch <= '9') { +- int v = 0; +- for (; ch >= '0' && ch <= '9'; ch = read()) { +- v = 10 * v + ch - '0'; +- } +- +- if (ch != ';') +- throw error("expected ';' at " + (char) ch); +- +- return (char) v; +- } +- else +- throw error("expected digit at " + (char) ch); +- } +- else { +- _entityBuffer.setLength(0); +- +- for (; ch >= 'a' && ch <= 'z'; ch = read()) +- _entityBuffer.append((char) ch); +- +- String entity = _entityBuffer.toString(); +- +- if (ch != ';') +- throw expectedChar("';'", ch); +- +- if (entity.equals("amp")) +- return '&'; +- else if (entity.equals("apos")) +- return '\''; +- else if (entity.equals("quot")) +- return '"'; +- else if (entity.equals("lt")) +- return '<'; +- else if (entity.equals("gt")) +- return '>'; +- else +- throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); +- } +- } +- else if (ch < 0x80) +- return (char) ch; +- else if ((ch & 0xe0) == 0xc0) { +- int ch1 = read(); +- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); +- +- return (char) v; +- } +- else if ((ch & 0xf0) == 0xe0) { +- int ch1 = read(); +- int ch2 = read(); +- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); +- +- return (char) v; +- } +- else +- throw new BurlapProtocolException("bad utf-8 encoding"); +- } +- +- /** +- * Parses a byte array. +- */ +- protected byte []parseBytes() +- throws IOException +- { +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- parseBytes(bos); +- +- return bos.toByteArray(); +- } +- +- /** +- * Parses a byte array. +- */ +- protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) +- throws IOException +- { +- int ch; +- for (ch = skipWhitespace(); ch >= 0 && ch != '<'; ch = skipWhitespace()) { +- int b1 = ch; +- int b2 = read(); +- int b3 = read(); +- int b4 = read(); +- +- if (b4 != '=') { +- int chunk = ((base64Decode[b1] << 18) + +- (base64Decode[b2] << 12) + +- (base64Decode[b3] << 6) + +- (base64Decode[b4])); +- +- bos.write(chunk >> 16); +- bos.write(chunk >> 8); +- bos.write(chunk); +- } +- else if (b3 != '=') { +- int chunk = ((base64Decode[b1] << 10) + +- (base64Decode[b2] << 4) + +- (base64Decode[b3] >> 2)); +- +- bos.write(chunk >> 8); +- bos.write(chunk); +- } +- else { +- int chunk = ((base64Decode[b1] << 2) + +- (base64Decode[b2] >> 4)); +- +- bos.write(chunk); +- } +- } +- +- if (ch == '<') +- _peek = ch; +- +- return bos; +- } +- +- public void expectTag(int expectTag) +- throws IOException +- { +- int tag = parseTag(); +- +- if (tag != expectTag) +- throw error("expected " + tagName(expectTag) + " at " + tagName(tag)); +- } +- +- /** +- * Parses a tag. Returns true if it's a start tag. +- */ +- protected int parseTag() +- throws IOException +- { +- if (_peekTag >= 0) { +- int tag = _peekTag; +- _peekTag = -1; +- return tag; +- } +- +- int ch = skipWhitespace(); +- int endTagDelta = 0; +- +- if (ch != '<') +- throw expectedChar("'<'", ch); +- +- ch = read(); +- if (ch == '/') { +- endTagDelta = 100; +- ch = _is.read(); +- } +- +- if (! isTagChar(ch)) +- throw expectedChar("tag", ch); +- +- _sbuf.setLength(0); +- for (; isTagChar(ch); ch = read()) +- _sbuf.append((char) ch); +- +- if (ch != '>') +- throw expectedChar("'>'", ch); +- +- Integer value = (Integer) _tagMap.get(_sbuf.toString()); +- if (value == null) +- throw error("Unknown tag <" + _sbuf + ">"); +- +- return value.intValue() + endTagDelta; +- } +- +- /** +- * Returns true if the character is a valid tag character. +- */ +- private boolean isTagChar(int ch) +- { +- return (ch >= 'a' && ch <= 'z' || +- ch >= 'A' && ch <= 'Z' || +- ch >= '0' && ch <= '9' || +- ch == ':' || ch == '-'); +- } +- +- protected int skipWhitespace() +- throws IOException +- { +- int ch = read(); +- +- for (; +- ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; +- ch = read()) { +- } +- +- return ch; +- } +- +- protected boolean isWhitespace(int ch) +- throws IOException +- { +- return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; +- } +- +- /** +- * Reads bytes from the underlying stream. +- */ +- int read(byte []buffer, int offset, int length) +- throws IOException +- { +- throw new UnsupportedOperationException(); +- } +- +- int read() +- throws IOException +- { +- if (_peek >= 0) { +- int value = _peek; +- _peek = -1; +- return value; +- } +- +- int ch = _is.read(); +- return ch; +- } +- +- public Reader getReader() +- { +- return null; +- } +- +- public InputStream readInputStream() +- { +- return null; +- } +- +- public InputStream getInputStream() +- { +- return null; +- } +- +- protected IOException expectBeginTag(String expect, String tag) +- { +- return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); +- } +- +- protected IOException expectedChar(String expect, int ch) +- { +- if (ch < 0) +- return error("expected " + expect + " at end of file"); +- else +- return error("expected " + expect + " at " + (char) ch); +- } +- +- protected IOException expectedTag(String expect, int tag) +- { +- return error("expected " + expect + " at " + tagName(tag)); +- } +- +- protected IOException error(String message) +- { +- return new BurlapProtocolException(message); +- } +- +- protected static String tagName(int tag) +- { +- switch (tag) { +- case TAG_NULL: +- return ""; +- case TAG_NULL_END: +- return ""; +- +- case TAG_BOOLEAN: +- return ""; +- case TAG_BOOLEAN_END: +- return ""; +- +- case TAG_INT: +- return ""; +- case TAG_INT_END: +- return ""; +- +- case TAG_LONG: +- return ""; +- case TAG_LONG_END: +- return ""; +- +- case TAG_DOUBLE: +- return ""; +- case TAG_DOUBLE_END: +- return ""; +- +- case TAG_STRING: +- return ""; +- case TAG_STRING_END: +- return ""; +- +- case TAG_XML: +- return ""; +- case TAG_XML_END: +- return ""; +- +- case TAG_BASE64: +- return ""; +- case TAG_BASE64_END: +- return ""; +- +- case TAG_MAP: +- return ""; +- case TAG_MAP_END: +- return ""; +- +- case TAG_LIST: +- return ""; +- case TAG_LIST_END: +- return ""; +- +- case TAG_TYPE: +- return ""; +- case TAG_TYPE_END: +- return ""; +- +- case TAG_LENGTH: +- return ""; +- case TAG_LENGTH_END: +- return ""; +- +- case TAG_REF: +- return ""; +- case TAG_REF_END: +- return ""; +- +- case TAG_REMOTE: +- return ""; +- case TAG_REMOTE_END: +- return ""; +- +- case TAG_CALL: +- return ""; +- case TAG_CALL_END: +- return ""; +- +- case TAG_REPLY: +- return ""; +- case TAG_REPLY_END: +- return ""; +- +- case TAG_HEADER: +- return "
"; +- case TAG_HEADER_END: +- return "
"; +- +- case TAG_FAULT: +- return ""; +- case TAG_FAULT_END: +- return ""; +- +- case -1: +- return "end of file"; +- +- default: +- return "unknown " + tag; +- } +- } +- +- +- static { +- _tagMap = new HashMap(); +- _tagMap.put("null", new Integer(TAG_NULL)); +- +- _tagMap.put("boolean", new Integer(TAG_BOOLEAN)); +- _tagMap.put("int", new Integer(TAG_INT)); +- _tagMap.put("long", new Integer(TAG_LONG)); +- _tagMap.put("double", new Integer(TAG_DOUBLE)); +- +- _tagMap.put("date", new Integer(TAG_DATE)); +- +- _tagMap.put("string", new Integer(TAG_STRING)); +- _tagMap.put("xml", new Integer(TAG_XML)); +- _tagMap.put("base64", new Integer(TAG_BASE64)); +- +- _tagMap.put("map", new Integer(TAG_MAP)); +- _tagMap.put("list", new Integer(TAG_LIST)); +- +- _tagMap.put("type", new Integer(TAG_TYPE)); +- _tagMap.put("length", new Integer(TAG_LENGTH)); +- +- _tagMap.put("ref", new Integer(TAG_REF)); +- _tagMap.put("remote", new Integer(TAG_REMOTE)); +- +- _tagMap.put("burlap:call", new Integer(TAG_CALL)); +- _tagMap.put("burlap:reply", new Integer(TAG_REPLY)); +- _tagMap.put("fault", new Integer(TAG_FAULT)); +- _tagMap.put("method", new Integer(TAG_METHOD)); +- _tagMap.put("header", new Integer(TAG_HEADER)); +- } +- +- static { +- base64Decode = new int[256]; +- for (int i = 'A'; i <= 'Z'; i++) +- base64Decode[i] = i - 'A'; +- for (int i = 'a'; i <= 'z'; i++) +- base64Decode[i] = i - 'a' + 26; +- for (int i = '0'; i <= '9'; i++) +- base64Decode[i] = i - '0' + 52; +- base64Decode['+'] = 62; +- base64Decode['/'] = 63; +- } +- +- private static Field getDetailMessageField() +- { +- if (_detailMessageField == null) { +- try { +- _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); +- _detailMessageField.setAccessible(true); +- } catch (Throwable e) { +- } +- } +- +- return _detailMessageField; +- +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import com.caucho.hessian.io.Deserializer; ++import com.caucho.hessian.io.HessianRemoteResolver; ++import com.caucho.hessian.io.SerializerFactory; ++ ++import java.io.ByteArrayOutputStream; ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.Reader; ++import java.lang.reflect.Field; ++import java.util.ArrayList; ++import java.util.Calendar; ++import java.util.Date; ++import java.util.HashMap; ++import java.util.TimeZone; ++ ++/** ++ * Input stream for Burlap requests. ++ * ++ *

BurlapInput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * InputStream is = ...; // from http connection
++ * BurlapInput in = new BurlapInput(is);
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++public class BurlapInput extends AbstractBurlapInput { ++ private static int []base64Decode; ++ ++ public final static int TAG_EOF = -1; ++ ++ public final static int TAG_NULL = 0; ++ public final static int TAG_BOOLEAN = 1; ++ public final static int TAG_INT = 2; ++ public final static int TAG_LONG = 3; ++ public final static int TAG_DOUBLE = 4; ++ public final static int TAG_DATE = 5; ++ public final static int TAG_STRING = 6; ++ public final static int TAG_XML = 7; ++ public final static int TAG_BASE64 = 8; ++ public final static int TAG_MAP = 9; ++ public final static int TAG_LIST = 10; ++ public final static int TAG_TYPE = 11; ++ public final static int TAG_LENGTH = 12; ++ ++ public final static int TAG_REF = 13; ++ public final static int TAG_REMOTE = 14; ++ ++ public final static int TAG_CALL = 15; ++ public final static int TAG_REPLY = 16; ++ public final static int TAG_FAULT = 17; ++ public final static int TAG_METHOD = 18; ++ public final static int TAG_HEADER = 19; ++ ++ public final static int TAG_NULL_END = TAG_NULL + 100; ++ public final static int TAG_BOOLEAN_END = TAG_BOOLEAN + 100; ++ public final static int TAG_INT_END = TAG_INT + 100; ++ public final static int TAG_LONG_END = TAG_LONG + 100; ++ public final static int TAG_DOUBLE_END = TAG_DOUBLE + 100; ++ public final static int TAG_DATE_END = TAG_DATE + 100; ++ public final static int TAG_STRING_END = TAG_STRING + 100; ++ public final static int TAG_XML_END = TAG_XML + 100; ++ public final static int TAG_BASE64_END = TAG_BASE64 + 100; ++ public final static int TAG_MAP_END = TAG_MAP + 100; ++ public final static int TAG_LIST_END = TAG_LIST + 100; ++ public final static int TAG_TYPE_END = TAG_TYPE + 100; ++ public final static int TAG_LENGTH_END = TAG_LENGTH + 100; ++ ++ public final static int TAG_REF_END = TAG_REF + 100; ++ public final static int TAG_REMOTE_END = TAG_REMOTE + 100; ++ ++ public final static int TAG_CALL_END = TAG_CALL + 100; ++ public final static int TAG_REPLY_END = TAG_REPLY + 100; ++ public final static int TAG_FAULT_END = TAG_FAULT + 100; ++ public final static int TAG_METHOD_END = TAG_METHOD + 100; ++ public final static int TAG_HEADER_END = TAG_HEADER + 100; ++ ++ private static HashMap _tagMap; ++ ++ private static Field _detailMessageField; ++ ++ protected SerializerFactory _serializerFactory; ++ ++ protected ArrayList _refs; ++ ++ // the underlying input stream ++ private InputStream _is; ++ // a peek character ++ protected int _peek = -1; ++ ++ // the method for a call ++ private String _method; ++ ++ private int _peekTag; ++ ++ private Throwable _replyFault; ++ ++ protected StringBuffer _sbuf = new StringBuffer(); ++ protected StringBuffer _entityBuffer = new StringBuffer(); ++ ++ protected Calendar _utcCalendar; ++ protected Calendar _localCalendar; ++ ++ /** ++ * Creates an uninitialized Burlap input stream. ++ */ ++ public BurlapInput() ++ { ++ } ++ ++ /** ++ * Creates a new Burlap input stream, initialized with an ++ * underlying input stream. ++ * ++ * @param is the underlying input stream. ++ */ ++ public BurlapInput(InputStream is) ++ { ++ init(is); ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ return _serializerFactory; ++ } ++ ++ /** ++ * Initialize the burlap stream with the underlying input stream. ++ */ ++ public void init(InputStream is) ++ { ++ _is = is; ++ _method = null; ++ _peek = -1; ++ _peekTag = -1; ++ _refs = null; ++ _replyFault = null; ++ ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(); ++ } ++ ++ /** ++ * Returns the calls method ++ */ ++ public String getMethod() ++ { ++ return _method; ++ } ++ ++ /** ++ * Returns any reply fault. ++ */ ++ public Throwable getReplyFault() ++ { ++ return _replyFault; ++ } ++ ++ /** ++ * Starts reading the call ++ * ++ *
++   * <burlap:call>
++   * <method>method</method>
++   * 
++ */ ++ public void startCall() ++ throws IOException ++ { ++ readCall(); ++ ++ while ((readHeader() != null)) ++ readObject(); ++ ++ readMethod(); ++ } ++ ++ /** ++ * Starts reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * <burlap:call>
++   * 
++ */ ++ public int readCall() ++ throws IOException ++ { ++ expectTag(TAG_CALL); ++ ++ int major = 1; ++ int minor = 0; ++ ++ return (major << 16) + minor; ++ } ++ ++ /** ++ * Reads the method ++ * ++ *
++   * <method>method</method>
++   * 
++ */ ++ public String readMethod() ++ throws IOException ++ { ++ expectTag(TAG_METHOD); ++ ++ _method = parseString(); ++ ++ expectTag(TAG_METHOD_END); ++ ++ return _method; ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * </burlap:call>
++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ expectTag(TAG_CALL_END); ++ } ++ ++ /** ++ * Reads a reply as an object. ++ * If the reply has a fault, throws the exception. ++ */ ++ public Object readReply(Class expectedClass) ++ throws Throwable ++ { ++ expectTag(TAG_REPLY); ++ ++ int tag = parseTag(); ++ ++ if (tag == TAG_FAULT) ++ throw prepareFault(); ++ else { ++ _peekTag = tag; ++ Object value = readObject(expectedClass); ++ ++ expectTag(TAG_REPLY_END); ++ ++ return value; ++ } ++ } ++ ++ /** ++ * Starts reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * <burlap:reply>
++   * <value>
++   * 
++ */ ++ public void startReply() ++ throws Throwable ++ { ++ expectTag(TAG_REPLY); ++ ++ int tag = parseTag(); ++ if (tag == TAG_FAULT) ++ throw prepareFault(); ++ else ++ _peekTag = tag; ++ } ++ ++ /** ++ * Prepares the fault. ++ */ ++ private Throwable prepareFault() ++ throws IOException ++ { ++ HashMap fault = readFault(); ++ ++ Object detail = fault.get("detail"); ++ String message = (String) fault.get("message"); ++ ++ if (detail instanceof Throwable) { ++ _replyFault = (Throwable) detail; ++ ++ Field detailMessageField = getDetailMessageField(); ++ ++ if (message != null && detailMessageField != null) { ++ try { ++ detailMessageField.set(_replyFault, message); ++ } catch (Throwable e) { ++ } ++ } ++ ++ return _replyFault; ++ } ++ ++ else { ++ String code = (String) fault.get("code"); ++ ++ _replyFault = new BurlapServiceException(message, code, detail); ++ ++ return _replyFault; ++ } ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * </burlap:reply>
++   * 
++ */ ++ public void completeReply() ++ throws IOException ++ { ++ expectTag(TAG_REPLY_END); ++ } ++ ++ /** ++ * Reads a header, returning null if there are no headers. ++ * ++ *
++   * <header>value</header>
++   * 
++ */ ++ public String readHeader() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ if (tag == TAG_HEADER) { ++ _sbuf.setLength(0); ++ String value = parseString(_sbuf).toString(); ++ expectTag(TAG_HEADER_END); ++ return value; ++ } ++ ++ _peekTag = tag; ++ ++ return null; ++ } ++ ++ /** ++ * Reads a null ++ * ++ *
++   * <null></null>
++   * 
++ */ ++ public void readNull() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ switch (tag) { ++ case TAG_NULL: ++ expectTag(TAG_NULL_END); ++ return; ++ ++ default: ++ throw expectedTag("null", tag); ++ } ++ } ++ ++ /** ++ * Reads a boolean ++ * ++ *
++   * <boolean>0</boolean>
++   * <boolean>1</boolean>
++   * 
++ */ ++ public boolean readBoolean() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ boolean value; ++ ++ switch (tag) { ++ case TAG_NULL: ++ value = false; ++ expectTag(TAG_NULL_END); ++ return value; ++ ++ case TAG_BOOLEAN: ++ value = parseInt() != 0; ++ expectTag(TAG_BOOLEAN_END); ++ return value; ++ ++ case TAG_INT: ++ value = parseInt() != 0; ++ expectTag(TAG_INT_END); ++ return value; ++ ++ case TAG_LONG: ++ value = parseLong() != 0; ++ expectTag(TAG_LONG_END); ++ return value; ++ ++ case TAG_DOUBLE: ++ value = parseDouble() != 0; ++ expectTag(TAG_DOUBLE_END); ++ return value; ++ ++ default: ++ throw expectedTag("boolean", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte ++ * ++ *
++   * <int>value</int>
++   * 
++ */ ++ public byte readByte() ++ throws IOException ++ { ++ return (byte) readInt(); ++ } ++ ++ /** ++ * Reads a short ++ * ++ *
++   * <int>value</int>
++   * 
++ */ ++ public short readShort() ++ throws IOException ++ { ++ return (short) readInt(); ++ } ++ ++ /** ++ * Reads an integer ++ * ++ *
++   * <int>value</int>
++   * 
++ */ ++ public int readInt() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ int value; ++ ++ switch (tag) { ++ case TAG_NULL: ++ value = 0; ++ expectTag(TAG_NULL_END); ++ return value; ++ ++ case TAG_BOOLEAN: ++ value = parseInt(); ++ expectTag(TAG_BOOLEAN_END); ++ return value; ++ ++ case TAG_INT: ++ value = parseInt(); ++ expectTag(TAG_INT_END); ++ return value; ++ ++ case TAG_LONG: ++ value = (int) parseLong(); ++ expectTag(TAG_LONG_END); ++ return value; ++ ++ case TAG_DOUBLE: ++ value = (int) parseDouble(); ++ expectTag(TAG_DOUBLE_END); ++ return value; ++ ++ default: ++ throw expectedTag("int", tag); ++ } ++ } ++ ++ /** ++ * Reads a long ++ * ++ *
++   * <long>value</long>
++   * 
++ */ ++ public long readLong() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ long value; ++ ++ switch (tag) { ++ case TAG_NULL: ++ value = 0; ++ expectTag(TAG_NULL_END); ++ return value; ++ ++ case TAG_BOOLEAN: ++ value = parseInt(); ++ expectTag(TAG_BOOLEAN_END); ++ return value; ++ ++ case TAG_INT: ++ value = parseInt(); ++ expectTag(TAG_INT_END); ++ return value; ++ ++ case TAG_LONG: ++ value = parseLong(); ++ expectTag(TAG_LONG_END); ++ return value; ++ ++ case TAG_DOUBLE: ++ value = (long) parseDouble(); ++ expectTag(TAG_DOUBLE_END); ++ return value; ++ ++ default: ++ throw expectedTag("long", tag); ++ } ++ } ++ ++ /** ++ * Reads a float ++ * ++ *
++   * <double>value</double>
++   * 
++ */ ++ public float readFloat() ++ throws IOException ++ { ++ return (float) readDouble(); ++ } ++ ++ /** ++ * Reads a double ++ * ++ *
++   * <double>value</double>
++   * 
++ */ ++ public double readDouble() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ double value; ++ ++ switch (tag) { ++ case TAG_NULL: ++ value = 0; ++ expectTag(TAG_NULL_END); ++ return value; ++ ++ case TAG_BOOLEAN: ++ value = parseInt(); ++ expectTag(TAG_BOOLEAN_END); ++ return value; ++ ++ case TAG_INT: ++ value = parseInt(); ++ expectTag(TAG_INT_END); ++ return value; ++ ++ case TAG_LONG: ++ value = parseLong(); ++ expectTag(TAG_LONG_END); ++ return value; ++ ++ case TAG_DOUBLE: ++ value = parseDouble(); ++ expectTag(TAG_DOUBLE_END); ++ return value; ++ ++ default: ++ throw expectedTag("double", tag); ++ } ++ } ++ ++ /** ++ * Reads a date. ++ * ++ *
++   * <date>ISO-8609 date</date>
++   * 
++ */ ++ public long readUTCDate() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ if (tag != TAG_DATE) ++ throw error("expected date"); ++ ++ if (_utcCalendar == null) ++ _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); ++ ++ long value = parseDate(_utcCalendar); ++ ++ expectTag(TAG_DATE_END); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a date. ++ * ++ *
++   * <date>ISO-8609 date</date>
++   * 
++ */ ++ public long readLocalDate() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ if (tag != TAG_DATE) ++ throw error("expected date"); ++ ++ if (_localCalendar == null) ++ _localCalendar = Calendar.getInstance(); ++ ++ long value = parseDate(_localCalendar); ++ ++ expectTag(TAG_DATE_END); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a string ++ * ++ *
++   * <string>value</string>
++   * 
++ */ ++ public String readString() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ String value; ++ ++ switch (tag) { ++ case TAG_NULL: ++ expectTag(TAG_NULL_END); ++ return null; ++ ++ case TAG_STRING: ++ _sbuf.setLength(0); ++ value = parseString(_sbuf).toString(); ++ expectTag(TAG_STRING_END); ++ return value; ++ ++ case TAG_XML: ++ _sbuf.setLength(0); ++ value = parseString(_sbuf).toString(); ++ expectTag(TAG_XML_END); ++ return value; ++ ++ default: ++ throw expectedTag("string", tag); ++ } ++ } ++ ++ /** ++ * Reads an XML node. ++ * ++ *
++   * &xml;xml string</xml>
++   * 
++ */ ++ public org.w3c.dom.Node readNode() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'S': ++ case 's': ++ case 'X': ++ case 'x': ++ throw error("can't cope"); ++ ++ default: ++ throw expectedTag("string", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte array ++ * ++ *
++   * <base64>...</base64>
++   * 
++ */ ++ public byte []readBytes() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ switch (tag) { ++ case TAG_NULL: ++ expectTag(TAG_NULL_END); ++ return null; ++ ++ case TAG_BASE64: ++ byte []data = parseBytes(); ++ expectTag(TAG_BASE64_END); ++ ++ return data; ++ ++ default: ++ throw expectedTag("bytes", tag); ++ } ++ } ++ ++ /** ++ * Reads a length ++ * ++ *
++   * <length>value</length>
++   * 
++ */ ++ public int readLength() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ if (tag != TAG_LENGTH) { ++ _peekTag = tag; ++ return -1; ++ } ++ ++ int value = parseInt(); ++ ++ expectTag(TAG_LENGTH_END); ++ ++ return value; ++ } ++ ++ /** ++ * Reads a fault. ++ */ ++ private HashMap readFault() ++ throws IOException ++ { ++ HashMap map = new HashMap(); ++ ++ int code = parseTag(); ++ for (; code >= 0 && code != TAG_FAULT_END; code = parseTag()) { ++ _peekTag = code; ++ ++ Object key = readObject(); ++ Object value = readObject(); ++ ++ if (key != null && value != null) ++ map.put(key, value); ++ } ++ ++ if (code != TAG_FAULT_END) ++ throw expectedTag("fault", code); ++ ++ return map; ++ } ++ ++ /** ++ * Reads an object from the input stream with an expected type. ++ */ ++ public Object readObject(Class cl) ++ throws IOException ++ { ++ if (cl == null || cl.equals(Object.class)) ++ return readObject(); ++ ++ int tag = parseTag(); ++ ++ switch (tag) { ++ case TAG_NULL: ++ expectTag(TAG_NULL_END); ++ return null; ++ ++ case TAG_MAP: ++ { ++ String type = readType(); ++ Deserializer reader; ++ ++ reader = _serializerFactory.getObjectDeserializer(type, cl); ++ ++ return reader.readMap(this); ++ } ++ ++ case TAG_LIST: ++ { ++ String type = readType(); ++ int length = readLength(); ++ ++ Deserializer reader; ++ reader = _serializerFactory.getObjectDeserializer(type, cl); ++ ++ return reader.readList(this, length); ++ } ++ ++ case TAG_REF: ++ { ++ int ref = parseInt(); ++ ++ expectTag(TAG_REF_END); ++ ++ return _refs.get(ref); ++ } ++ ++ case TAG_REMOTE: ++ { ++ String type = readType(); ++ String url = readString(); ++ ++ expectTag(TAG_REMOTE_END); ++ ++ Object remote = resolveRemote(type, url); ++ ++ return remote; ++ } ++ } ++ ++ _peekTag = tag; ++ ++ Object value = _serializerFactory.getDeserializer(cl).readObject(this); ++ ++ return value; ++ } ++ ++ /** ++ * Reads an arbitrary object from the input stream when the type ++ * is unknown. ++ */ ++ public Object readObject() ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ switch (tag) { ++ case TAG_NULL: ++ expectTag(TAG_NULL_END); ++ return null; ++ ++ case TAG_BOOLEAN: ++ { ++ int value = parseInt(); ++ expectTag(TAG_BOOLEAN_END); ++ return new Boolean(value != 0); ++ } ++ ++ case TAG_INT: ++ { ++ int value = parseInt(); ++ expectTag(TAG_INT_END); ++ return new Integer(value); ++ } ++ ++ case TAG_LONG: ++ { ++ long value = parseLong(); ++ expectTag(TAG_LONG_END); ++ return new Long(value); ++ } ++ ++ case TAG_DOUBLE: ++ { ++ double value = parseDouble(); ++ expectTag(TAG_DOUBLE_END); ++ return new Double(value); ++ } ++ ++ case TAG_DATE: ++ { ++ long value = parseDate(); ++ expectTag(TAG_DATE_END); ++ return new Date(value); ++ } ++ ++ case TAG_XML: ++ { ++ return parseXML(); ++ } ++ ++ case TAG_STRING: ++ { ++ _sbuf.setLength(0); ++ ++ String value = parseString(_sbuf).toString(); ++ ++ expectTag(TAG_STRING_END); ++ ++ return value; ++ } ++ ++ case TAG_BASE64: ++ { ++ byte []data = parseBytes(); ++ ++ expectTag(TAG_BASE64_END); ++ ++ return data; ++ } ++ ++ case TAG_LIST: ++ { ++ String type = readType(); ++ int length = readLength(); ++ ++ return _serializerFactory.readList(this, length, type); ++ } ++ ++ case TAG_MAP: ++ { ++ String type = readType(); ++ Deserializer deserializer; ++ deserializer = _serializerFactory.getObjectDeserializer(type); ++ ++ return deserializer.readMap(this); ++ } ++ ++ case TAG_REF: ++ { ++ int ref = parseInt(); ++ ++ expectTag(TAG_REF_END); ++ ++ return _refs.get(ref); ++ } ++ ++ case TAG_REMOTE: ++ { ++ String type = readType(); ++ String url = readString(); ++ ++ expectTag(TAG_REMOTE_END); ++ ++ return resolveRemote(type, url); ++ } ++ ++ default: ++ throw error("unknown code:" + tagName(tag)); ++ } ++ } ++ ++ /** ++ * Reads a remote object. ++ */ ++ public Object readRemote() ++ throws IOException ++ { ++ String type = readType(); ++ String url = readString(); ++ ++ return resolveRemote(type, url); ++ } ++ ++ /** ++ * Reads a reference. ++ */ ++ public Object readRef() ++ throws IOException ++ { ++ return _refs.get(parseInt()); ++ } ++ ++ /** ++ * Reads the start of a list. ++ */ ++ public int readListStart() ++ throws IOException ++ { ++ return parseTag(); ++ } ++ ++ /** ++ * Reads the start of a map. ++ */ ++ public int readMapStart() ++ throws IOException ++ { ++ return parseTag(); ++ } ++ ++ /** ++ * Returns true if this is the end of a list or a map. ++ */ ++ public boolean isEnd() ++ throws IOException ++ { ++ int code = parseTag(); ++ ++ _peekTag = code; ++ ++ return (code < 0 || code >= 100); ++ } ++ ++ /** ++ * Reads the end byte. ++ */ ++ public void readEnd() ++ throws IOException ++ { ++ int code = parseTag(); ++ ++ if (code < 100) ++ throw error("unknown code:" + (char) code); ++ } ++ ++ /** ++ * Reads the end of the map ++ */ ++ public void readMapEnd() ++ throws IOException ++ { ++ expectTag(TAG_MAP_END); ++ } ++ ++ /** ++ * Reads the end of the map ++ */ ++ public void readListEnd() ++ throws IOException ++ { ++ expectTag(TAG_LIST_END); ++ } ++ ++ /** ++ * Adds a list/map reference. ++ */ ++ public int addRef(Object ref) ++ { ++ if (_refs == null) ++ _refs = new ArrayList(); ++ ++ _refs.add(ref); ++ ++ return _refs.size() - 1; ++ } ++ ++ /** ++ * Adds a list/map reference. ++ */ ++ public void setRef(int i, Object ref) ++ { ++ _refs.set(i, ref); ++ } ++ ++ /** ++ * Resolves a remote object. ++ */ ++ public Object resolveRemote(String type, String url) ++ throws IOException ++ { ++ HessianRemoteResolver resolver = getRemoteResolver(); ++ ++ if (resolver != null) ++ return resolver.lookup(type, url); ++ else ++ return new BurlapRemote(type, url); ++ } ++ ++ /** ++ * Parses a type from the stream. ++ * ++ *
++   * <type>type</type>
++   * 
++ */ ++ public String readType() ++ throws IOException ++ { ++ int code = parseTag(); ++ ++ if (code != TAG_TYPE) { ++ _peekTag = code; ++ return ""; ++ } ++ ++ _sbuf.setLength(0); ++ int ch; ++ while ((ch = readChar()) >= 0) ++ _sbuf.append((char) ch); ++ String type = _sbuf.toString(); ++ ++ expectTag(TAG_TYPE_END); ++ ++ return type; ++ } ++ ++ /** ++ * Parses a 32-bit integer value from the stream. ++ */ ++ private int parseInt() ++ throws IOException ++ { ++ int sign = 1; ++ ++ int ch = read(); ++ if (ch == '-') { ++ sign = -1; ++ ch = read(); ++ } ++ ++ int value = 0; ++ for (; ch >= '0' && ch <= '9'; ch = read()) ++ value = 10 * value + ch - '0'; ++ ++ _peek = ch; ++ ++ return sign * value; ++ } ++ ++ /** ++ * Parses a 64-bit long value from the stream. ++ */ ++ private long parseLong() ++ throws IOException ++ { ++ int sign = 1; ++ ++ int ch = read(); ++ if (ch == '-') { ++ sign = -1; ++ ch = read(); ++ } ++ ++ long value = 0; ++ for (; ch >= '0' && ch <= '9'; ch = read()) ++ value = 10 * value + ch - '0'; ++ ++ _peek = ch; ++ ++ return sign * value; ++ } ++ ++ /** ++ * Parses a 64-bit double value from the stream. ++ * ++ *
++   * b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ private double parseDouble() ++ throws IOException ++ { ++ int ch = skipWhitespace(); ++ ++ _sbuf.setLength(0); ++ ++ for (; ! isWhitespace(ch) && ch != '<'; ch = read()) ++ _sbuf.append((char) ch); ++ ++ _peek = ch; ++ ++ return new Double(_sbuf.toString()).doubleValue(); ++ } ++ ++ /** ++ * Parses a date value from the stream. ++ */ ++ protected long parseDate() ++ throws IOException ++ { ++ if (_utcCalendar == null) ++ _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); ++ ++ return parseDate(_utcCalendar); ++ } ++ ++ /** ++ * Parses a date value from the stream. ++ */ ++ protected long parseDate(Calendar calendar) ++ throws IOException ++ { ++ int ch = skipWhitespace(); ++ ++ int year = 0; ++ for (int i = 0; i < 4; i++) { ++ if (ch >= '0' && ch <= '9') ++ year = 10 * year + ch - '0'; ++ else ++ throw expectedChar("year", ch); ++ ++ ch = read(); ++ } ++ ++ int month = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ month = 10 * month + ch - '0'; ++ else ++ throw expectedChar("month", ch); ++ ++ ch = read(); ++ } ++ ++ int day = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ day = 10 * day + ch - '0'; ++ else ++ throw expectedChar("day", ch); ++ ++ ch = read(); ++ } ++ ++ if (ch != 'T') ++ throw expectedChar("`T'", ch); ++ ++ ch = read(); ++ ++ int hour = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ hour = 10 * hour + ch - '0'; ++ else ++ throw expectedChar("hour", ch); ++ ++ ch = read(); ++ } ++ ++ int minute = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ minute = 10 * minute + ch - '0'; ++ else ++ throw expectedChar("minute", ch); ++ ++ ch = read(); ++ } ++ ++ int second = 0; ++ for (int i = 0; i < 2; i++) { ++ if (ch >= '0' && ch <= '9') ++ second = 10 * second + ch - '0'; ++ else ++ throw expectedChar("second", ch); ++ ++ ch = read(); ++ } ++ ++ int ms = 0; ++ if (ch == '.') { ++ ch = read(); ++ ++ while (ch >= '0' && ch <= '9') { ++ ms = 10 * ms + ch - '0'; ++ ++ ch = read(); ++ } ++ } ++ ++ for (; ch > 0 && ch != '<'; ch = read()) { ++ } ++ ++ _peek = ch; ++ ++ calendar.set(Calendar.YEAR, year); ++ calendar.set(Calendar.MONTH, month - 1); ++ calendar.set(Calendar.DAY_OF_MONTH, day); ++ calendar.set(Calendar.HOUR_OF_DAY, hour); ++ calendar.set(Calendar.MINUTE, minute); ++ calendar.set(Calendar.SECOND, second); ++ calendar.set(Calendar.MILLISECOND, ms); ++ ++ return calendar.getTime().getTime(); ++ } ++ ++ protected String parseString() ++ throws IOException ++ { ++ _sbuf.setLength(0); ++ ++ return parseString(_sbuf).toString(); ++ } ++ ++ /** ++ * Parses a string value from the stream. The burlap object's ++ * string buffer is used for the result. ++ */ ++ protected StringBuffer parseString(StringBuffer sbuf) ++ throws IOException ++ { ++ int ch; ++ ++ while ((ch = readChar()) >= 0) ++ sbuf.append((char) ch); ++ ++ return sbuf; ++ } ++ ++ org.w3c.dom.Node parseXML() ++ throws IOException ++ { ++ throw error("help!"); ++ } ++ ++ /** ++ * Reads a character from the underlying stream. ++ */ ++ int readChar() ++ throws IOException ++ { ++ int ch = read(); ++ ++ if (ch == '<' || ch < 0) { ++ _peek = ch; ++ return -1; ++ } ++ ++ if (ch == '&') { ++ ch = read(); ++ ++ if (ch == '#') { ++ ch = read(); ++ ++ if (ch >= '0' && ch <= '9') { ++ int v = 0; ++ for (; ch >= '0' && ch <= '9'; ch = read()) { ++ v = 10 * v + ch - '0'; ++ } ++ ++ if (ch != ';') ++ throw error("expected ';' at " + (char) ch); ++ ++ return (char) v; ++ } ++ else ++ throw error("expected digit at " + (char) ch); ++ } ++ else { ++ _entityBuffer.setLength(0); ++ ++ for (; ch >= 'a' && ch <= 'z'; ch = read()) ++ _entityBuffer.append((char) ch); ++ ++ String entity = _entityBuffer.toString(); ++ ++ if (ch != ';') ++ throw expectedChar("';'", ch); ++ ++ if (entity.equals("amp")) ++ return '&'; ++ else if (entity.equals("apos")) ++ return '\''; ++ else if (entity.equals("quot")) ++ return '"'; ++ else if (entity.equals("lt")) ++ return '<'; ++ else if (entity.equals("gt")) ++ return '>'; ++ else ++ throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); ++ } ++ } ++ else if (ch < 0x80) ++ return (char) ch; ++ else if ((ch & 0xe0) == 0xc0) { ++ int ch1 = read(); ++ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); ++ ++ return (char) v; ++ } ++ else if ((ch & 0xf0) == 0xe0) { ++ int ch1 = read(); ++ int ch2 = read(); ++ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); ++ ++ return (char) v; ++ } ++ else ++ throw new BurlapProtocolException("bad utf-8 encoding"); ++ } ++ ++ /** ++ * Parses a byte array. ++ */ ++ protected byte []parseBytes() ++ throws IOException ++ { ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ parseBytes(bos); ++ ++ return bos.toByteArray(); ++ } ++ ++ /** ++ * Parses a byte array. ++ */ ++ protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) ++ throws IOException ++ { ++ int ch; ++ for (ch = skipWhitespace(); ch >= 0 && ch != '<'; ch = skipWhitespace()) { ++ int b1 = ch; ++ int b2 = read(); ++ int b3 = read(); ++ int b4 = read(); ++ ++ if (b4 != '=') { ++ int chunk = ((base64Decode[b1] << 18) + ++ (base64Decode[b2] << 12) + ++ (base64Decode[b3] << 6) + ++ (base64Decode[b4])); ++ ++ bos.write(chunk >> 16); ++ bos.write(chunk >> 8); ++ bos.write(chunk); ++ } ++ else if (b3 != '=') { ++ int chunk = ((base64Decode[b1] << 10) + ++ (base64Decode[b2] << 4) + ++ (base64Decode[b3] >> 2)); ++ ++ bos.write(chunk >> 8); ++ bos.write(chunk); ++ } ++ else { ++ int chunk = ((base64Decode[b1] << 2) + ++ (base64Decode[b2] >> 4)); ++ ++ bos.write(chunk); ++ } ++ } ++ ++ if (ch == '<') ++ _peek = ch; ++ ++ return bos; ++ } ++ ++ public void expectTag(int expectTag) ++ throws IOException ++ { ++ int tag = parseTag(); ++ ++ if (tag != expectTag) ++ throw error("expected " + tagName(expectTag) + " at " + tagName(tag)); ++ } ++ ++ /** ++ * Parses a tag. Returns true if it's a start tag. ++ */ ++ protected int parseTag() ++ throws IOException ++ { ++ if (_peekTag >= 0) { ++ int tag = _peekTag; ++ _peekTag = -1; ++ return tag; ++ } ++ ++ int ch = skipWhitespace(); ++ int endTagDelta = 0; ++ ++ if (ch != '<') ++ throw expectedChar("'<'", ch); ++ ++ ch = read(); ++ if (ch == '/') { ++ endTagDelta = 100; ++ ch = _is.read(); ++ } ++ ++ if (! isTagChar(ch)) ++ throw expectedChar("tag", ch); ++ ++ _sbuf.setLength(0); ++ for (; isTagChar(ch); ch = read()) ++ _sbuf.append((char) ch); ++ ++ if (ch != '>') ++ throw expectedChar("'>'", ch); ++ ++ Integer value = (Integer) _tagMap.get(_sbuf.toString()); ++ if (value == null) ++ throw error("Unknown tag <" + _sbuf + ">"); ++ ++ return value.intValue() + endTagDelta; ++ } ++ ++ /** ++ * Returns true if the character is a valid tag character. ++ */ ++ private boolean isTagChar(int ch) ++ { ++ return (ch >= 'a' && ch <= 'z' || ++ ch >= 'A' && ch <= 'Z' || ++ ch >= '0' && ch <= '9' || ++ ch == ':' || ch == '-'); ++ } ++ ++ protected int skipWhitespace() ++ throws IOException ++ { ++ int ch = read(); ++ ++ for (; ++ ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; ++ ch = read()) { ++ } ++ ++ return ch; ++ } ++ ++ protected boolean isWhitespace(int ch) ++ throws IOException ++ { ++ return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; ++ } ++ ++ /** ++ * Reads bytes from the underlying stream. ++ */ ++ int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(); ++ } ++ ++ int read() ++ throws IOException ++ { ++ if (_peek >= 0) { ++ int value = _peek; ++ _peek = -1; ++ return value; ++ } ++ ++ int ch = _is.read(); ++ return ch; ++ } ++ ++ public Reader getReader() ++ { ++ return null; ++ } ++ ++ public InputStream readInputStream() ++ { ++ return null; ++ } ++ ++ public InputStream getInputStream() ++ { ++ return null; ++ } ++ ++ protected IOException expectBeginTag(String expect, String tag) ++ { ++ return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); ++ } ++ ++ protected IOException expectedChar(String expect, int ch) ++ { ++ if (ch < 0) ++ return error("expected " + expect + " at end of file"); ++ else ++ return error("expected " + expect + " at " + (char) ch); ++ } ++ ++ protected IOException expectedTag(String expect, int tag) ++ { ++ return error("expected " + expect + " at " + tagName(tag)); ++ } ++ ++ protected IOException error(String message) ++ { ++ return new BurlapProtocolException(message); ++ } ++ ++ protected static String tagName(int tag) ++ { ++ switch (tag) { ++ case TAG_NULL: ++ return ""; ++ case TAG_NULL_END: ++ return ""; ++ ++ case TAG_BOOLEAN: ++ return ""; ++ case TAG_BOOLEAN_END: ++ return ""; ++ ++ case TAG_INT: ++ return ""; ++ case TAG_INT_END: ++ return ""; ++ ++ case TAG_LONG: ++ return ""; ++ case TAG_LONG_END: ++ return ""; ++ ++ case TAG_DOUBLE: ++ return ""; ++ case TAG_DOUBLE_END: ++ return ""; ++ ++ case TAG_STRING: ++ return ""; ++ case TAG_STRING_END: ++ return ""; ++ ++ case TAG_XML: ++ return ""; ++ case TAG_XML_END: ++ return ""; ++ ++ case TAG_BASE64: ++ return ""; ++ case TAG_BASE64_END: ++ return ""; ++ ++ case TAG_MAP: ++ return ""; ++ case TAG_MAP_END: ++ return ""; ++ ++ case TAG_LIST: ++ return ""; ++ case TAG_LIST_END: ++ return ""; ++ ++ case TAG_TYPE: ++ return ""; ++ case TAG_TYPE_END: ++ return ""; ++ ++ case TAG_LENGTH: ++ return ""; ++ case TAG_LENGTH_END: ++ return ""; ++ ++ case TAG_REF: ++ return ""; ++ case TAG_REF_END: ++ return ""; ++ ++ case TAG_REMOTE: ++ return ""; ++ case TAG_REMOTE_END: ++ return ""; ++ ++ case TAG_CALL: ++ return ""; ++ case TAG_CALL_END: ++ return ""; ++ ++ case TAG_REPLY: ++ return ""; ++ case TAG_REPLY_END: ++ return ""; ++ ++ case TAG_HEADER: ++ return "
"; ++ case TAG_HEADER_END: ++ return "
"; ++ ++ case TAG_FAULT: ++ return ""; ++ case TAG_FAULT_END: ++ return ""; ++ ++ case -1: ++ return "end of file"; ++ ++ default: ++ return "unknown " + tag; ++ } ++ } ++ ++ ++ static { ++ _tagMap = new HashMap(); ++ _tagMap.put("null", new Integer(TAG_NULL)); ++ ++ _tagMap.put("boolean", new Integer(TAG_BOOLEAN)); ++ _tagMap.put("int", new Integer(TAG_INT)); ++ _tagMap.put("long", new Integer(TAG_LONG)); ++ _tagMap.put("double", new Integer(TAG_DOUBLE)); ++ ++ _tagMap.put("date", new Integer(TAG_DATE)); ++ ++ _tagMap.put("string", new Integer(TAG_STRING)); ++ _tagMap.put("xml", new Integer(TAG_XML)); ++ _tagMap.put("base64", new Integer(TAG_BASE64)); ++ ++ _tagMap.put("map", new Integer(TAG_MAP)); ++ _tagMap.put("list", new Integer(TAG_LIST)); ++ ++ _tagMap.put("type", new Integer(TAG_TYPE)); ++ _tagMap.put("length", new Integer(TAG_LENGTH)); ++ ++ _tagMap.put("ref", new Integer(TAG_REF)); ++ _tagMap.put("remote", new Integer(TAG_REMOTE)); ++ ++ _tagMap.put("burlap:call", new Integer(TAG_CALL)); ++ _tagMap.put("burlap:reply", new Integer(TAG_REPLY)); ++ _tagMap.put("fault", new Integer(TAG_FAULT)); ++ _tagMap.put("method", new Integer(TAG_METHOD)); ++ _tagMap.put("header", new Integer(TAG_HEADER)); ++ } ++ ++ static { ++ base64Decode = new int[256]; ++ for (int i = 'A'; i <= 'Z'; i++) ++ base64Decode[i] = i - 'A'; ++ for (int i = 'a'; i <= 'z'; i++) ++ base64Decode[i] = i - 'a' + 26; ++ for (int i = '0'; i <= '9'; i++) ++ base64Decode[i] = i - '0' + 52; ++ base64Decode['+'] = 62; ++ base64Decode['/'] = 63; ++ } ++ ++ private static Field getDetailMessageField() ++ { ++ if (_detailMessageField == null) { ++ try { ++ _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); ++ _detailMessageField.setAccessible(true); ++ } catch (Throwable e) { ++ } ++ } ++ ++ return _detailMessageField; ++ ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapOutput.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapOutput.java +--- hessian-4.0.65-src/com/caucho/burlap/io/BurlapOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,978 +1,978 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import com.caucho.hessian.io.Serializer; +-import com.caucho.hessian.io.SerializerFactory; +- +-import java.io.IOException; +-import java.io.OutputStream; +-import java.util.Calendar; +-import java.util.Date; +-import java.util.IdentityHashMap; +-import java.util.TimeZone; +- +-/** +- * Output stream for Burlap requests, compatible with microedition +- * Java. It only uses classes and types available in JDK. +- * +- *

Since BurlapOutput does not depend on any classes other than +- * in the JDK, it can be extracted independently into a smaller package. +- * +- *

BurlapOutput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * OutputStream os = ...; // from http connection
+- * BurlapOutput out = new BurlapOutput(os);
+- * String value;
+- *
+- * out.startCall("hello");  // start hello call
+- * out.writeString("arg1"); // write a string argument
+- * out.completeCall();      // complete the call
+- * 
+- */ +-public class BurlapOutput extends AbstractBurlapOutput { +- // the output stream +- protected OutputStream os; +- // map of references +- private IdentityHashMap _refs; +- +- private Date date; +- private Calendar utcCalendar; +- private Calendar localCalendar; +- /** +- * Creates a new Burlap output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public BurlapOutput(OutputStream os) +- { +- init(os); +- } +- +- /** +- * Creates an uninitialized Burlap output stream. +- */ +- public BurlapOutput() +- { +- } +- +- /** +- * Initializes the output +- */ +- public void init(OutputStream os) +- { +- this.os = os; +- +- _refs = null; +- +- if (_serializerFactory == null) +- _serializerFactory = new SerializerFactory(); +- } +- +- /** +- * Writes a complete method call. +- */ +- public void call(String method, Object []args) +- throws IOException +- { +- startCall(method); +- +- if (args != null) { +- for (int i = 0; i < args.length; i++) +- writeObject(args[i]); +- } +- +- completeCall(); +- } +- +- /** +- * Starts the method call. Clients would use startCall +- * instead of call if they wanted finer control over +- * writing the arguments, or needed to write headers. +- * +- *
+-   * <burlap:call>
+-   * <method>method-name</method>
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void startCall(String method) +- throws IOException +- { +- print(""); +- print(method); +- print(""); +- } +- +- /** +- * Starts the method call. Clients would use startCall +- * instead of call if they wanted finer control over +- * writing the arguments, or needed to write headers. +- * +- *
+-   * <method>method-name</method>
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void startCall() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Writes the method for a call. +- * +- *
+-   * <method>value</method>
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void writeMethod(String method) +- throws IOException +- { +- print(""); +- print(method); +- print(""); +- } +- +- +- /** +- * Completes. +- * +- *
+-   * </burlap:call>
+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- print("
"); +- } +- +- /** +- * Starts the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * r
+-   * 
+- */ +- public void startReply() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Completes reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * </burlap:reply>
+-   * 
+- */ +- public void completeReply() +- throws IOException +- { +- print("
"); +- } +- +- /** +- * Writes a header name. The header value must immediately follow. +- * +- *
+-   * <header>foo</header><int>value</int>
+-   * 
+- */ +- public void writeHeader(String name) +- throws IOException +- { +- print("
"); +- printString(name); +- print("
"); +- } +- +- /** +- * Writes a fault. The fault will be written +- * as a descriptive string followed by an object: +- * +- *
+-   * <fault>
+-   * <string>code
+-   * <string>the fault code
+-   *
+-   * <string>message
+-   * <string>the fault mesage
+-   *
+-   * <string>detail
+-   * <map>t\x00\xnnjavax.ejb.FinderException
+-   *     ...
+-   * </map>
+-   * </fault>
+-   * 
+- * +- * @param code the fault code, a three digit +- */ +- public void writeFault(String code, String message, Object detail) +- throws IOException +- { +- print(""); +- writeString("code"); +- writeString(code); +- +- writeString("message"); +- writeString(message); +- +- if (detail != null) { +- writeString("detail"); +- writeObject(detail); +- } +- print(""); +- } +- +- /** +- * Writes any object to the output stream. +- */ +- public void writeObject(Object object) +- throws IOException +- { +- if (object == null) { +- writeNull(); +- return; +- } +- +- Serializer serializer; +- +- serializer = _serializerFactory.getSerializer(object.getClass()); +- +- serializer.writeObject(object, this); +- } +- +- /** +- * Writes the list header to the stream. List writers will call +- * writeListBegin followed by the list contents and then +- * call writeListEnd. +- * +- *
+-   * <list>
+-   *   <type>java.util.ArrayList</type>
+-   *   <length>3</length>
+-   *   <int>1</int>
+-   *   <int>2</int>
+-   *   <int>3</int>
+-   * </list>
+-   * 
+- */ +- public boolean writeListBegin(int length, String type) +- throws IOException +- { +- print(""); +- +- if (type != null) +- print(type); +- +- print(""); +- print(length); +- print(""); +- +- return true; +- } +- +- /** +- * Writes the tail of the list to the stream. +- */ +- public void writeListEnd() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Writes the map header to the stream. Map writers will call +- * writeMapBegin followed by the map contents and then +- * call writeMapEnd. +- * +- *
+-   * <map>
+-   *   <type>type</type>
+-   *   (<key> <value>)*
+-   * </map>
+-   * 
+- */ +- public void writeMapBegin(String type) +- throws IOException +- { +- print(""); +- if (type != null) +- print(type); +- +- print(""); +- } +- +- /** +- * Writes the tail of the map to the stream. +- */ +- public void writeMapEnd() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Writes a remote object reference to the stream. The type is the +- * type of the remote interface. +- * +- *
+-   * <remote>
+-   *   <type>test.account.Account</type>
+-   *   <string>http://caucho.com/foo;ejbid=bar</string>
+-   * </remote>
+-   * 
+- */ +- public void writeRemote(String type, String url) +- throws IOException +- { +- print(""); +- print(type); +- print(""); +- print(url); +- print(""); +- } +- +- /** +- * Writes a boolean value to the stream. The boolean will be written +- * with the following syntax: +- * +- *
+-   * <boolean>0</boolean>
+-   * <boolean>1</boolean>
+-   * 
+- * +- * @param value the boolean value to write. +- */ +- public void writeBoolean(boolean value) +- throws IOException +- { +- if (value) +- print("1"); +- else +- print("0"); +- } +- +- /** +- * Writes an integer value to the stream. The integer will be written +- * with the following syntax: +- * +- *
+-   * <int>int value</int>
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeInt(int value) +- throws IOException +- { +- print(""); +- print(value); +- print(""); +- } +- +- /** +- * Writes a long value to the stream. The long will be written +- * with the following syntax: +- * +- *
+-   * <long>int value</long>
+-   * 
+- * +- * @param value the long value to write. +- */ +- public void writeLong(long value) +- throws IOException +- { +- print(""); +- print(value); +- print(""); +- } +- +- /** +- * Writes a double value to the stream. The double will be written +- * with the following syntax: +- * +- *
+-   * <double>value</double>
+-   * 
+- * +- * @param value the double value to write. +- */ +- public void writeDouble(double value) +- throws IOException +- { +- print(""); +- print(value); +- print(""); +- } +- +- /** +- * Writes a date to the stream. +- * +- *
+-   * <date>iso8901</date>
+-   * 
+- * +- * @param time the date in milliseconds from the epoch in UTC +- */ +- public void writeUTCDate(long time) +- throws IOException +- { +- print(""); +- if (utcCalendar == null) { +- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); +- date = new Date(); +- } +- +- date.setTime(time); +- utcCalendar.setTime(date); +- +- printDate(utcCalendar); +- print(""); +- } +- +- /** +- * Writes a null value to the stream. +- * The null will be written with the following syntax +- * +- *
+-   * <null></null>
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeNull() +- throws IOException +- { +- print(""); +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * <string>string-value</string>
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * <null></null>
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(String value) +- throws IOException +- { +- if (value == null) { +- print(""); +- } +- else { +- print(""); +- printString(value); +- print(""); +- } +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(char []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- print(""); +- } +- else { +- print(""); +- printString(buffer, offset, length); +- print(""); +- } +- } +- +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * <base64>bytes</base64>
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * <null></null>
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer) +- throws IOException +- { +- if (buffer == null) +- print(""); +- else +- writeBytes(buffer, 0, buffer.length); +- } +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * <base64>bytes</base64>
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * <null></null>
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- print(""); +- } +- else { +- print(""); +- +- int i = 0; +- for (; i + 2 < length; i += 3) { +- if (i != 0 && (i & 0x3f) == 0) +- print('\n'); +- +- int v = (((buffer[offset + i] & 0xff) << 16) + +- ((buffer[offset + i + 1] & 0xff) << 8) + +- (buffer[offset + i + 2] & 0xff)); +- +- print(encode(v >> 18)); +- print(encode(v >> 12)); +- print(encode(v >> 6)); +- print(encode(v)); +- } +- +- if (i + 1 < length) { +- int v = (((buffer[offset + i] & 0xff) << 8) + +- (buffer[offset + i + 1] & 0xff)); +- +- print(encode(v >> 10)); +- print(encode(v >> 4)); +- print(encode(v << 2)); +- print('='); +- } +- else if (i < length) { +- int v = buffer[offset + i] & 0xff; +- +- print(encode(v >> 2)); +- print(encode(v << 4)); +- print('='); +- print('='); +- } +- +- print(""); +- } +- } +- +- /** +- * Writes a byte buffer to the stream. +- */ +- public void writeByteBufferStart() +- throws IOException +- { +- throw new UnsupportedOperationException(); +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- */ +- public void writeByteBufferPart(byte []buffer, int offset, int length) +- throws IOException +- { +- throw new UnsupportedOperationException(); +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- */ +- public void writeByteBufferEnd(byte []buffer, int offset, int length) +- throws IOException +- { +- throw new UnsupportedOperationException(); +- } +- +- /** +- * Encodes a digit +- */ +- private char encode(int d) +- { +- d &= 0x3f; +- if (d < 26) +- return (char) (d + 'A'); +- else if (d < 52) +- return (char) (d + 'a' - 26); +- else if (d < 62) +- return (char) (d + '0' - 52); +- else if (d == 62) +- return '+'; +- else +- return '/'; +- } +- +- /** +- * Writes a reference. +- * +- *
+-   * <ref>int</ref>
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeRef(int value) +- throws IOException +- { +- print(""); +- print(value); +- print(""); +- } +- +- /** +- * If the object has already been written, just write its ref. +- * +- * @return true if we're writing a ref. +- */ +- public boolean addRef(Object object) +- throws IOException +- { +- if (_refs == null) +- _refs = new IdentityHashMap(); +- +- Integer ref = (Integer) _refs.get(object); +- +- if (ref != null) { +- int value = ref.intValue(); +- +- writeRef(value); +- return true; +- } +- else { +- _refs.put(object, new Integer(_refs.size())); +- +- return false; +- } +- } +- +- @Override +- public int getRef(Object obj) +- { +- if (_refs == null) +- return -1; +- +- Integer ref = (Integer) _refs.get(obj); +- +- if (ref != null) +- return ref; +- else +- return -1; +- } +- +- /** +- * Removes a reference. +- */ +- public boolean removeRef(Object obj) +- throws IOException +- { +- if (_refs != null) { +- _refs.remove(obj); +- +- return true; +- } +- else +- return false; +- } +- +- /** +- * Replaces a reference from one object to another. +- */ +- public boolean replaceRef(Object oldRef, Object newRef) +- throws IOException +- { +- Integer value = (Integer) _refs.remove(oldRef); +- +- if (value != null) { +- _refs.put(newRef, value); +- return true; +- } +- else +- return false; +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v) +- throws IOException +- { +- printString(v, 0, v.length()); +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v, int offset, int length) +- throws IOException +- { +- for (int i = 0; i < length; i++) { +- char ch = v.charAt(i + offset); +- +- if (ch == '<') { +- os.write('&'); +- os.write('#'); +- os.write('6'); +- os.write('0'); +- os.write(';'); +- } +- else if (ch == '&') { +- os.write('&'); +- os.write('#'); +- os.write('3'); +- os.write('8'); +- os.write(';'); +- } +- else if (ch < 0x80) +- os.write(ch); +- else if (ch < 0x800) { +- os.write(0xc0 + ((ch >> 6) & 0x1f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- else { +- os.write(0xe0 + ((ch >> 12) & 0xf)); +- os.write(0x80 + ((ch >> 6) & 0x3f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- } +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(char []v, int offset, int length) +- throws IOException +- { +- for (int i = 0; i < length; i++) { +- char ch = v[i + offset]; +- +- if (ch < 0x80) +- os.write(ch); +- else if (ch < 0x800) { +- os.write(0xc0 + ((ch >> 6) & 0x1f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- else { +- os.write(0xe0 + ((ch >> 12) & 0xf)); +- os.write(0x80 + ((ch >> 6) & 0x3f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- } +- } +- +- /** +- * Prints a date. +- * +- * @param date the date to print. +- */ +- public void printDate(Calendar calendar) +- throws IOException +- { +- int year = calendar.get(Calendar.YEAR); +- +- os.write((char) ('0' + (year / 1000 % 10))); +- os.write((char) ('0' + (year / 100 % 10))); +- os.write((char) ('0' + (year / 10 % 10))); +- os.write((char) ('0' + (year % 10))); +- +- int month = calendar.get(Calendar.MONTH) + 1; +- os.write((char) ('0' + (month / 10 % 10))); +- os.write((char) ('0' + (month % 10))); +- +- int day = calendar.get(Calendar.DAY_OF_MONTH); +- os.write((char) ('0' + (day / 10 % 10))); +- os.write((char) ('0' + (day % 10))); +- +- os.write('T'); +- +- int hour = calendar.get(Calendar.HOUR_OF_DAY); +- os.write((char) ('0' + (hour / 10 % 10))); +- os.write((char) ('0' + (hour % 10))); +- +- int minute = calendar.get(Calendar.MINUTE); +- os.write((char) ('0' + (minute / 10 % 10))); +- os.write((char) ('0' + (minute % 10))); +- +- int second = calendar.get(Calendar.SECOND); +- os.write((char) ('0' + (second / 10 % 10))); +- os.write((char) ('0' + (second % 10))); +- +- int ms = calendar.get(Calendar.MILLISECOND); +- os.write('.'); +- os.write((char) ('0' + (ms / 100 % 10))); +- os.write((char) ('0' + (ms / 10 % 10))); +- os.write((char) ('0' + (ms % 10))); +- +- os.write('Z'); +- } +- +- /** +- * Prints a char to the stream. +- * +- * @param v the char to print. +- */ +- protected void print(char v) +- throws IOException +- { +- os.write(v); +- } +- +- /** +- * Prints an integer to the stream. +- * +- * @param v the integer to print. +- */ +- protected void print(int v) +- throws IOException +- { +- print(String.valueOf(v)); +- } +- +- /** +- * Prints a long to the stream. +- * +- * @param v the long to print. +- */ +- protected void print(long v) +- throws IOException +- { +- print(String.valueOf(v)); +- } +- +- /** +- * Prints a double to the stream. +- * +- * @param v the double to print. +- */ +- protected void print(double v) +- throws IOException +- { +- print(String.valueOf(v)); +- } +- +- /** +- * Prints a string as ascii to the stream. Used for tags, etc. +- * that are known to the ascii. +- * +- * @param s the ascii string to print. +- */ +- protected void print(String s) +- throws IOException +- { +- int len = s.length(); +- for (int i = 0; i < len; i++) { +- int ch = s.charAt(i); +- +- os.write(ch); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import com.caucho.hessian.io.Serializer; ++import com.caucho.hessian.io.SerializerFactory; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++import java.util.Calendar; ++import java.util.Date; ++import java.util.IdentityHashMap; ++import java.util.TimeZone; ++ ++/** ++ * Output stream for Burlap requests, compatible with microedition ++ * Java. It only uses classes and types available in JDK. ++ * ++ *

Since BurlapOutput does not depend on any classes other than ++ * in the JDK, it can be extracted independently into a smaller package. ++ * ++ *

BurlapOutput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * OutputStream os = ...; // from http connection
++ * BurlapOutput out = new BurlapOutput(os);
++ * String value;
++ *
++ * out.startCall("hello");  // start hello call
++ * out.writeString("arg1"); // write a string argument
++ * out.completeCall();      // complete the call
++ * 
++ */ ++public class BurlapOutput extends AbstractBurlapOutput { ++ // the output stream ++ protected OutputStream os; ++ // map of references ++ private IdentityHashMap _refs; ++ ++ private Date date; ++ private Calendar utcCalendar; ++ private Calendar localCalendar; ++ /** ++ * Creates a new Burlap output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public BurlapOutput(OutputStream os) ++ { ++ init(os); ++ } ++ ++ /** ++ * Creates an uninitialized Burlap output stream. ++ */ ++ public BurlapOutput() ++ { ++ } ++ ++ /** ++ * Initializes the output ++ */ ++ public void init(OutputStream os) ++ { ++ this.os = os; ++ ++ _refs = null; ++ ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(); ++ } ++ ++ /** ++ * Writes a complete method call. ++ */ ++ public void call(String method, Object []args) ++ throws IOException ++ { ++ startCall(method); ++ ++ if (args != null) { ++ for (int i = 0; i < args.length; i++) ++ writeObject(args[i]); ++ } ++ ++ completeCall(); ++ } ++ ++ /** ++ * Starts the method call. Clients would use startCall ++ * instead of call if they wanted finer control over ++ * writing the arguments, or needed to write headers. ++ * ++ *
++   * <burlap:call>
++   * <method>method-name</method>
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void startCall(String method) ++ throws IOException ++ { ++ print(""); ++ print(method); ++ print(""); ++ } ++ ++ /** ++ * Starts the method call. Clients would use startCall ++ * instead of call if they wanted finer control over ++ * writing the arguments, or needed to write headers. ++ * ++ *
++   * <method>method-name</method>
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void startCall() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Writes the method for a call. ++ * ++ *
++   * <method>value</method>
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void writeMethod(String method) ++ throws IOException ++ { ++ print(""); ++ print(method); ++ print(""); ++ } ++ ++ ++ /** ++ * Completes. ++ * ++ *
++   * </burlap:call>
++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ print("
"); ++ } ++ ++ /** ++ * Starts the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * r
++   * 
++ */ ++ public void startReply() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Completes reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * </burlap:reply>
++   * 
++ */ ++ public void completeReply() ++ throws IOException ++ { ++ print("
"); ++ } ++ ++ /** ++ * Writes a header name. The header value must immediately follow. ++ * ++ *
++   * <header>foo</header><int>value</int>
++   * 
++ */ ++ public void writeHeader(String name) ++ throws IOException ++ { ++ print("
"); ++ printString(name); ++ print("
"); ++ } ++ ++ /** ++ * Writes a fault. The fault will be written ++ * as a descriptive string followed by an object: ++ * ++ *
++   * <fault>
++   * <string>code
++   * <string>the fault code
++   *
++   * <string>message
++   * <string>the fault mesage
++   *
++   * <string>detail
++   * <map>t\x00\xnnjavax.ejb.FinderException
++   *     ...
++   * </map>
++   * </fault>
++   * 
++ * ++ * @param code the fault code, a three digit ++ */ ++ public void writeFault(String code, String message, Object detail) ++ throws IOException ++ { ++ print(""); ++ writeString("code"); ++ writeString(code); ++ ++ writeString("message"); ++ writeString(message); ++ ++ if (detail != null) { ++ writeString("detail"); ++ writeObject(detail); ++ } ++ print(""); ++ } ++ ++ /** ++ * Writes any object to the output stream. ++ */ ++ public void writeObject(Object object) ++ throws IOException ++ { ++ if (object == null) { ++ writeNull(); ++ return; ++ } ++ ++ Serializer serializer; ++ ++ serializer = _serializerFactory.getSerializer(object.getClass()); ++ ++ serializer.writeObject(object, this); ++ } ++ ++ /** ++ * Writes the list header to the stream. List writers will call ++ * writeListBegin followed by the list contents and then ++ * call writeListEnd. ++ * ++ *
++   * <list>
++   *   <type>java.util.ArrayList</type>
++   *   <length>3</length>
++   *   <int>1</int>
++   *   <int>2</int>
++   *   <int>3</int>
++   * </list>
++   * 
++ */ ++ public boolean writeListBegin(int length, String type) ++ throws IOException ++ { ++ print(""); ++ ++ if (type != null) ++ print(type); ++ ++ print(""); ++ print(length); ++ print(""); ++ ++ return true; ++ } ++ ++ /** ++ * Writes the tail of the list to the stream. ++ */ ++ public void writeListEnd() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Writes the map header to the stream. Map writers will call ++ * writeMapBegin followed by the map contents and then ++ * call writeMapEnd. ++ * ++ *
++   * <map>
++   *   <type>type</type>
++   *   (<key> <value>)*
++   * </map>
++   * 
++ */ ++ public void writeMapBegin(String type) ++ throws IOException ++ { ++ print(""); ++ if (type != null) ++ print(type); ++ ++ print(""); ++ } ++ ++ /** ++ * Writes the tail of the map to the stream. ++ */ ++ public void writeMapEnd() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Writes a remote object reference to the stream. The type is the ++ * type of the remote interface. ++ * ++ *
++   * <remote>
++   *   <type>test.account.Account</type>
++   *   <string>http://caucho.com/foo;ejbid=bar</string>
++   * </remote>
++   * 
++ */ ++ public void writeRemote(String type, String url) ++ throws IOException ++ { ++ print(""); ++ print(type); ++ print(""); ++ print(url); ++ print(""); ++ } ++ ++ /** ++ * Writes a boolean value to the stream. The boolean will be written ++ * with the following syntax: ++ * ++ *
++   * <boolean>0</boolean>
++   * <boolean>1</boolean>
++   * 
++ * ++ * @param value the boolean value to write. ++ */ ++ public void writeBoolean(boolean value) ++ throws IOException ++ { ++ if (value) ++ print("1"); ++ else ++ print("0"); ++ } ++ ++ /** ++ * Writes an integer value to the stream. The integer will be written ++ * with the following syntax: ++ * ++ *
++   * <int>int value</int>
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeInt(int value) ++ throws IOException ++ { ++ print(""); ++ print(value); ++ print(""); ++ } ++ ++ /** ++ * Writes a long value to the stream. The long will be written ++ * with the following syntax: ++ * ++ *
++   * <long>int value</long>
++   * 
++ * ++ * @param value the long value to write. ++ */ ++ public void writeLong(long value) ++ throws IOException ++ { ++ print(""); ++ print(value); ++ print(""); ++ } ++ ++ /** ++ * Writes a double value to the stream. The double will be written ++ * with the following syntax: ++ * ++ *
++   * <double>value</double>
++   * 
++ * ++ * @param value the double value to write. ++ */ ++ public void writeDouble(double value) ++ throws IOException ++ { ++ print(""); ++ print(value); ++ print(""); ++ } ++ ++ /** ++ * Writes a date to the stream. ++ * ++ *
++   * <date>iso8901</date>
++   * 
++ * ++ * @param time the date in milliseconds from the epoch in UTC ++ */ ++ public void writeUTCDate(long time) ++ throws IOException ++ { ++ print(""); ++ if (utcCalendar == null) { ++ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); ++ date = new Date(); ++ } ++ ++ date.setTime(time); ++ utcCalendar.setTime(date); ++ ++ printDate(utcCalendar); ++ print(""); ++ } ++ ++ /** ++ * Writes a null value to the stream. ++ * The null will be written with the following syntax ++ * ++ *
++   * <null></null>
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeNull() ++ throws IOException ++ { ++ print(""); ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * <string>string-value</string>
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * <null></null>
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(String value) ++ throws IOException ++ { ++ if (value == null) { ++ print(""); ++ } ++ else { ++ print(""); ++ printString(value); ++ print(""); ++ } ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(char []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ print(""); ++ } ++ else { ++ print(""); ++ printString(buffer, offset, length); ++ print(""); ++ } ++ } ++ ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * <base64>bytes</base64>
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * <null></null>
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer) ++ throws IOException ++ { ++ if (buffer == null) ++ print(""); ++ else ++ writeBytes(buffer, 0, buffer.length); ++ } ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * <base64>bytes</base64>
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * <null></null>
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ print(""); ++ } ++ else { ++ print(""); ++ ++ int i = 0; ++ for (; i + 2 < length; i += 3) { ++ if (i != 0 && (i & 0x3f) == 0) ++ print('\n'); ++ ++ int v = (((buffer[offset + i] & 0xff) << 16) + ++ ((buffer[offset + i + 1] & 0xff) << 8) + ++ (buffer[offset + i + 2] & 0xff)); ++ ++ print(encode(v >> 18)); ++ print(encode(v >> 12)); ++ print(encode(v >> 6)); ++ print(encode(v)); ++ } ++ ++ if (i + 1 < length) { ++ int v = (((buffer[offset + i] & 0xff) << 8) + ++ (buffer[offset + i + 1] & 0xff)); ++ ++ print(encode(v >> 10)); ++ print(encode(v >> 4)); ++ print(encode(v << 2)); ++ print('='); ++ } ++ else if (i < length) { ++ int v = buffer[offset + i] & 0xff; ++ ++ print(encode(v >> 2)); ++ print(encode(v << 4)); ++ print('='); ++ print('='); ++ } ++ ++ print(""); ++ } ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ */ ++ public void writeByteBufferStart() ++ throws IOException ++ { ++ throw new UnsupportedOperationException(); ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ */ ++ public void writeByteBufferPart(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(); ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ */ ++ public void writeByteBufferEnd(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(); ++ } ++ ++ /** ++ * Encodes a digit ++ */ ++ private char encode(int d) ++ { ++ d &= 0x3f; ++ if (d < 26) ++ return (char) (d + 'A'); ++ else if (d < 52) ++ return (char) (d + 'a' - 26); ++ else if (d < 62) ++ return (char) (d + '0' - 52); ++ else if (d == 62) ++ return '+'; ++ else ++ return '/'; ++ } ++ ++ /** ++ * Writes a reference. ++ * ++ *
++   * <ref>int</ref>
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeRef(int value) ++ throws IOException ++ { ++ print(""); ++ print(value); ++ print(""); ++ } ++ ++ /** ++ * If the object has already been written, just write its ref. ++ * ++ * @return true if we're writing a ref. ++ */ ++ public boolean addRef(Object object) ++ throws IOException ++ { ++ if (_refs == null) ++ _refs = new IdentityHashMap(); ++ ++ Integer ref = (Integer) _refs.get(object); ++ ++ if (ref != null) { ++ int value = ref.intValue(); ++ ++ writeRef(value); ++ return true; ++ } ++ else { ++ _refs.put(object, new Integer(_refs.size())); ++ ++ return false; ++ } ++ } ++ ++ @Override ++ public int getRef(Object obj) ++ { ++ if (_refs == null) ++ return -1; ++ ++ Integer ref = (Integer) _refs.get(obj); ++ ++ if (ref != null) ++ return ref; ++ else ++ return -1; ++ } ++ ++ /** ++ * Removes a reference. ++ */ ++ public boolean removeRef(Object obj) ++ throws IOException ++ { ++ if (_refs != null) { ++ _refs.remove(obj); ++ ++ return true; ++ } ++ else ++ return false; ++ } ++ ++ /** ++ * Replaces a reference from one object to another. ++ */ ++ public boolean replaceRef(Object oldRef, Object newRef) ++ throws IOException ++ { ++ Integer value = (Integer) _refs.remove(oldRef); ++ ++ if (value != null) { ++ _refs.put(newRef, value); ++ return true; ++ } ++ else ++ return false; ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v) ++ throws IOException ++ { ++ printString(v, 0, v.length()); ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v, int offset, int length) ++ throws IOException ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = v.charAt(i + offset); ++ ++ if (ch == '<') { ++ os.write('&'); ++ os.write('#'); ++ os.write('6'); ++ os.write('0'); ++ os.write(';'); ++ } ++ else if (ch == '&') { ++ os.write('&'); ++ os.write('#'); ++ os.write('3'); ++ os.write('8'); ++ os.write(';'); ++ } ++ else if (ch < 0x80) ++ os.write(ch); ++ else if (ch < 0x800) { ++ os.write(0xc0 + ((ch >> 6) & 0x1f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ else { ++ os.write(0xe0 + ((ch >> 12) & 0xf)); ++ os.write(0x80 + ((ch >> 6) & 0x3f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ } ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(char []v, int offset, int length) ++ throws IOException ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = v[i + offset]; ++ ++ if (ch < 0x80) ++ os.write(ch); ++ else if (ch < 0x800) { ++ os.write(0xc0 + ((ch >> 6) & 0x1f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ else { ++ os.write(0xe0 + ((ch >> 12) & 0xf)); ++ os.write(0x80 + ((ch >> 6) & 0x3f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ } ++ } ++ ++ /** ++ * Prints a date. ++ * ++ * @param date the date to print. ++ */ ++ public void printDate(Calendar calendar) ++ throws IOException ++ { ++ int year = calendar.get(Calendar.YEAR); ++ ++ os.write((char) ('0' + (year / 1000 % 10))); ++ os.write((char) ('0' + (year / 100 % 10))); ++ os.write((char) ('0' + (year / 10 % 10))); ++ os.write((char) ('0' + (year % 10))); ++ ++ int month = calendar.get(Calendar.MONTH) + 1; ++ os.write((char) ('0' + (month / 10 % 10))); ++ os.write((char) ('0' + (month % 10))); ++ ++ int day = calendar.get(Calendar.DAY_OF_MONTH); ++ os.write((char) ('0' + (day / 10 % 10))); ++ os.write((char) ('0' + (day % 10))); ++ ++ os.write('T'); ++ ++ int hour = calendar.get(Calendar.HOUR_OF_DAY); ++ os.write((char) ('0' + (hour / 10 % 10))); ++ os.write((char) ('0' + (hour % 10))); ++ ++ int minute = calendar.get(Calendar.MINUTE); ++ os.write((char) ('0' + (minute / 10 % 10))); ++ os.write((char) ('0' + (minute % 10))); ++ ++ int second = calendar.get(Calendar.SECOND); ++ os.write((char) ('0' + (second / 10 % 10))); ++ os.write((char) ('0' + (second % 10))); ++ ++ int ms = calendar.get(Calendar.MILLISECOND); ++ os.write('.'); ++ os.write((char) ('0' + (ms / 100 % 10))); ++ os.write((char) ('0' + (ms / 10 % 10))); ++ os.write((char) ('0' + (ms % 10))); ++ ++ os.write('Z'); ++ } ++ ++ /** ++ * Prints a char to the stream. ++ * ++ * @param v the char to print. ++ */ ++ protected void print(char v) ++ throws IOException ++ { ++ os.write(v); ++ } ++ ++ /** ++ * Prints an integer to the stream. ++ * ++ * @param v the integer to print. ++ */ ++ protected void print(int v) ++ throws IOException ++ { ++ print(String.valueOf(v)); ++ } ++ ++ /** ++ * Prints a long to the stream. ++ * ++ * @param v the long to print. ++ */ ++ protected void print(long v) ++ throws IOException ++ { ++ print(String.valueOf(v)); ++ } ++ ++ /** ++ * Prints a double to the stream. ++ * ++ * @param v the double to print. ++ */ ++ protected void print(double v) ++ throws IOException ++ { ++ print(String.valueOf(v)); ++ } ++ ++ /** ++ * Prints a string as ascii to the stream. Used for tags, etc. ++ * that are known to the ascii. ++ * ++ * @param s the ascii string to print. ++ */ ++ protected void print(String s) ++ throws IOException ++ { ++ int len = s.length(); ++ for (int i = 0; i < len; i++) { ++ int ch = s.charAt(i); ++ ++ os.write(ch); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapProtocolException.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapProtocolException.java +--- hessian-4.0.65-src/com/caucho/burlap/io/BurlapProtocolException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapProtocolException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,88 +1,88 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import com.caucho.hessian.io.HessianProtocolException; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroBurlapInput. +- */ +-public class BurlapProtocolException extends HessianProtocolException { +- /** +- * Zero-arg constructor. +- */ +- public BurlapProtocolException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public BurlapProtocolException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public BurlapProtocolException(String message, Throwable rootCause) +- { +- super(message, rootCause); +- } +- +- /** +- * Create the exception. +- */ +- public BurlapProtocolException(Throwable rootCause) +- { +- super(rootCause); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import com.caucho.hessian.io.HessianProtocolException; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroBurlapInput. ++ */ ++public class BurlapProtocolException extends HessianProtocolException { ++ /** ++ * Zero-arg constructor. ++ */ ++ public BurlapProtocolException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapProtocolException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapProtocolException(String message, Throwable rootCause) ++ { ++ super(message, rootCause); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapProtocolException(Throwable rootCause) ++ { ++ super(rootCause); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemote.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemote.java +--- hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemote.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemote.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,130 +1,130 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-/** +- * Encapsulates a remote address when no stub is available, e.g. for +- * Java MicroEdition. +- */ +-public class BurlapRemote { +- private String type; +- private String url; +- +- /** +- * Creates a new Burlap remote object. +- * +- * @param type the remote stub interface +- * @param url the remote url +- */ +- public BurlapRemote(String type, String url) +- { +- this.type = type; +- this.url = url; +- } +- +- /** +- * Creates an uninitialized Burlap remote. +- */ +- public BurlapRemote() +- { +- } +- +- /** +- * Returns the remote api class name. +- */ +- public String getType() +- { +- return this.type; +- } +- +- /** +- * Returns the remote URL. +- */ +- public String getURL() +- { +- return this.url; +- } +- +- /** +- * Sets the remote URL. +- */ +- public void setURL(String url) +- { +- this.url = url; +- } +- +- /** +- * Defines the hashcode. +- */ +- public int hashCode() +- { +- return this.url.hashCode(); +- } +- +- /** +- * Defines equality +- */ +- public boolean equals(Object obj) +- { +- if (! (obj instanceof BurlapRemote)) +- return false; +- +- BurlapRemote remote = (BurlapRemote) obj; +- +- return this.url.equals(remote.url); +- } +- +- /** +- * Readable version of the remote. +- */ +- public String toString() +- { +- return "[BurlapRemote " + this.url + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++/** ++ * Encapsulates a remote address when no stub is available, e.g. for ++ * Java MicroEdition. ++ */ ++public class BurlapRemote { ++ private String type; ++ private String url; ++ ++ /** ++ * Creates a new Burlap remote object. ++ * ++ * @param type the remote stub interface ++ * @param url the remote url ++ */ ++ public BurlapRemote(String type, String url) ++ { ++ this.type = type; ++ this.url = url; ++ } ++ ++ /** ++ * Creates an uninitialized Burlap remote. ++ */ ++ public BurlapRemote() ++ { ++ } ++ ++ /** ++ * Returns the remote api class name. ++ */ ++ public String getType() ++ { ++ return this.type; ++ } ++ ++ /** ++ * Returns the remote URL. ++ */ ++ public String getURL() ++ { ++ return this.url; ++ } ++ ++ /** ++ * Sets the remote URL. ++ */ ++ public void setURL(String url) ++ { ++ this.url = url; ++ } ++ ++ /** ++ * Defines the hashcode. ++ */ ++ public int hashCode() ++ { ++ return this.url.hashCode(); ++ } ++ ++ /** ++ * Defines equality ++ */ ++ public boolean equals(Object obj) ++ { ++ if (! (obj instanceof BurlapRemote)) ++ return false; ++ ++ BurlapRemote remote = (BurlapRemote) obj; ++ ++ return this.url.equals(remote.url); ++ } ++ ++ /** ++ * Readable version of the remote. ++ */ ++ public String toString() ++ { ++ return "[BurlapRemote " + this.url + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteObject.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteObject.java +--- hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteObject.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteObject.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,57 +1,57 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-/** +- * Interface for any burlap remote object. +- */ +-public interface BurlapRemoteObject { +- public String getBurlapType(); +- public String getBurlapURL(); +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++/** ++ * Interface for any burlap remote object. ++ */ ++public interface BurlapRemoteObject { ++ public String getBurlapType(); ++ public String getBurlapURL(); ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteResolver.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteResolver.java +--- hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteResolver.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteResolver.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,63 +1,63 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import com.caucho.hessian.io.HessianRemoteResolver; +- +-import java.io.IOException; +-/** +- * Looks up remote objects. The default just returns a BurlapRemote object. +- */ +-public interface BurlapRemoteResolver extends HessianRemoteResolver { +- /** +- * Looks up a proxy object. +- */ +- public Object lookup(String type, String url) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import com.caucho.hessian.io.HessianRemoteResolver; ++ ++import java.io.IOException; ++/** ++ * Looks up remote objects. The default just returns a BurlapRemote object. ++ */ ++public interface BurlapRemoteResolver extends HessianRemoteResolver { ++ /** ++ * Looks up a proxy object. ++ */ ++ public Object lookup(String type, String url) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapServiceException.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapServiceException.java +--- hessian-4.0.65-src/com/caucho/burlap/io/BurlapServiceException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapServiceException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,72 +1,72 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.io; +- +-import com.caucho.hessian.io.HessianServiceException; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroBurlapInput. +- */ +-public class BurlapServiceException extends HessianServiceException { +- /** +- * Zero-arg constructor. +- */ +- public BurlapServiceException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public BurlapServiceException(String message, String code, Object detail) +- { +- super(message, code, detail); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.io; ++ ++import com.caucho.hessian.io.HessianServiceException; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroBurlapInput. ++ */ ++public class BurlapServiceException extends HessianServiceException { ++ /** ++ * Zero-arg constructor. ++ */ ++ public BurlapServiceException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public BurlapServiceException(String message, String code, Object detail) ++ { ++ super(message, code, detail); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/server/BurlapServlet.java hessian-4.0.65-fix/com/caucho/burlap/server/BurlapServlet.java +--- hessian-4.0.65-src/com/caucho/burlap/server/BurlapServlet.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/server/BurlapServlet.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,205 +1,205 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.server; +- +-import com.caucho.burlap.io.BurlapInput; +-import com.caucho.burlap.io.BurlapOutput; +-import com.caucho.services.server.Service; +-import com.caucho.services.server.ServiceContext; +- +-import javax.servlet.GenericServlet; +-import javax.servlet.Servlet; +-import javax.servlet.ServletConfig; +-import javax.servlet.ServletException; +-import javax.servlet.ServletRequest; +-import javax.servlet.ServletResponse; +-import javax.servlet.http.HttpServletRequest; +-import javax.servlet.http.HttpServletResponse; +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.PrintWriter; +- +-/** +- * Servlet for serving Burlap services. +- */ +-public class BurlapServlet extends GenericServlet { +- private Class _apiClass; +- private Object _service; +- +- private BurlapSkeleton _skeleton; +- +- public String getServletInfo() +- { +- return "Burlap Servlet"; +- } +- +- /** +- * Sets the service class. +- */ +- public void setService(Object service) +- { +- _service = service; +- } +- +- /** +- * Sets the api-class. +- */ +- public void setAPIClass(Class apiClass) +- { +- _apiClass = apiClass; +- } +- +- /** +- * Initialize the service, including the service object. +- */ +- public void init(ServletConfig config) +- throws ServletException +- { +- super.init(config); +- +- try { +- if (_service == null) { +- String className = getInitParameter("service-class"); +- Class serviceClass = null; +- +- if (className != null) { +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- +- if (loader != null) +- serviceClass = Class.forName(className, false, loader); +- else +- serviceClass = Class.forName(className); +- } +- else { +- if (getClass().equals(BurlapServlet.class)) +- throw new ServletException("server must extend BurlapServlet"); +- +- serviceClass = getClass(); +- } +- +- _service = serviceClass.newInstance(); +- +- if (_service instanceof BurlapServlet) +- ((BurlapServlet) _service).setService(this); +- if (_service instanceof Service) +- ((Service) _service).init(getServletConfig()); +- else if (_service instanceof Servlet) +- ((Servlet) _service).init(getServletConfig()); +- } +- +- if (_apiClass == null) { +- String className = getInitParameter("api-class"); +- +- if (className != null) { +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- +- if (loader != null) +- _apiClass = Class.forName(className, false, loader); +- else +- _apiClass = Class.forName(className); +- } +- else +- _apiClass = _service.getClass(); +- } +- +- _skeleton = new BurlapSkeleton(_service, _apiClass); +- } catch (ServletException e) { +- throw e; +- } catch (Exception e) { +- throw new ServletException(e); +- } +- } +- +- /** +- * Execute a request. The path-info of the request selects the bean. +- * Once the bean's selected, it will be applied. +- */ +- public void service(ServletRequest request, ServletResponse response) +- throws IOException, ServletException +- { +- HttpServletRequest req = (HttpServletRequest) request; +- HttpServletResponse res = (HttpServletResponse) response; +- +- if (! req.getMethod().equals("POST")) { +- res.setStatus(500, "Burlap Requires POST"); +- PrintWriter out = res.getWriter(); +- +- res.setContentType("text/html"); +- out.println("

Burlap Requires POST

"); +- +- return; +- } +- +- String serviceId = req.getPathInfo(); +- String objectId = req.getParameter("id"); +- if (objectId == null) +- objectId = req.getParameter("ejbid"); +- +- ServiceContext.begin(req, res, serviceId, objectId); +- +- try { +- InputStream is = request.getInputStream(); +- OutputStream os = response.getOutputStream(); +- +- BurlapInput in = new BurlapInput(is); +- BurlapOutput out = new BurlapOutput(os); +- +- _skeleton.invoke(in, out); +- } catch (RuntimeException e) { +- throw e; +- } catch (ServletException e) { +- throw e; +- } catch (Throwable e) { +- throw new ServletException(e); +- } finally { +- ServiceContext.end(); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.server; ++ ++import com.caucho.burlap.io.BurlapInput; ++import com.caucho.burlap.io.BurlapOutput; ++import com.caucho.services.server.Service; ++import com.caucho.services.server.ServiceContext; ++ ++import javax.servlet.GenericServlet; ++import javax.servlet.Servlet; ++import javax.servlet.ServletConfig; ++import javax.servlet.ServletException; ++import javax.servlet.ServletRequest; ++import javax.servlet.ServletResponse; ++import javax.servlet.http.HttpServletRequest; ++import javax.servlet.http.HttpServletResponse; ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.PrintWriter; ++ ++/** ++ * Servlet for serving Burlap services. ++ */ ++public class BurlapServlet extends GenericServlet { ++ private Class _apiClass; ++ private Object _service; ++ ++ private BurlapSkeleton _skeleton; ++ ++ public String getServletInfo() ++ { ++ return "Burlap Servlet"; ++ } ++ ++ /** ++ * Sets the service class. ++ */ ++ public void setService(Object service) ++ { ++ _service = service; ++ } ++ ++ /** ++ * Sets the api-class. ++ */ ++ public void setAPIClass(Class apiClass) ++ { ++ _apiClass = apiClass; ++ } ++ ++ /** ++ * Initialize the service, including the service object. ++ */ ++ public void init(ServletConfig config) ++ throws ServletException ++ { ++ super.init(config); ++ ++ try { ++ if (_service == null) { ++ String className = getInitParameter("service-class"); ++ Class serviceClass = null; ++ ++ if (className != null) { ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ if (loader != null) ++ serviceClass = Class.forName(className, false, loader); ++ else ++ serviceClass = Class.forName(className); ++ } ++ else { ++ if (getClass().equals(BurlapServlet.class)) ++ throw new ServletException("server must extend BurlapServlet"); ++ ++ serviceClass = getClass(); ++ } ++ ++ _service = serviceClass.newInstance(); ++ ++ if (_service instanceof BurlapServlet) ++ ((BurlapServlet) _service).setService(this); ++ if (_service instanceof Service) ++ ((Service) _service).init(getServletConfig()); ++ else if (_service instanceof Servlet) ++ ((Servlet) _service).init(getServletConfig()); ++ } ++ ++ if (_apiClass == null) { ++ String className = getInitParameter("api-class"); ++ ++ if (className != null) { ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ if (loader != null) ++ _apiClass = Class.forName(className, false, loader); ++ else ++ _apiClass = Class.forName(className); ++ } ++ else ++ _apiClass = _service.getClass(); ++ } ++ ++ _skeleton = new BurlapSkeleton(_service, _apiClass); ++ } catch (ServletException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new ServletException(e); ++ } ++ } ++ ++ /** ++ * Execute a request. The path-info of the request selects the bean. ++ * Once the bean's selected, it will be applied. ++ */ ++ public void service(ServletRequest request, ServletResponse response) ++ throws IOException, ServletException ++ { ++ HttpServletRequest req = (HttpServletRequest) request; ++ HttpServletResponse res = (HttpServletResponse) response; ++ ++ if (! req.getMethod().equals("POST")) { ++ res.setStatus(500, "Burlap Requires POST"); ++ PrintWriter out = res.getWriter(); ++ ++ res.setContentType("text/html"); ++ out.println("

Burlap Requires POST

"); ++ ++ return; ++ } ++ ++ String serviceId = req.getPathInfo(); ++ String objectId = req.getParameter("id"); ++ if (objectId == null) ++ objectId = req.getParameter("ejbid"); ++ ++ ServiceContext.begin(req, res, serviceId, objectId); ++ ++ try { ++ InputStream is = request.getInputStream(); ++ OutputStream os = response.getOutputStream(); ++ ++ BurlapInput in = new BurlapInput(is); ++ BurlapOutput out = new BurlapOutput(os); ++ ++ _skeleton.invoke(in, out); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (ServletException e) { ++ throw e; ++ } catch (Throwable e) { ++ throw new ServletException(e); ++ } finally { ++ ServiceContext.end(); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/burlap/server/BurlapSkeleton.java hessian-4.0.65-fix/com/caucho/burlap/server/BurlapSkeleton.java +--- hessian-4.0.65-src/com/caucho/burlap/server/BurlapSkeleton.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/burlap/server/BurlapSkeleton.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,195 +1,195 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.burlap.server; +- +-import com.caucho.burlap.io.BurlapInput; +-import com.caucho.burlap.io.BurlapOutput; +-import com.caucho.services.server.AbstractSkeleton; +-import com.caucho.services.server.ServiceContext; +- +-import java.lang.reflect.InvocationTargetException; +-import java.lang.reflect.Method; +-import java.util.logging.*; +- +-/** +- * Proxy class for Burlap services. +- */ +-public class BurlapSkeleton extends AbstractSkeleton { +- private static final Logger log +- = Logger.getLogger(BurlapSkeleton.class.getName()); +- +- private Object _service; +- +- /** +- * Create a new burlap skeleton. +- * +- * @param service the underlying service object. +- * @param apiClass the API interface +- */ +- public BurlapSkeleton(Object service, Class apiClass) +- { +- super(apiClass); +- +- _service = service; +- } +- +- /** +- * Create a new burlap skeleton. +- * +- * @param service the underlying service object. +- * @param apiClass the API interface +- */ +- public BurlapSkeleton(Class apiClass) +- { +- super(apiClass); +- } +- +- /** +- * Invoke the object with the request from the input stream. +- * +- * @param in the Burlap input stream +- * @param out the Burlap output stream +- */ +- public void invoke(BurlapInput in, BurlapOutput out) +- throws Exception +- { +- invoke(_service, in, out); +- } +- +- /** +- * Invoke the object with the request from the input stream. +- * +- * @param in the Burlap input stream +- * @param out the Burlap output stream +- */ +- public void invoke(Object service, BurlapInput in, BurlapOutput out) +- throws Exception +- { +- in.readCall(); +- +- ServiceContext context = ServiceContext.getContext(); +- +- String header; +- while ((header = in.readHeader()) != null) { +- Object value = in.readObject(); +- +- context.addHeader(header, value); +- } +- +- String methodName = in.readMethod(); +- Method method = getMethod(methodName); +- +- if (log.isLoggable(Level.FINE)) +- log.fine(this + " invoking " + methodName + " (" + method + ")"); +- +- if (method != null) { +- } +- else if ("_burlap_getAttribute".equals(in.getMethod())) { +- String attrName = in.readString(); +- in.completeCall(); +- +- String value = null; +- +- if ("java.api.class".equals(attrName)) +- value = getAPIClassName(); +- else if ("java.home.class".equals(attrName)) +- value = getHomeClassName(); +- else if ("java.object.class".equals(attrName)) +- value = getObjectClassName(); +- +- out.startReply(); +- +- out.writeObject(value); +- +- out.completeReply(); +- return; +- } +- else if (method == null) { +- out.startReply(); +- out.writeFault("NoSuchMethodException", +- "The service has no method named: " + in.getMethod(), +- null); +- out.completeReply(); +- return; +- } +- +- Class []args = method.getParameterTypes(); +- Object []values = new Object[args.length]; +- +- for (int i = 0; i < args.length; i++) +- values[i] = in.readObject(args[i]); +- +- in.completeCall(); +- +- Object result = null; +- +- try { +- result = method.invoke(service, values); +- } catch (Throwable e) { +- log.log(Level.FINE, +- service + "." + method.getName() + "() failed with exception:\n" +- + e.toString(), +- e); +- +- if (e instanceof InvocationTargetException +- && e.getCause() instanceof Exception) +- e = ((InvocationTargetException) e).getTargetException(); +- out.startReply(); +- out.writeFault("ServiceException", e.getMessage(), e); +- out.completeReply(); +- return; +- } +- +- out.startReply(); +- +- out.writeObject(result); +- +- out.completeReply(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.burlap.server; ++ ++import com.caucho.burlap.io.BurlapInput; ++import com.caucho.burlap.io.BurlapOutput; ++import com.caucho.services.server.AbstractSkeleton; ++import com.caucho.services.server.ServiceContext; ++ ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.util.logging.*; ++ ++/** ++ * Proxy class for Burlap services. ++ */ ++public class BurlapSkeleton extends AbstractSkeleton { ++ private static final Logger log ++ = Logger.getLogger(BurlapSkeleton.class.getName()); ++ ++ private Object _service; ++ ++ /** ++ * Create a new burlap skeleton. ++ * ++ * @param service the underlying service object. ++ * @param apiClass the API interface ++ */ ++ public BurlapSkeleton(Object service, Class apiClass) ++ { ++ super(apiClass); ++ ++ _service = service; ++ } ++ ++ /** ++ * Create a new burlap skeleton. ++ * ++ * @param service the underlying service object. ++ * @param apiClass the API interface ++ */ ++ public BurlapSkeleton(Class apiClass) ++ { ++ super(apiClass); ++ } ++ ++ /** ++ * Invoke the object with the request from the input stream. ++ * ++ * @param in the Burlap input stream ++ * @param out the Burlap output stream ++ */ ++ public void invoke(BurlapInput in, BurlapOutput out) ++ throws Exception ++ { ++ invoke(_service, in, out); ++ } ++ ++ /** ++ * Invoke the object with the request from the input stream. ++ * ++ * @param in the Burlap input stream ++ * @param out the Burlap output stream ++ */ ++ public void invoke(Object service, BurlapInput in, BurlapOutput out) ++ throws Exception ++ { ++ in.readCall(); ++ ++ ServiceContext context = ServiceContext.getContext(); ++ ++ String header; ++ while ((header = in.readHeader()) != null) { ++ Object value = in.readObject(); ++ ++ context.addHeader(header, value); ++ } ++ ++ String methodName = in.readMethod(); ++ Method method = getMethod(methodName); ++ ++ if (log.isLoggable(Level.FINE)) ++ log.fine(this + " invoking " + methodName + " (" + method + ")"); ++ ++ if (method != null) { ++ } ++ else if ("_burlap_getAttribute".equals(in.getMethod())) { ++ String attrName = in.readString(); ++ in.completeCall(); ++ ++ String value = null; ++ ++ if ("java.api.class".equals(attrName)) ++ value = getAPIClassName(); ++ else if ("java.home.class".equals(attrName)) ++ value = getHomeClassName(); ++ else if ("java.object.class".equals(attrName)) ++ value = getObjectClassName(); ++ ++ out.startReply(); ++ ++ out.writeObject(value); ++ ++ out.completeReply(); ++ return; ++ } ++ else if (method == null) { ++ out.startReply(); ++ out.writeFault("NoSuchMethodException", ++ "The service has no method named: " + in.getMethod(), ++ null); ++ out.completeReply(); ++ return; ++ } ++ ++ Class []args = method.getParameterTypes(); ++ Object []values = new Object[args.length]; ++ ++ for (int i = 0; i < args.length; i++) ++ values[i] = in.readObject(args[i]); ++ ++ in.completeCall(); ++ ++ Object result = null; ++ ++ try { ++ result = method.invoke(service, values); ++ } catch (Throwable e) { ++ log.log(Level.FINE, ++ service + "." + method.getName() + "() failed with exception:\n" ++ + e.toString(), ++ e); ++ ++ if (e instanceof InvocationTargetException ++ && e.getCause() instanceof Exception) ++ e = ((InvocationTargetException) e).getTargetException(); ++ out.startReply(); ++ out.writeFault("ServiceException", e.getMessage(), e); ++ out.completeReply(); ++ return; ++ } ++ ++ out.startReply(); ++ ++ out.writeObject(result); ++ ++ out.completeReply(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/HessianException.java hessian-4.0.65-fix/com/caucho/hessian/HessianException.java +--- hessian-4.0.65-src/com/caucho/hessian/HessianException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/HessianException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,85 +1,85 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian; +- +-/** +- * Base runtime exception for Hessian exceptions. +- */ +-public class HessianException extends RuntimeException { +- /** +- * Zero-arg constructor. +- */ +- public HessianException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public HessianException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public HessianException(String message, Throwable rootCause) +- { +- super(message, rootCause); +- } +- +- /** +- * Create the exception. +- */ +- public HessianException(Throwable rootCause) +- { +- super(rootCause); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian; ++ ++/** ++ * Base runtime exception for Hessian exceptions. ++ */ ++public class HessianException extends RuntimeException { ++ /** ++ * Zero-arg constructor. ++ */ ++ public HessianException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianException(String message, Throwable rootCause) ++ { ++ super(message, rootCause); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianException(Throwable rootCause) ++ { ++ super(rootCause); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/HessianUnshared.java hessian-4.0.65-fix/com/caucho/hessian/HessianUnshared.java +--- hessian-4.0.65-src/com/caucho/hessian/HessianUnshared.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/HessianUnshared.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,68 +1,68 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +- +-package com.caucho.hessian; +- +-import java.lang.annotation.ElementType; +-import java.lang.annotation.Retention; +-import java.lang.annotation.RetentionPolicy; +-import java.lang.annotation.Target; +- +-/** +- * Marks the class and all children as unshared. +- * A reference item will be created, but will not be stored in a +- * mapped or checked for duplicated. +- * +- * Used for efficiency to avoid the cost of the map lookup. +- */ +-@Target({ElementType.TYPE }) +-@Retention(RetentionPolicy.RUNTIME) +-public @interface HessianUnshared +-{ +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++ ++package com.caucho.hessian; ++ ++import java.lang.annotation.ElementType; ++import java.lang.annotation.Retention; ++import java.lang.annotation.RetentionPolicy; ++import java.lang.annotation.Target; ++ ++/** ++ * Marks the class and all children as unshared. ++ * A reference item will be created, but will not be stored in a ++ * mapped or checked for duplicated. ++ * ++ * Used for efficiency to avoid the cost of the map lookup. ++ */ ++@Target({ElementType.TYPE }) ++@Retention(RetentionPolicy.RUNTIME) ++public @interface HessianUnshared ++{ ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnection.java hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnection.java +--- hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnection.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnection.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,117 +1,117 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import java.net.URL; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.IOException; +- +-/** +- * Internal connection to a server. The default connection is based on +- * java.net +- */ +-abstract public class AbstractHessianConnection implements HessianConnection { +- /** +- * Adds HTTP headers. +- */ +- public void addHeader(String key, String value) +- { +- } +- +- /** +- * Returns the output stream for the request. +- */ +- abstract public OutputStream getOutputStream() +- throws IOException; +- +- /** +- * Sends the query +- */ +- abstract public void sendRequest() +- throws IOException; +- +- /** +- * Returns the status code. +- */ +- abstract public int getStatusCode(); +- +- /** +- * Returns the status string. +- */ +- abstract public String getStatusMessage(); +- +- /** +- * Returns the InputStream to the result +- */ +- abstract public InputStream getInputStream() +- throws IOException; +- +- @Override +- public String getContentEncoding() +- { +- return null; +- } +- +- /** +- * Close/free the connection, using keepalive if appropriate. +- */ +- public void close() +- throws IOException +- { +- destroy(); +- } +- +- /** +- * Destroy/disconnect the connection +- */ +- abstract public void destroy() +- throws IOException; +-} +- ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import java.net.URL; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.IOException; ++ ++/** ++ * Internal connection to a server. The default connection is based on ++ * java.net ++ */ ++abstract public class AbstractHessianConnection implements HessianConnection { ++ /** ++ * Adds HTTP headers. ++ */ ++ public void addHeader(String key, String value) ++ { ++ } ++ ++ /** ++ * Returns the output stream for the request. ++ */ ++ abstract public OutputStream getOutputStream() ++ throws IOException; ++ ++ /** ++ * Sends the query ++ */ ++ abstract public void sendRequest() ++ throws IOException; ++ ++ /** ++ * Returns the status code. ++ */ ++ abstract public int getStatusCode(); ++ ++ /** ++ * Returns the status string. ++ */ ++ abstract public String getStatusMessage(); ++ ++ /** ++ * Returns the InputStream to the result ++ */ ++ abstract public InputStream getInputStream() ++ throws IOException; ++ ++ @Override ++ public String getContentEncoding() ++ { ++ return null; ++ } ++ ++ /** ++ * Close/free the connection, using keepalive if appropriate. ++ */ ++ public void close() ++ throws IOException ++ { ++ destroy(); ++ } ++ ++ /** ++ * Destroy/disconnect the connection ++ */ ++ abstract public void destroy() ++ throws IOException; ++} ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnectionFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnectionFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnectionFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnectionFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,86 +1,86 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import java.net.URL; +-import java.io.IOException; +- +-/** +- * Internal factory for creating connections to the server. The default +- * factory is java.net +- */ +-abstract public class AbstractHessianConnectionFactory +- implements HessianConnectionFactory +-{ +- private HessianProxyFactory _factory; +- +- /** +- * The HessianProxyFactory contains some common network +- * configuration like timeouts. +- */ +- public void setHessianProxyFactory(HessianProxyFactory factory) +- { +- _factory = factory; +- } +- +- /** +- * The HessianProxyFactory contains some common network +- * configuration like timeouts. +- */ +- public HessianProxyFactory getHessianProxyFactory() +- { +- return _factory; +- } +- +- /** +- * Opens a new or recycled connection to the HTTP server. +- */ +- abstract public HessianConnection open(URL url) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import java.net.URL; ++import java.io.IOException; ++ ++/** ++ * Internal factory for creating connections to the server. The default ++ * factory is java.net ++ */ ++abstract public class AbstractHessianConnectionFactory ++ implements HessianConnectionFactory ++{ ++ private HessianProxyFactory _factory; ++ ++ /** ++ * The HessianProxyFactory contains some common network ++ * configuration like timeouts. ++ */ ++ public void setHessianProxyFactory(HessianProxyFactory factory) ++ { ++ _factory = factory; ++ } ++ ++ /** ++ * The HessianProxyFactory contains some common network ++ * configuration like timeouts. ++ */ ++ public HessianProxyFactory getHessianProxyFactory() ++ { ++ return _factory; ++ } ++ ++ /** ++ * Opens a new or recycled connection to the HTTP server. ++ */ ++ abstract public HessianConnection open(URL url) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianConnection.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnection.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianConnection.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnection.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,112 +1,112 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import java.net.URL; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.IOException; +- +-/** +- * Internal connection to a server. The default connection is based on +- * java.net +- */ +-public interface HessianConnection { +- /** +- * Adds HTTP headers. +- */ +- public void addHeader(String key, String value); +- +- /** +- * Returns the output stream for the request. +- */ +- public OutputStream getOutputStream() +- throws IOException; +- +- /** +- * Sends the query +- */ +- public void sendRequest() +- throws IOException; +- +- /** +- * Returns the status code. +- */ +- public int getStatusCode(); +- +- /** +- * Returns the status string. +- */ +- public String getStatusMessage(); +- +- /** +- * Returns the content encoding +- */ +- public String getContentEncoding(); +- +- +- /** +- * Returns the InputStream to the result +- */ +- public InputStream getInputStream() +- throws IOException; +- +- /** +- * Close/free the connection. If keepalive is allowed, it may be used. +- */ +- public void close() +- throws IOException; +- +- /** +- * Shut the connection down. +- */ +- public void destroy() +- throws IOException; +-} +- ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import java.net.URL; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.IOException; ++ ++/** ++ * Internal connection to a server. The default connection is based on ++ * java.net ++ */ ++public interface HessianConnection { ++ /** ++ * Adds HTTP headers. ++ */ ++ public void addHeader(String key, String value); ++ ++ /** ++ * Returns the output stream for the request. ++ */ ++ public OutputStream getOutputStream() ++ throws IOException; ++ ++ /** ++ * Sends the query ++ */ ++ public void sendRequest() ++ throws IOException; ++ ++ /** ++ * Returns the status code. ++ */ ++ public int getStatusCode(); ++ ++ /** ++ * Returns the status string. ++ */ ++ public String getStatusMessage(); ++ ++ /** ++ * Returns the content encoding ++ */ ++ public String getContentEncoding(); ++ ++ ++ /** ++ * Returns the InputStream to the result ++ */ ++ public InputStream getInputStream() ++ throws IOException; ++ ++ /** ++ * Close/free the connection. If keepalive is allowed, it may be used. ++ */ ++ public void close() ++ throws IOException; ++ ++ /** ++ * Shut the connection down. ++ */ ++ public void destroy() ++ throws IOException; ++} ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionException.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionException.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,87 +1,87 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Exception caused by failure of the client proxy to connect to the server. +- */ +-public class HessianConnectionException extends HessianException { +- /** +- * Zero-arg constructor. +- */ +- public HessianConnectionException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public HessianConnectionException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public HessianConnectionException(String message, Throwable rootCause) +- { +- super(message, rootCause); +- } +- +- /** +- * Create the exception. +- */ +- public HessianConnectionException(Throwable rootCause) +- { +- super(rootCause); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Exception caused by failure of the client proxy to connect to the server. ++ */ ++public class HessianConnectionException extends HessianException { ++ /** ++ * Zero-arg constructor. ++ */ ++ public HessianConnectionException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianConnectionException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianConnectionException(String message, Throwable rootCause) ++ { ++ super(message, rootCause); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianConnectionException(Throwable rootCause) ++ { ++ super(rootCause); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,69 +1,69 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import java.net.URL; +-import java.io.IOException; +- +-/** +- * Internal factory for creating connections to the server. The default +- * factory is java.net +- */ +-public interface HessianConnectionFactory { +- /** +- * Sets the HessianProxyFactory +- */ +- public void setHessianProxyFactory(HessianProxyFactory factory); +- +- /** +- * Opens a new or recycled connection to the HTTP server. +- */ +- public HessianConnection open(URL url) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import java.net.URL; ++import java.io.IOException; ++ ++/** ++ * Internal factory for creating connections to the server. The default ++ * factory is java.net ++ */ ++public interface HessianConnectionFactory { ++ /** ++ * Sets the HessianProxyFactory ++ */ ++ public void setHessianProxyFactory(HessianProxyFactory factory); ++ ++ /** ++ * Opens a new or recycled connection to the HTTP server. ++ */ ++ public HessianConnection open(URL url) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianMetaInfoAPI.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianMetaInfoAPI.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianMetaInfoAPI.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianMetaInfoAPI.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,66 +1,66 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-/** +- * API retrieving hessian meta information. +- */ +-public interface HessianMetaInfoAPI { +- /** +- * Returns a service attribute. +- * +- *
    +- *
  • java.api.class - the Java interface for the object interface. +- *
  • java.ejb.home.class - the EJB home interface +- *
  • java.ejb.remote.class - the EJB remote interface +- *
  • java.primary.key.class - the EJB primary key class +- *
+- */ +- public Object _hessian_getAttribute(String name); +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++/** ++ * API retrieving hessian meta information. ++ */ ++public interface HessianMetaInfoAPI { ++ /** ++ * Returns a service attribute. ++ * ++ *
    ++ *
  • java.api.class - the Java interface for the object interface. ++ *
  • java.ejb.home.class - the EJB home interface ++ *
  • java.ejb.remote.class - the EJB remote interface ++ *
  • java.primary.key.class - the EJB primary key class ++ *
++ */ ++ public Object _hessian_getAttribute(String name); ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianProxy.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxy.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianProxy.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxy.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,483 +1,483 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import com.caucho.hessian.io.*; +-import com.caucho.services.server.*; +- +-import java.io.*; +-import java.util.logging.*; +-import java.lang.reflect.InvocationHandler; +-import java.lang.reflect.Method; +-import java.lang.reflect.Proxy; +-import java.util.WeakHashMap; +-import java.net.HttpURLConnection; +-import java.net.URL; +-import java.net.URLConnection; +-import java.util.zip.*; +- +-/** +- * Proxy implementation for Hessian clients. Applications will generally +- * use HessianProxyFactory to create proxy clients. +- */ +-public class HessianProxy implements InvocationHandler, Serializable { +- private static final Logger log +- = Logger.getLogger(HessianProxy.class.getName()); +- +- protected HessianProxyFactory _factory; +- +- private WeakHashMap _mangleMap +- = new WeakHashMap(); +- +- private Class _type; +- private URL _url; +- +- /** +- * Protected constructor for subclassing +- */ +- protected HessianProxy(URL url, HessianProxyFactory factory) +- { +- this(url, factory, null); +- } +- +- /** +- * Protected constructor for subclassing +- */ +- protected HessianProxy(URL url, +- HessianProxyFactory factory, +- Class type) +- { +- _factory = factory; +- _url = url; +- _type = type; +- } +- +- /** +- * Returns the proxy's URL. +- */ +- public URL getURL() +- { +- return _url; +- } +- +- /** +- * Handles the object invocation. +- * +- * @param proxy the proxy object to invoke +- * @param method the method to call +- * @param args the arguments to the proxy object +- */ +- public Object invoke(Object proxy, Method method, Object []args) +- throws Throwable +- { +- String mangleName; +- +- synchronized (_mangleMap) { +- mangleName = _mangleMap.get(method); +- } +- +- if (mangleName == null) { +- String methodName = method.getName(); +- Class []params = method.getParameterTypes(); +- +- // equals and hashCode are special cased +- if (methodName.equals("equals") +- && params.length == 1 && params[0].equals(Object.class)) { +- Object value = args[0]; +- if (value == null || ! Proxy.isProxyClass(value.getClass())) +- return Boolean.FALSE; +- +- Object proxyHandler = Proxy.getInvocationHandler(value); +- +- if (! (proxyHandler instanceof HessianProxy)) +- return Boolean.FALSE; +- +- HessianProxy handler = (HessianProxy) proxyHandler; +- +- return new Boolean(_url.equals(handler.getURL())); +- } +- else if (methodName.equals("hashCode") && params.length == 0) +- return new Integer(_url.hashCode()); +- else if (methodName.equals("getHessianType")) +- return proxy.getClass().getInterfaces()[0].getName(); +- else if (methodName.equals("getHessianURL")) +- return _url.toString(); +- else if (methodName.equals("toString") && params.length == 0) +- return "HessianProxy[" + _url + "]"; +- +- if (! _factory.isOverloadEnabled()) +- mangleName = method.getName(); +- else +- mangleName = mangleName(method); +- +- synchronized (_mangleMap) { +- _mangleMap.put(method, mangleName); +- } +- } +- +- InputStream is = null; +- HessianConnection conn = null; +- +- try { +- if (log.isLoggable(Level.FINER)) +- log.finer("Hessian[" + _url + "] calling " + mangleName); +- +- conn = sendRequest(mangleName, args); +- +- is = getInputStream(conn); +- +- if (log.isLoggable(Level.FINEST)) { +- PrintWriter dbg = new PrintWriter(new LogWriter(log)); +- HessianDebugInputStream dIs +- = new HessianDebugInputStream(is, dbg); +- +- dIs.startTop2(); +- +- is = dIs; +- } +- +- AbstractHessianInput in; +- +- int code = is.read(); +- +- if (code == 'H') { +- int major = is.read(); +- int minor = is.read(); +- +- in = _factory.getHessian2Input(is); +- +- Object value = in.readReply(method.getReturnType()); +- +- if (value instanceof InputStream) { +- value = new ResultInputStream(conn, is, in, (InputStream) value); +- is = null; +- conn = null; +- } +- +- return value; +- } +- else if (code == 'r') { +- int major = is.read(); +- int minor = is.read(); +- +- in = _factory.getHessianInput(is); +- +- in.startReplyBody(); +- +- Object value = in.readObject(method.getReturnType()); +- +- if (value instanceof InputStream) { +- value = new ResultInputStream(conn, is, in, (InputStream) value); +- is = null; +- conn = null; +- } +- else { +- in.completeReply(); +- } +- +- return value; +- } +- else +- throw new HessianProtocolException("'" + (char) code + "' is an unknown code"); +- } catch (HessianProtocolException e) { +- throw new HessianRuntimeException(e); +- } finally { +- try { +- if (is != null) +- is.close(); +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- try { +- if (conn != null) +- conn.destroy(); +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- } +- } +- } +- +- protected InputStream getInputStream(HessianConnection conn) +- throws IOException +- { +- InputStream is = conn.getInputStream(); +- +- if ("deflate".equals(conn.getContentEncoding())) { +- is = new InflaterInputStream(is, new Inflater(true)); +- } +- +- return is; +- } +- +- protected String mangleName(Method method) +- { +- Class []param = method.getParameterTypes(); +- +- if (param == null || param.length == 0) +- return method.getName(); +- else +- return AbstractSkeleton.mangleName(method, false); +- } +- +- /** +- * Sends the HTTP request to the Hessian connection. +- */ +- protected HessianConnection sendRequest(String methodName, Object []args) +- throws IOException +- { +- HessianConnection conn = null; +- +- conn = _factory.getConnectionFactory().open(_url); +- boolean isValid = false; +- +- try { +- addRequestHeaders(conn); +- +- OutputStream os = null; +- +- try { +- os = conn.getOutputStream(); +- } catch (Exception e) { +- throw new HessianRuntimeException(e); +- } +- +- if (log.isLoggable(Level.FINEST)) { +- PrintWriter dbg = new PrintWriter(new LogWriter(log)); +- HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); +- dOs.startTop2(); +- os = dOs; +- } +- +- AbstractHessianOutput out = _factory.getHessianOutput(os); +- +- out.call(methodName, args); +- out.flush(); +- +- conn.sendRequest(); +- +- isValid = true; +- +- return conn; +- } finally { +- if (! isValid && conn != null) +- conn.destroy(); +- } +- } +- +- /** +- * Method that allows subclasses to add request headers such as cookies. +- * Default implementation is empty. +- */ +- protected void addRequestHeaders(HessianConnection conn) +- { +- conn.addHeader("Content-Type", "x-application/hessian"); +- conn.addHeader("Accept-Encoding", "deflate"); +- +- String basicAuth = _factory.getBasicAuth(); +- +- if (basicAuth != null) +- conn.addHeader("Authorization", basicAuth); +- } +- +- /** +- * Method that allows subclasses to parse response headers such as cookies. +- * Default implementation is empty. +- * @param conn +- */ +- protected void parseResponseHeaders(URLConnection conn) +- { +- } +- +- public Object writeReplace() +- { +- return new HessianRemote(_type.getName(), _url.toString()); +- } +- +- static class ResultInputStream extends InputStream { +- private HessianConnection _conn; +- private InputStream _connIs; +- private AbstractHessianInput _in; +- private InputStream _hessianIs; +- +- ResultInputStream(HessianConnection conn, +- InputStream is, +- AbstractHessianInput in, +- InputStream hessianIs) +- { +- _conn = conn; +- _connIs = is; +- _in = in; +- _hessianIs = hessianIs; +- } +- +- public int read() +- throws IOException +- { +- if (_hessianIs != null) { +- int value = _hessianIs.read(); +- +- if (value < 0) +- close(); +- +- return value; +- } +- else +- return -1; +- } +- +- public int read(byte []buffer, int offset, int length) +- throws IOException +- { +- if (_hessianIs != null) { +- int value = _hessianIs.read(buffer, offset, length); +- +- if (value < 0) +- close(); +- +- return value; +- } +- else +- return -1; +- } +- +- public void close() +- throws IOException +- { +- HessianConnection conn = _conn; +- _conn = null; +- +- InputStream connIs = _connIs; +- _connIs = null; +- +- AbstractHessianInput in = _in; +- _in = null; +- +- InputStream hessianIs = _hessianIs; +- _hessianIs = null; +- +- try { +- if (hessianIs != null) +- hessianIs.close(); +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- try { +- if (in != null) { +- in.completeReply(); +- in.close(); +- } +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- try { +- if (connIs != null) { +- connIs.close(); +- } +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- try { +- if (conn != null) { +- conn.close(); +- } +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- } +- } +- } +- +- static class LogWriter extends Writer { +- private Logger _log; +- private Level _level = Level.FINEST; +- private StringBuilder _sb = new StringBuilder(); +- +- LogWriter(Logger log) +- { +- _log = log; +- } +- +- public void write(char ch) +- { +- if (ch == '\n' && _sb.length() > 0) { +- _log.fine(_sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- +- public void write(char []buffer, int offset, int length) +- { +- for (int i = 0; i < length; i++) { +- char ch = buffer[offset + i]; +- +- if (ch == '\n' && _sb.length() > 0) { +- _log.log(_level, _sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- } +- +- public void flush() +- { +- } +- +- public void close() +- { +- if (_sb.length() > 0) +- _log.log(_level, _sb.toString()); +- } +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import com.caucho.hessian.io.*; ++import com.caucho.services.server.*; ++ ++import java.io.*; ++import java.util.logging.*; ++import java.lang.reflect.InvocationHandler; ++import java.lang.reflect.Method; ++import java.lang.reflect.Proxy; ++import java.util.WeakHashMap; ++import java.net.HttpURLConnection; ++import java.net.URL; ++import java.net.URLConnection; ++import java.util.zip.*; ++ ++/** ++ * Proxy implementation for Hessian clients. Applications will generally ++ * use HessianProxyFactory to create proxy clients. ++ */ ++public class HessianProxy implements InvocationHandler, Serializable { ++ private static final Logger log ++ = Logger.getLogger(HessianProxy.class.getName()); ++ ++ protected HessianProxyFactory _factory; ++ ++ private WeakHashMap _mangleMap ++ = new WeakHashMap(); ++ ++ private Class _type; ++ private URL _url; ++ ++ /** ++ * Protected constructor for subclassing ++ */ ++ protected HessianProxy(URL url, HessianProxyFactory factory) ++ { ++ this(url, factory, null); ++ } ++ ++ /** ++ * Protected constructor for subclassing ++ */ ++ protected HessianProxy(URL url, ++ HessianProxyFactory factory, ++ Class type) ++ { ++ _factory = factory; ++ _url = url; ++ _type = type; ++ } ++ ++ /** ++ * Returns the proxy's URL. ++ */ ++ public URL getURL() ++ { ++ return _url; ++ } ++ ++ /** ++ * Handles the object invocation. ++ * ++ * @param proxy the proxy object to invoke ++ * @param method the method to call ++ * @param args the arguments to the proxy object ++ */ ++ public Object invoke(Object proxy, Method method, Object []args) ++ throws Throwable ++ { ++ String mangleName; ++ ++ synchronized (_mangleMap) { ++ mangleName = _mangleMap.get(method); ++ } ++ ++ if (mangleName == null) { ++ String methodName = method.getName(); ++ Class []params = method.getParameterTypes(); ++ ++ // equals and hashCode are special cased ++ if (methodName.equals("equals") ++ && params.length == 1 && params[0].equals(Object.class)) { ++ Object value = args[0]; ++ if (value == null || ! Proxy.isProxyClass(value.getClass())) ++ return Boolean.FALSE; ++ ++ Object proxyHandler = Proxy.getInvocationHandler(value); ++ ++ if (! (proxyHandler instanceof HessianProxy)) ++ return Boolean.FALSE; ++ ++ HessianProxy handler = (HessianProxy) proxyHandler; ++ ++ return new Boolean(_url.equals(handler.getURL())); ++ } ++ else if (methodName.equals("hashCode") && params.length == 0) ++ return new Integer(_url.hashCode()); ++ else if (methodName.equals("getHessianType")) ++ return proxy.getClass().getInterfaces()[0].getName(); ++ else if (methodName.equals("getHessianURL")) ++ return _url.toString(); ++ else if (methodName.equals("toString") && params.length == 0) ++ return "HessianProxy[" + _url + "]"; ++ ++ if (! _factory.isOverloadEnabled()) ++ mangleName = method.getName(); ++ else ++ mangleName = mangleName(method); ++ ++ synchronized (_mangleMap) { ++ _mangleMap.put(method, mangleName); ++ } ++ } ++ ++ InputStream is = null; ++ HessianConnection conn = null; ++ ++ try { ++ if (log.isLoggable(Level.FINER)) ++ log.finer("Hessian[" + _url + "] calling " + mangleName); ++ ++ conn = sendRequest(mangleName, args); ++ ++ is = getInputStream(conn); ++ ++ if (log.isLoggable(Level.FINEST)) { ++ PrintWriter dbg = new PrintWriter(new LogWriter(log)); ++ HessianDebugInputStream dIs ++ = new HessianDebugInputStream(is, dbg); ++ ++ dIs.startTop2(); ++ ++ is = dIs; ++ } ++ ++ AbstractHessianInput in; ++ ++ int code = is.read(); ++ ++ if (code == 'H') { ++ int major = is.read(); ++ int minor = is.read(); ++ ++ in = _factory.getHessian2Input(is); ++ ++ Object value = in.readReply(method.getReturnType()); ++ ++ if (value instanceof InputStream) { ++ value = new ResultInputStream(conn, is, in, (InputStream) value); ++ is = null; ++ conn = null; ++ } ++ ++ return value; ++ } ++ else if (code == 'r') { ++ int major = is.read(); ++ int minor = is.read(); ++ ++ in = _factory.getHessianInput(is); ++ ++ in.startReplyBody(); ++ ++ Object value = in.readObject(method.getReturnType()); ++ ++ if (value instanceof InputStream) { ++ value = new ResultInputStream(conn, is, in, (InputStream) value); ++ is = null; ++ conn = null; ++ } ++ else { ++ in.completeReply(); ++ } ++ ++ return value; ++ } ++ else ++ throw new HessianProtocolException("'" + (char) code + "' is an unknown code"); ++ } catch (HessianProtocolException e) { ++ throw new HessianRuntimeException(e); ++ } finally { ++ try { ++ if (is != null) ++ is.close(); ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ try { ++ if (conn != null) ++ conn.destroy(); ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ } ++ } ++ ++ protected InputStream getInputStream(HessianConnection conn) ++ throws IOException ++ { ++ InputStream is = conn.getInputStream(); ++ ++ if ("deflate".equals(conn.getContentEncoding())) { ++ is = new InflaterInputStream(is, new Inflater(true)); ++ } ++ ++ return is; ++ } ++ ++ protected String mangleName(Method method) ++ { ++ Class []param = method.getParameterTypes(); ++ ++ if (param == null || param.length == 0) ++ return method.getName(); ++ else ++ return AbstractSkeleton.mangleName(method, false); ++ } ++ ++ /** ++ * Sends the HTTP request to the Hessian connection. ++ */ ++ protected HessianConnection sendRequest(String methodName, Object []args) ++ throws IOException ++ { ++ HessianConnection conn = null; ++ ++ conn = _factory.getConnectionFactory().open(_url); ++ boolean isValid = false; ++ ++ try { ++ addRequestHeaders(conn); ++ ++ OutputStream os = null; ++ ++ try { ++ os = conn.getOutputStream(); ++ } catch (Exception e) { ++ throw new HessianRuntimeException(e); ++ } ++ ++ if (log.isLoggable(Level.FINEST)) { ++ PrintWriter dbg = new PrintWriter(new LogWriter(log)); ++ HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); ++ dOs.startTop2(); ++ os = dOs; ++ } ++ ++ AbstractHessianOutput out = _factory.getHessianOutput(os); ++ ++ out.call(methodName, args); ++ out.flush(); ++ ++ conn.sendRequest(); ++ ++ isValid = true; ++ ++ return conn; ++ } finally { ++ if (! isValid && conn != null) ++ conn.destroy(); ++ } ++ } ++ ++ /** ++ * Method that allows subclasses to add request headers such as cookies. ++ * Default implementation is empty. ++ */ ++ protected void addRequestHeaders(HessianConnection conn) ++ { ++ conn.addHeader("Content-Type", "x-application/hessian"); ++ conn.addHeader("Interface-Name", this._type.getCanonicalName()); ++ ++ String basicAuth = _factory.getBasicAuth(); ++ ++ if (basicAuth != null) ++ conn.addHeader("Authorization", basicAuth); ++ } ++ ++ /** ++ * Method that allows subclasses to parse response headers such as cookies. ++ * Default implementation is empty. ++ * @param conn ++ */ ++ protected void parseResponseHeaders(URLConnection conn) ++ { ++ } ++ ++ public Object writeReplace() ++ { ++ return new HessianRemote(_type.getName(), _url.toString()); ++ } ++ ++ static class ResultInputStream extends InputStream { ++ private HessianConnection _conn; ++ private InputStream _connIs; ++ private AbstractHessianInput _in; ++ private InputStream _hessianIs; ++ ++ ResultInputStream(HessianConnection conn, ++ InputStream is, ++ AbstractHessianInput in, ++ InputStream hessianIs) ++ { ++ _conn = conn; ++ _connIs = is; ++ _in = in; ++ _hessianIs = hessianIs; ++ } ++ ++ public int read() ++ throws IOException ++ { ++ if (_hessianIs != null) { ++ int value = _hessianIs.read(); ++ ++ if (value < 0) ++ close(); ++ ++ return value; ++ } ++ else ++ return -1; ++ } ++ ++ public int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (_hessianIs != null) { ++ int value = _hessianIs.read(buffer, offset, length); ++ ++ if (value < 0) ++ close(); ++ ++ return value; ++ } ++ else ++ return -1; ++ } ++ ++ public void close() ++ throws IOException ++ { ++ HessianConnection conn = _conn; ++ _conn = null; ++ ++ InputStream connIs = _connIs; ++ _connIs = null; ++ ++ AbstractHessianInput in = _in; ++ _in = null; ++ ++ InputStream hessianIs = _hessianIs; ++ _hessianIs = null; ++ ++ try { ++ if (hessianIs != null) ++ hessianIs.close(); ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ try { ++ if (in != null) { ++ in.completeReply(); ++ in.close(); ++ } ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ try { ++ if (connIs != null) { ++ connIs.close(); ++ } ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ try { ++ if (conn != null) { ++ conn.close(); ++ } ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ } ++ } ++ ++ static class LogWriter extends Writer { ++ private Logger _log; ++ private Level _level = Level.FINEST; ++ private StringBuilder _sb = new StringBuilder(); ++ ++ LogWriter(Logger log) ++ { ++ _log = log; ++ } ++ ++ public void write(char ch) ++ { ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ ++ public void write(char []buffer, int offset, int length) ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = buffer[offset + i]; ++ ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.log(_level, _sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ } ++ ++ public void flush() ++ { ++ } ++ ++ public void close() ++ { ++ if (_sb.length() > 0) ++ _log.log(_level, _sb.toString()); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,613 +1,613 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.PrintWriter; +-import java.lang.reflect.InvocationHandler; +-import java.lang.reflect.Proxy; +-import java.net.MalformedURLException; +-import java.net.URL; +-import java.util.Hashtable; +-import java.util.logging.Logger; +- +-import javax.naming.Context; +-import javax.naming.Name; +-import javax.naming.NamingException; +-import javax.naming.RefAddr; +-import javax.naming.Reference; +-import javax.naming.spi.ObjectFactory; +- +-import com.caucho.hessian.io.AbstractHessianInput; +-import com.caucho.hessian.io.AbstractHessianOutput; +-import com.caucho.hessian.io.Hessian2Input; +-import com.caucho.hessian.io.Hessian2Output; +-import com.caucho.hessian.io.HessianDebugInputStream; +-import com.caucho.hessian.io.HessianInput; +-import com.caucho.hessian.io.HessianOutput; +-import com.caucho.hessian.io.HessianRemoteObject; +-import com.caucho.hessian.io.HessianRemoteResolver; +-import com.caucho.hessian.io.SerializerFactory; +-import com.caucho.services.client.ServiceProxyFactory; +- +-/** +- * Factory for creating Hessian client stubs. The returned stub will +- * call the remote object for all methods. +- * +- *
+- * String url = "http://localhost:8080/ejb/hello";
+- * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+- * 
+- * +- * After creation, the stub can be like a regular Java class. Because +- * it makes remote calls, it can throw more exceptions than a Java class. +- * In particular, it may throw protocol exceptions. +- * +- * The factory can also be configured as a JNDI resource. The factory +- * expects to parameters: "type" and "url", corresponding to the two +- * arguments to create +- * +- * In Resin 3.0, the above example would be configured as: +- *
+- * <reference>
+- *   <jndi-name>hessian/hello</jndi-name>
+- *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
+- *   <init-param url="http://localhost:8080/ejb/hello"/>
+- *   <init-param type="test.HelloHome"/>
+- * </reference>
+- * 
+- * +- * To get the above resource, use JNDI as follows: +- *
+- * Context ic = new InitialContext();
+- * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/hessian/hello");
+- *
+- * System.out.println("Hello: " + hello.helloWorld());
+- * 
+- * +- *

Authentication

+- * +- *

The proxy can use HTTP basic authentication if the user and the +- * password are set. +- */ +-public class HessianProxyFactory implements ServiceProxyFactory, ObjectFactory { +- protected static Logger log +- = Logger.getLogger(HessianProxyFactory.class.getName()); +- +- private final ClassLoader _loader; +- +- private SerializerFactory _serializerFactory; +- +- private HessianConnectionFactory _connFactory; +- +- private HessianRemoteResolver _resolver; +- +- private String _user; +- private String _password; +- private String _basicAuth; +- +- private boolean _isOverloadEnabled = false; +- +- private boolean _isHessian2Reply = true; +- private boolean _isHessian2Request = false; +- +- private boolean _isChunkedPost = true; +- private boolean _isDebug = false; +- +- private long _readTimeout = -1; +- private long _connectTimeout = -1; +- +- /** +- * Creates the new proxy factory. +- */ +- public HessianProxyFactory() +- { +- this(Thread.currentThread().getContextClassLoader()); +- } +- +- /** +- * Creates the new proxy factory. +- */ +- public HessianProxyFactory(ClassLoader loader) +- { +- _loader = loader; +- _resolver = new HessianProxyResolver(this); +- } +- +- /** +- * Sets the user. +- */ +- public void setUser(String user) +- { +- _user = user; +- _basicAuth = null; +- } +- +- /** +- * Sets the password. +- */ +- public void setPassword(String password) +- { +- _password = password; +- _basicAuth = null; +- } +- +- public String getBasicAuth() +- { +- if (_basicAuth != null) +- return _basicAuth; +- +- else if (_user != null && _password != null) +- return "Basic " + base64(_user + ":" + _password); +- +- else +- return null; +- } +- +- /** +- * Sets the connection factory to use when connecting +- * to the Hessian service. +- */ +- public void setConnectionFactory(HessianConnectionFactory factory) +- { +- _connFactory = factory; +- } +- +- /** +- * Returns the connection factory to be used for the HTTP request. +- */ +- public HessianConnectionFactory getConnectionFactory() +- { +- if (_connFactory == null) { +- _connFactory = createHessianConnectionFactory(); +- _connFactory.setHessianProxyFactory(this); +- } +- +- return _connFactory; +- } +- +- /** +- * Sets the debug +- */ +- public void setDebug(boolean isDebug) +- { +- _isDebug = isDebug; +- } +- +- /** +- * Gets the debug +- */ +- public boolean isDebug() +- { +- return _isDebug; +- } +- +- /** +- * Returns true if overloaded methods are allowed (using mangling) +- */ +- public boolean isOverloadEnabled() +- { +- return _isOverloadEnabled; +- } +- +- /** +- * set true if overloaded methods are allowed (using mangling) +- */ +- public void setOverloadEnabled(boolean isOverloadEnabled) +- { +- _isOverloadEnabled = isOverloadEnabled; +- } +- +- /** +- * Set true if should use chunked encoding on the request. +- */ +- public void setChunkedPost(boolean isChunked) +- { +- _isChunkedPost = isChunked; +- } +- +- /** +- * Set true if should use chunked encoding on the request. +- */ +- public boolean isChunkedPost() +- { +- return _isChunkedPost; +- } +- +- /** +- * The socket timeout on requests in milliseconds. +- */ +- public long getReadTimeout() +- { +- return _readTimeout; +- } +- +- /** +- * The socket timeout on requests in milliseconds. +- */ +- public void setReadTimeout(long timeout) +- { +- _readTimeout = timeout; +- } +- +- /** +- * The socket connection timeout in milliseconds. +- */ +- public long getConnectTimeout() +- { +- return _connectTimeout; +- } +- +- /** +- * The socket connect timeout in milliseconds. +- */ +- public void setConnectTimeout(long timeout) +- { +- _connectTimeout = timeout; +- } +- +- /** +- * True if the proxy can read Hessian 2 responses. +- */ +- public void setHessian2Reply(boolean isHessian2) +- { +- _isHessian2Reply = isHessian2; +- } +- +- /** +- * True if the proxy should send Hessian 2 requests. +- */ +- public void setHessian2Request(boolean isHessian2) +- { +- _isHessian2Request = isHessian2; +- +- if (isHessian2) +- _isHessian2Reply = true; +- } +- +- /** +- * Returns the remote resolver. +- */ +- public HessianRemoteResolver getRemoteResolver() +- { +- return _resolver; +- } +- +- /** +- * Sets the serializer factory. +- */ +- public void setSerializerFactory(SerializerFactory factory) +- { +- _serializerFactory = factory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- public SerializerFactory getSerializerFactory() +- { +- if (_serializerFactory == null) +- _serializerFactory = new SerializerFactory(_loader); +- +- return _serializerFactory; +- } +- +- protected HessianConnectionFactory createHessianConnectionFactory() +- { +- String className +- = System.getProperty(HessianConnectionFactory.class.getName()); +- +- HessianConnectionFactory factory = null; +- +- try { +- if (className != null) { +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- +- Class cl = Class.forName(className, false, loader); +- +- factory = (HessianConnectionFactory) cl.newInstance(); +- +- return factory; +- } +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- +- return new HessianURLConnectionFactory(); +- } +- /** +- * Creates a new proxy with the specified URL. The API class uses +- * the java.api.class value from _hessian_ +- * +- * @param url the URL where the client object is located. +- * +- * @return a proxy to the object with the specified interface. +- */ +- public Object create(String url) +- throws MalformedURLException, ClassNotFoundException +- { +- HessianMetaInfoAPI metaInfo; +- +- metaInfo = (HessianMetaInfoAPI) create(HessianMetaInfoAPI.class, url); +- +- String apiClassName = +- (String) metaInfo._hessian_getAttribute("java.api.class"); +- +- if (apiClassName == null) +- throw new HessianRuntimeException(url + " has an unknown api."); +- +- Class apiClass = Class.forName(apiClassName, false, _loader); +- +- return create(apiClass, url); +- } +- +- /** +- * Creates a new proxy with the specified URL. The returned object +- * is a proxy with the interface specified by api. +- * +- *

+-   * String url = "http://localhost:8080/ejb/hello");
+-   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+-   * 
+- * +- * @param api the interface the proxy class needs to implement +- * @param url the URL where the client object is located. +- * +- * @return a proxy to the object with the specified interface. +- */ +- public Object create(Class api, String urlName) +- throws MalformedURLException +- { +- return create(api, urlName, _loader); +- } +- +- /** +- * Creates a new proxy with the specified URL. The returned object +- * is a proxy with the interface specified by api. +- * +- *
+-   * String url = "http://localhost:8080/ejb/hello");
+-   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+-   * 
+- * +- * @param api the interface the proxy class needs to implement +- * @param url the URL where the client object is located. +- * +- * @return a proxy to the object with the specified interface. +- */ +- public Object create(Class api, String urlName, ClassLoader loader) +- throws MalformedURLException +- { +- URL url = new URL(urlName); +- +- return create(api, url, loader); +- } +- +- /** +- * Creates a new proxy with the specified URL. The returned object +- * is a proxy with the interface specified by api. +- * +- *
+-   * String url = "http://localhost:8080/ejb/hello");
+-   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+-   * 
+- * +- * @param api the interface the proxy class needs to implement +- * @param url the URL where the client object is located. +- * +- * @return a proxy to the object with the specified interface. +- */ +- public Object create(Class api, URL url, ClassLoader loader) +- { +- if (api == null) +- throw new NullPointerException("api must not be null for HessianProxyFactory.create()"); +- InvocationHandler handler = null; +- +- handler = new HessianProxy(url, this, api); +- +- return Proxy.newProxyInstance(loader, +- new Class[] { api, +- HessianRemoteObject.class }, +- handler); +- } +- +- public AbstractHessianInput getHessianInput(InputStream is) +- { +- return getHessian2Input(is); +- } +- +- public AbstractHessianInput getHessian1Input(InputStream is) +- { +- AbstractHessianInput in; +- +- if (_isDebug) +- is = new HessianDebugInputStream(is, new PrintWriter(System.out)); +- +- in = new HessianInput(is); +- +- in.setRemoteResolver(getRemoteResolver()); +- +- in.setSerializerFactory(getSerializerFactory()); +- +- return in; +- } +- +- public AbstractHessianInput getHessian2Input(InputStream is) +- { +- AbstractHessianInput in; +- +- if (_isDebug) +- is = new HessianDebugInputStream(is, new PrintWriter(System.out)); +- +- in = new Hessian2Input(is); +- +- in.setRemoteResolver(getRemoteResolver()); +- +- in.setSerializerFactory(getSerializerFactory()); +- +- return in; +- } +- +- public AbstractHessianOutput getHessianOutput(OutputStream os) +- { +- AbstractHessianOutput out; +- +- if (_isHessian2Request) +- out = new Hessian2Output(os); +- else { +- HessianOutput out1 = new HessianOutput(os); +- out = out1; +- +- if (_isHessian2Reply) +- out1.setVersion(2); +- } +- +- out.setSerializerFactory(getSerializerFactory()); +- +- return out; +- } +- +- /** +- * JNDI object factory so the proxy can be used as a resource. +- */ +- public Object getObjectInstance(Object obj, Name name, +- Context nameCtx, Hashtable environment) +- throws Exception +- { +- Reference ref = (Reference) obj; +- +- String api = null; +- String url = null; +- +- for (int i = 0; i < ref.size(); i++) { +- RefAddr addr = ref.get(i); +- +- String type = addr.getType(); +- String value = (String) addr.getContent(); +- +- if (type.equals("type")) +- api = value; +- else if (type.equals("url")) +- url = value; +- else if (type.equals("user")) +- setUser(value); +- else if (type.equals("password")) +- setPassword(value); +- } +- +- if (url == null) +- throw new NamingException("`url' must be configured for HessianProxyFactory."); +- // XXX: could use meta protocol to grab this +- if (api == null) +- throw new NamingException("`type' must be configured for HessianProxyFactory."); +- +- Class apiClass = Class.forName(api, false, _loader); +- +- return create(apiClass, url); +- } +- +- /** +- * Creates the Base64 value. +- */ +- private String base64(String value) +- { +- StringBuffer cb = new StringBuffer(); +- +- int i = 0; +- for (i = 0; i + 2 < value.length(); i += 3) { +- long chunk = (int) value.charAt(i); +- chunk = (chunk << 8) + (int) value.charAt(i + 1); +- chunk = (chunk << 8) + (int) value.charAt(i + 2); +- +- cb.append(encode(chunk >> 18)); +- cb.append(encode(chunk >> 12)); +- cb.append(encode(chunk >> 6)); +- cb.append(encode(chunk)); +- } +- +- if (i + 1 < value.length()) { +- long chunk = (int) value.charAt(i); +- chunk = (chunk << 8) + (int) value.charAt(i + 1); +- chunk <<= 8; +- +- cb.append(encode(chunk >> 18)); +- cb.append(encode(chunk >> 12)); +- cb.append(encode(chunk >> 6)); +- cb.append('='); +- } +- else if (i < value.length()) { +- long chunk = (int) value.charAt(i); +- chunk <<= 16; +- +- cb.append(encode(chunk >> 18)); +- cb.append(encode(chunk >> 12)); +- cb.append('='); +- cb.append('='); +- } +- +- return cb.toString(); +- } +- +- public static char encode(long d) +- { +- d &= 0x3f; +- if (d < 26) +- return (char) (d + 'A'); +- else if (d < 52) +- return (char) (d + 'a' - 26); +- else if (d < 62) +- return (char) (d + '0' - 52); +- else if (d == 62) +- return '+'; +- else +- return '/'; +- } +-} +- ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.PrintWriter; ++import java.lang.reflect.InvocationHandler; ++import java.lang.reflect.Proxy; ++import java.net.MalformedURLException; ++import java.net.URL; ++import java.util.Hashtable; ++import java.util.logging.Logger; ++ ++import javax.naming.Context; ++import javax.naming.Name; ++import javax.naming.NamingException; ++import javax.naming.RefAddr; ++import javax.naming.Reference; ++import javax.naming.spi.ObjectFactory; ++ ++import com.caucho.hessian.io.AbstractHessianInput; ++import com.caucho.hessian.io.AbstractHessianOutput; ++import com.caucho.hessian.io.Hessian2Input; ++import com.caucho.hessian.io.Hessian2Output; ++import com.caucho.hessian.io.HessianDebugInputStream; ++import com.caucho.hessian.io.HessianInput; ++import com.caucho.hessian.io.HessianOutput; ++import com.caucho.hessian.io.HessianRemoteObject; ++import com.caucho.hessian.io.HessianRemoteResolver; ++import com.caucho.hessian.io.SerializerFactory; ++import com.caucho.services.client.ServiceProxyFactory; ++ ++/** ++ * Factory for creating Hessian client stubs. The returned stub will ++ * call the remote object for all methods. ++ * ++ *
++ * String url = "http://localhost:8080/ejb/hello";
++ * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++ * 
++ * ++ * After creation, the stub can be like a regular Java class. Because ++ * it makes remote calls, it can throw more exceptions than a Java class. ++ * In particular, it may throw protocol exceptions. ++ * ++ * The factory can also be configured as a JNDI resource. The factory ++ * expects to parameters: "type" and "url", corresponding to the two ++ * arguments to create ++ * ++ * In Resin 3.0, the above example would be configured as: ++ *
++ * <reference>
++ *   <jndi-name>hessian/hello</jndi-name>
++ *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
++ *   <init-param url="http://localhost:8080/ejb/hello"/>
++ *   <init-param type="test.HelloHome"/>
++ * </reference>
++ * 
++ * ++ * To get the above resource, use JNDI as follows: ++ *
++ * Context ic = new InitialContext();
++ * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/hessian/hello");
++ *
++ * System.out.println("Hello: " + hello.helloWorld());
++ * 
++ * ++ *

Authentication

++ * ++ *

The proxy can use HTTP basic authentication if the user and the ++ * password are set. ++ */ ++public class HessianProxyFactory implements ServiceProxyFactory, ObjectFactory { ++ protected static Logger log ++ = Logger.getLogger(HessianProxyFactory.class.getName()); ++ ++ private final ClassLoader _loader; ++ ++ private SerializerFactory _serializerFactory; ++ ++ private HessianConnectionFactory _connFactory; ++ ++ private HessianRemoteResolver _resolver; ++ ++ private String _user; ++ private String _password; ++ private String _basicAuth; ++ ++ private boolean _isOverloadEnabled = false; ++ ++ private boolean _isHessian2Reply = true; ++ private boolean _isHessian2Request = false; ++ ++ private boolean _isChunkedPost = true; ++ private boolean _isDebug = false; ++ ++ private long _readTimeout = -1; ++ private long _connectTimeout = -1; ++ ++ /** ++ * Creates the new proxy factory. ++ */ ++ public HessianProxyFactory() ++ { ++ this(Thread.currentThread().getContextClassLoader()); ++ } ++ ++ /** ++ * Creates the new proxy factory. ++ */ ++ public HessianProxyFactory(ClassLoader loader) ++ { ++ _loader = loader; ++ _resolver = new HessianProxyResolver(this); ++ } ++ ++ /** ++ * Sets the user. ++ */ ++ public void setUser(String user) ++ { ++ _user = user; ++ _basicAuth = null; ++ } ++ ++ /** ++ * Sets the password. ++ */ ++ public void setPassword(String password) ++ { ++ _password = password; ++ _basicAuth = null; ++ } ++ ++ public String getBasicAuth() ++ { ++ if (_basicAuth != null) ++ return _basicAuth; ++ ++ else if (_user != null && _password != null) ++ return "Basic " + base64(_user + ":" + _password); ++ ++ else ++ return null; ++ } ++ ++ /** ++ * Sets the connection factory to use when connecting ++ * to the Hessian service. ++ */ ++ public void setConnectionFactory(HessianConnectionFactory factory) ++ { ++ _connFactory = factory; ++ } ++ ++ /** ++ * Returns the connection factory to be used for the HTTP request. ++ */ ++ public HessianConnectionFactory getConnectionFactory() ++ { ++ if (_connFactory == null) { ++ _connFactory = createHessianConnectionFactory(); ++ _connFactory.setHessianProxyFactory(this); ++ } ++ ++ return _connFactory; ++ } ++ ++ /** ++ * Sets the debug ++ */ ++ public void setDebug(boolean isDebug) ++ { ++ _isDebug = isDebug; ++ } ++ ++ /** ++ * Gets the debug ++ */ ++ public boolean isDebug() ++ { ++ return _isDebug; ++ } ++ ++ /** ++ * Returns true if overloaded methods are allowed (using mangling) ++ */ ++ public boolean isOverloadEnabled() ++ { ++ return _isOverloadEnabled; ++ } ++ ++ /** ++ * set true if overloaded methods are allowed (using mangling) ++ */ ++ public void setOverloadEnabled(boolean isOverloadEnabled) ++ { ++ _isOverloadEnabled = isOverloadEnabled; ++ } ++ ++ /** ++ * Set true if should use chunked encoding on the request. ++ */ ++ public void setChunkedPost(boolean isChunked) ++ { ++ _isChunkedPost = isChunked; ++ } ++ ++ /** ++ * Set true if should use chunked encoding on the request. ++ */ ++ public boolean isChunkedPost() ++ { ++ return _isChunkedPost; ++ } ++ ++ /** ++ * The socket timeout on requests in milliseconds. ++ */ ++ public long getReadTimeout() ++ { ++ return _readTimeout; ++ } ++ ++ /** ++ * The socket timeout on requests in milliseconds. ++ */ ++ public void setReadTimeout(long timeout) ++ { ++ _readTimeout = timeout; ++ } ++ ++ /** ++ * The socket connection timeout in milliseconds. ++ */ ++ public long getConnectTimeout() ++ { ++ return _connectTimeout; ++ } ++ ++ /** ++ * The socket connect timeout in milliseconds. ++ */ ++ public void setConnectTimeout(long timeout) ++ { ++ _connectTimeout = timeout; ++ } ++ ++ /** ++ * True if the proxy can read Hessian 2 responses. ++ */ ++ public void setHessian2Reply(boolean isHessian2) ++ { ++ _isHessian2Reply = isHessian2; ++ } ++ ++ /** ++ * True if the proxy should send Hessian 2 requests. ++ */ ++ public void setHessian2Request(boolean isHessian2) ++ { ++ _isHessian2Request = isHessian2; ++ ++ if (isHessian2) ++ _isHessian2Reply = true; ++ } ++ ++ /** ++ * Returns the remote resolver. ++ */ ++ public HessianRemoteResolver getRemoteResolver() ++ { ++ return _resolver; ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(_loader); ++ ++ return _serializerFactory; ++ } ++ ++ protected HessianConnectionFactory createHessianConnectionFactory() ++ { ++ String className ++ = System.getProperty(HessianConnectionFactory.class.getName()); ++ ++ HessianConnectionFactory factory = null; ++ ++ try { ++ if (className != null) { ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ Class cl = Class.forName(className, false, loader); ++ ++ factory = (HessianConnectionFactory) cl.newInstance(); ++ ++ return factory; ++ } ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ ++ return new HessianURLConnectionFactory(); ++ } ++ /** ++ * Creates a new proxy with the specified URL. The API class uses ++ * the java.api.class value from _hessian_ ++ * ++ * @param url the URL where the client object is located. ++ * ++ * @return a proxy to the object with the specified interface. ++ */ ++ public Object create(String url) ++ throws MalformedURLException, ClassNotFoundException ++ { ++ HessianMetaInfoAPI metaInfo; ++ ++ metaInfo = (HessianMetaInfoAPI) create(HessianMetaInfoAPI.class, url); ++ ++ String apiClassName = ++ (String) metaInfo._hessian_getAttribute("java.api.class"); ++ ++ if (apiClassName == null) ++ throw new HessianRuntimeException(url + " has an unknown api."); ++ ++ Class apiClass = Class.forName(apiClassName, false, _loader); ++ ++ return create(apiClass, url); ++ } ++ ++ /** ++ * Creates a new proxy with the specified URL. The returned object ++ * is a proxy with the interface specified by api. ++ * ++ *

++   * String url = "http://localhost:8080/ejb/hello");
++   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++   * 
++ * ++ * @param api the interface the proxy class needs to implement ++ * @param url the URL where the client object is located. ++ * ++ * @return a proxy to the object with the specified interface. ++ */ ++ public Object create(Class api, String urlName) ++ throws MalformedURLException ++ { ++ return create(api, urlName, _loader); ++ } ++ ++ /** ++ * Creates a new proxy with the specified URL. The returned object ++ * is a proxy with the interface specified by api. ++ * ++ *
++   * String url = "http://localhost:8080/ejb/hello");
++   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++   * 
++ * ++ * @param api the interface the proxy class needs to implement ++ * @param url the URL where the client object is located. ++ * ++ * @return a proxy to the object with the specified interface. ++ */ ++ public Object create(Class api, String urlName, ClassLoader loader) ++ throws MalformedURLException ++ { ++ URL url = new URL(urlName); ++ ++ return create(api, url, loader); ++ } ++ ++ /** ++ * Creates a new proxy with the specified URL. The returned object ++ * is a proxy with the interface specified by api. ++ * ++ *
++   * String url = "http://localhost:8080/ejb/hello");
++   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++   * 
++ * ++ * @param api the interface the proxy class needs to implement ++ * @param url the URL where the client object is located. ++ * ++ * @return a proxy to the object with the specified interface. ++ */ ++ public Object create(Class api, URL url, ClassLoader loader) ++ { ++ if (api == null) ++ throw new NullPointerException("api must not be null for HessianProxyFactory.create()"); ++ InvocationHandler handler = null; ++ ++ handler = new HessianProxy(url, this, api); ++ ++ return Proxy.newProxyInstance(loader, ++ new Class[] { api, ++ HessianRemoteObject.class }, ++ handler); ++ } ++ ++ public AbstractHessianInput getHessianInput(InputStream is) ++ { ++ return getHessian2Input(is); ++ } ++ ++ public AbstractHessianInput getHessian1Input(InputStream is) ++ { ++ AbstractHessianInput in; ++ ++ if (_isDebug) ++ is = new HessianDebugInputStream(is, new PrintWriter(System.out)); ++ ++ in = new HessianInput(is); ++ ++ in.setRemoteResolver(getRemoteResolver()); ++ ++ in.setSerializerFactory(getSerializerFactory()); ++ ++ return in; ++ } ++ ++ public AbstractHessianInput getHessian2Input(InputStream is) ++ { ++ AbstractHessianInput in; ++ ++ if (_isDebug) ++ is = new HessianDebugInputStream(is, new PrintWriter(System.out)); ++ ++ in = new Hessian2Input(is); ++ ++ in.setRemoteResolver(getRemoteResolver()); ++ ++ in.setSerializerFactory(getSerializerFactory()); ++ ++ return in; ++ } ++ ++ public AbstractHessianOutput getHessianOutput(OutputStream os) ++ { ++ AbstractHessianOutput out; ++ ++ if (_isHessian2Request) ++ out = new Hessian2Output(os); ++ else { ++ HessianOutput out1 = new HessianOutput(os); ++ out = out1; ++ ++ if (_isHessian2Reply) ++ out1.setVersion(2); ++ } ++ ++ out.setSerializerFactory(getSerializerFactory()); ++ ++ return out; ++ } ++ ++ /** ++ * JNDI object factory so the proxy can be used as a resource. ++ */ ++ public Object getObjectInstance(Object obj, Name name, ++ Context nameCtx, Hashtable environment) ++ throws Exception ++ { ++ Reference ref = (Reference) obj; ++ ++ String api = null; ++ String url = null; ++ ++ for (int i = 0; i < ref.size(); i++) { ++ RefAddr addr = ref.get(i); ++ ++ String type = addr.getType(); ++ String value = (String) addr.getContent(); ++ ++ if (type.equals("type")) ++ api = value; ++ else if (type.equals("url")) ++ url = value; ++ else if (type.equals("user")) ++ setUser(value); ++ else if (type.equals("password")) ++ setPassword(value); ++ } ++ ++ if (url == null) ++ throw new NamingException("`url' must be configured for HessianProxyFactory."); ++ // XXX: could use meta protocol to grab this ++ if (api == null) ++ throw new NamingException("`type' must be configured for HessianProxyFactory."); ++ ++ Class apiClass = Class.forName(api, false, _loader); ++ ++ return create(apiClass, url); ++ } ++ ++ /** ++ * Creates the Base64 value. ++ */ ++ private String base64(String value) ++ { ++ StringBuffer cb = new StringBuffer(); ++ ++ int i = 0; ++ for (i = 0; i + 2 < value.length(); i += 3) { ++ long chunk = (int) value.charAt(i); ++ chunk = (chunk << 8) + (int) value.charAt(i + 1); ++ chunk = (chunk << 8) + (int) value.charAt(i + 2); ++ ++ cb.append(encode(chunk >> 18)); ++ cb.append(encode(chunk >> 12)); ++ cb.append(encode(chunk >> 6)); ++ cb.append(encode(chunk)); ++ } ++ ++ if (i + 1 < value.length()) { ++ long chunk = (int) value.charAt(i); ++ chunk = (chunk << 8) + (int) value.charAt(i + 1); ++ chunk <<= 8; ++ ++ cb.append(encode(chunk >> 18)); ++ cb.append(encode(chunk >> 12)); ++ cb.append(encode(chunk >> 6)); ++ cb.append('='); ++ } ++ else if (i < value.length()) { ++ long chunk = (int) value.charAt(i); ++ chunk <<= 16; ++ ++ cb.append(encode(chunk >> 18)); ++ cb.append(encode(chunk >> 12)); ++ cb.append('='); ++ cb.append('='); ++ } ++ ++ return cb.toString(); ++ } ++ ++ public static char encode(long d) ++ { ++ d &= 0x3f; ++ if (d < 26) ++ return (char) (d + 'A'); ++ else if (d < 52) ++ return (char) (d + 'a' - 26); ++ else if (d < 62) ++ return (char) (d + '0' - 52); ++ else if (d == 62) ++ return '+'; ++ else ++ return '/'; ++ } ++} ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyResolver.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyResolver.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyResolver.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyResolver.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,85 +1,85 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import com.caucho.hessian.io.HessianRemoteResolver; +- +-import java.io.IOException; +- +-/** +- * Looks up remote objects in the proxy. +- */ +-public class HessianProxyResolver implements HessianRemoteResolver { +- private HessianProxyFactory _factory; +- +- /** +- * Creates an uninitialized Hessian remote resolver. +- */ +- public HessianProxyResolver(HessianProxyFactory factory) +- { +- _factory = factory; +- } +- +- /** +- * Looks up a proxy object. +- */ +- public Object lookup(String type, String url) +- throws IOException +- { +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- +- try { +- Class api = Class.forName(type, false, loader); +- +- return _factory.create(api, url); +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import com.caucho.hessian.io.HessianRemoteResolver; ++ ++import java.io.IOException; ++ ++/** ++ * Looks up remote objects in the proxy. ++ */ ++public class HessianProxyResolver implements HessianRemoteResolver { ++ private HessianProxyFactory _factory; ++ ++ /** ++ * Creates an uninitialized Hessian remote resolver. ++ */ ++ public HessianProxyResolver(HessianProxyFactory factory) ++ { ++ _factory = factory; ++ } ++ ++ /** ++ * Looks up a proxy object. ++ */ ++ public Object lookup(String type, String url) ++ throws IOException ++ { ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ try { ++ Class api = Class.forName(type, false, loader); ++ ++ return _factory.create(api, url); ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianRuntimeException.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianRuntimeException.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianRuntimeException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianRuntimeException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,107 +1,107 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-/** +- * Wrapper for protocol exceptions thrown in the proxy. +- */ +-public class HessianRuntimeException extends RuntimeException { +- private Throwable rootCause; +- +- /** +- * Zero-arg constructor. +- */ +- public HessianRuntimeException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public HessianRuntimeException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public HessianRuntimeException(String message, Throwable rootCause) +- { +- super(message); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Create the exception. +- */ +- public HessianRuntimeException(Throwable rootCause) +- { +- super(String.valueOf(rootCause)); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getRootCause() +- { +- return this.rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getCause() +- { +- return getRootCause(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++/** ++ * Wrapper for protocol exceptions thrown in the proxy. ++ */ ++public class HessianRuntimeException extends RuntimeException { ++ private Throwable rootCause; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public HessianRuntimeException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianRuntimeException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianRuntimeException(String message, Throwable rootCause) ++ { ++ super(message); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianRuntimeException(Throwable rootCause) ++ { ++ super(String.valueOf(rootCause)); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getRootCause() ++ { ++ return this.rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getCause() ++ { ++ return getRootCause(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnection.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnection.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnection.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnection.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,219 +1,219 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import java.net.URL; +-import java.net.URLConnection; +-import java.net.HttpURLConnection; +-import java.util.zip.Inflater; +-import java.util.zip.InflaterInputStream; +- +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.IOException; +-import java.io.FileNotFoundException; +- +-/** +- * Internal connection to a server. The default connection is based on +- * java.net +- */ +-public class HessianURLConnection extends AbstractHessianConnection { +- private URL _url; +- private URLConnection _conn; +- +- private int _statusCode; +- private String _statusMessage; +- +- private InputStream _inputStream; +- private InputStream _errorStream; +- +- HessianURLConnection(URL url, URLConnection conn) +- { +- _url = url; +- _conn = conn; +- } +- +- /** +- * Adds a HTTP header. +- */ +- @Override +- public void addHeader(String key, String value) +- { +- _conn.setRequestProperty(key, value); +- } +- +- /** +- * Returns the output stream for the request. +- */ +- public OutputStream getOutputStream() +- throws IOException +- { +- return _conn.getOutputStream(); +- } +- +- /** +- * Sends the request +- */ +- public void sendRequest() +- throws IOException +- { +- if (_conn instanceof HttpURLConnection) { +- HttpURLConnection httpConn = (HttpURLConnection) _conn; +- +- _statusCode = 500; +- +- try { +- _statusCode = httpConn.getResponseCode(); +- } catch (Exception e) { +- } +- +- parseResponseHeaders(httpConn); +- +- InputStream is = null; +- +- if (_statusCode != 200) { +- StringBuffer sb = new StringBuffer(); +- int ch; +- +- try { +- is = httpConn.getInputStream(); +- +- if (is != null) { +- while ((ch = is.read()) >= 0) +- sb.append((char) ch); +- +- is.close(); +- } +- +- is = httpConn.getErrorStream(); +- if (is != null) { +- while ((ch = is.read()) >= 0) +- sb.append((char) ch); +- } +- +- _statusMessage = sb.toString(); +- } catch (FileNotFoundException e) { +- throw new HessianConnectionException("HessianProxy cannot connect to '" + _url, e); +- } catch (IOException e) { +- if (is == null) +- throw new HessianConnectionException(_statusCode + ": " + e, e); +- else +- throw new HessianConnectionException(_statusCode + ": " + sb, e); +- } +- +- if (is != null) +- is.close(); +- +- throw new HessianConnectionException(_statusCode + ": " + sb.toString()); +- } +- } +- } +- +- protected void parseResponseHeaders(HttpURLConnection conn) +- throws IOException +- { +- } +- +- /** +- * Returns the status code. +- */ +- public int getStatusCode() +- { +- return _statusCode; +- } +- +- /** +- * Returns the status string. +- */ +- public String getStatusMessage() +- { +- return _statusMessage; +- } +- +- /** +- * Returns the InputStream to the result +- */ +- @Override +- public InputStream getInputStream() +- throws IOException +- { +- return _conn.getInputStream(); +- } +- +- @Override +- public String getContentEncoding() +- { +- return _conn.getContentEncoding(); +- } +- +- /** +- * Close/free the connection +- */ +- @Override +- public void close() +- { +- _inputStream = null; +- } +- +- /** +- * Disconnect the connection +- */ +- @Override +- public void destroy() +- { +- close(); +- +- URLConnection conn = _conn; +- _conn = null; +- +- if (conn instanceof HttpURLConnection) +- ((HttpURLConnection) conn).disconnect(); +- } +-} +- ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import java.net.URL; ++import java.net.URLConnection; ++import java.net.HttpURLConnection; ++import java.util.zip.Inflater; ++import java.util.zip.InflaterInputStream; ++ ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.IOException; ++import java.io.FileNotFoundException; ++ ++/** ++ * Internal connection to a server. The default connection is based on ++ * java.net ++ */ ++public class HessianURLConnection extends AbstractHessianConnection { ++ private URL _url; ++ private URLConnection _conn; ++ ++ private int _statusCode; ++ private String _statusMessage; ++ ++ private InputStream _inputStream; ++ private InputStream _errorStream; ++ ++ HessianURLConnection(URL url, URLConnection conn) ++ { ++ _url = url; ++ _conn = conn; ++ } ++ ++ /** ++ * Adds a HTTP header. ++ */ ++ @Override ++ public void addHeader(String key, String value) ++ { ++ _conn.setRequestProperty(key, value); ++ } ++ ++ /** ++ * Returns the output stream for the request. ++ */ ++ public OutputStream getOutputStream() ++ throws IOException ++ { ++ return _conn.getOutputStream(); ++ } ++ ++ /** ++ * Sends the request ++ */ ++ public void sendRequest() ++ throws IOException ++ { ++ if (_conn instanceof HttpURLConnection) { ++ HttpURLConnection httpConn = (HttpURLConnection) _conn; ++ ++ _statusCode = 500; ++ ++ try { ++ _statusCode = httpConn.getResponseCode(); ++ } catch (Exception e) { ++ } ++ ++ parseResponseHeaders(httpConn); ++ ++ InputStream is = null; ++ ++ if (_statusCode != 200) { ++ StringBuffer sb = new StringBuffer(); ++ int ch; ++ ++ try { ++ is = httpConn.getInputStream(); ++ ++ if (is != null) { ++ while ((ch = is.read()) >= 0) ++ sb.append((char) ch); ++ ++ is.close(); ++ } ++ ++ is = httpConn.getErrorStream(); ++ if (is != null) { ++ while ((ch = is.read()) >= 0) ++ sb.append((char) ch); ++ } ++ ++ _statusMessage = sb.toString(); ++ } catch (FileNotFoundException e) { ++ throw new HessianConnectionException("HessianProxy cannot connect to '" + _url, e); ++ } catch (IOException e) { ++ if (is == null) ++ throw new HessianConnectionException(_statusCode + ": " + e, e); ++ else ++ throw new HessianConnectionException(_statusCode + ": " + sb, e); ++ } ++ ++ if (is != null) ++ is.close(); ++ ++ throw new HessianConnectionException(_statusCode + ": " + sb.toString()); ++ } ++ } ++ } ++ ++ protected void parseResponseHeaders(HttpURLConnection conn) ++ throws IOException ++ { ++ } ++ ++ /** ++ * Returns the status code. ++ */ ++ public int getStatusCode() ++ { ++ return _statusCode; ++ } ++ ++ /** ++ * Returns the status string. ++ */ ++ public String getStatusMessage() ++ { ++ return _statusMessage; ++ } ++ ++ /** ++ * Returns the InputStream to the result ++ */ ++ @Override ++ public InputStream getInputStream() ++ throws IOException ++ { ++ return _conn.getInputStream(); ++ } ++ ++ @Override ++ public String getContentEncoding() ++ { ++ return _conn.getContentEncoding(); ++ } ++ ++ /** ++ * Close/free the connection ++ */ ++ @Override ++ public void close() ++ { ++ _inputStream = null; ++ } ++ ++ /** ++ * Disconnect the connection ++ */ ++ @Override ++ public void destroy() ++ { ++ close(); ++ ++ URLConnection conn = _conn; ++ _conn = null; ++ ++ if (conn instanceof HttpURLConnection) ++ ((HttpURLConnection) conn).disconnect(); ++ } ++} ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnectionFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnectionFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnectionFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnectionFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,120 +1,120 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.client; +- +-import java.net.URL; +-import java.net.URLConnection; +-import java.net.HttpURLConnection; +- +-import java.io.IOException; +- +-import java.util.logging.Logger; +-import java.util.logging.Level; +- +-/** +- * Internal factory for creating connections to the server. The default +- * factory is java.net +- */ +-public class HessianURLConnectionFactory implements HessianConnectionFactory { +- private static final Logger log +- = Logger.getLogger(HessianURLConnectionFactory.class.getName()); +- +- private HessianProxyFactory _proxyFactory; +- +- public void setHessianProxyFactory(HessianProxyFactory factory) +- { +- _proxyFactory = factory; +- } +- +- /** +- * Opens a new or recycled connection to the HTTP server. +- */ +- public HessianConnection open(URL url) +- throws IOException +- { +- if (log.isLoggable(Level.FINER)) +- log.finer(this + " open(" + url + ")"); +- +- URLConnection conn = url.openConnection(); +- +- // HttpURLConnection httpConn = (HttpURLConnection) conn; +- // httpConn.setRequestMethod("POST"); +- // conn.setDoInput(true); +- +- long connectTimeout = _proxyFactory.getConnectTimeout(); +- +- if (connectTimeout >= 0) +- conn.setConnectTimeout((int) connectTimeout); +- +- conn.setDoOutput(true); +- +- long readTimeout = _proxyFactory.getReadTimeout(); +- +- if (readTimeout > 0) { +- try { +- conn.setReadTimeout((int) readTimeout); +- } catch (Throwable e) { +- } +- } +- +- /* +- // Used chunked mode when available, i.e. JDK 1.5. +- if (_proxyFactory.isChunkedPost() && conn instanceof HttpURLConnection) { +- try { +- HttpURLConnection httpConn = (HttpURLConnection) conn; +- +- httpConn.setChunkedStreamingMode(8 * 1024); +- } catch (Throwable e) { +- } +- } +- */ +- +- return new HessianURLConnection(url, conn); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.client; ++ ++import java.net.URL; ++import java.net.URLConnection; ++import java.net.HttpURLConnection; ++ ++import java.io.IOException; ++ ++import java.util.logging.Logger; ++import java.util.logging.Level; ++ ++/** ++ * Internal factory for creating connections to the server. The default ++ * factory is java.net ++ */ ++public class HessianURLConnectionFactory implements HessianConnectionFactory { ++ private static final Logger log ++ = Logger.getLogger(HessianURLConnectionFactory.class.getName()); ++ ++ private HessianProxyFactory _proxyFactory; ++ ++ public void setHessianProxyFactory(HessianProxyFactory factory) ++ { ++ _proxyFactory = factory; ++ } ++ ++ /** ++ * Opens a new or recycled connection to the HTTP server. ++ */ ++ public HessianConnection open(URL url) ++ throws IOException ++ { ++ if (log.isLoggable(Level.FINER)) ++ log.finer(this + " open(" + url + ")"); ++ ++ URLConnection conn = url.openConnection(); ++ ++ // HttpURLConnection httpConn = (HttpURLConnection) conn; ++ // httpConn.setRequestMethod("POST"); ++ // conn.setDoInput(true); ++ ++ long connectTimeout = _proxyFactory.getConnectTimeout(); ++ ++ if (connectTimeout >= 0) ++ conn.setConnectTimeout((int) connectTimeout); ++ ++ conn.setDoOutput(true); ++ ++ long readTimeout = _proxyFactory.getReadTimeout(); ++ ++ if (readTimeout > 0) { ++ try { ++ conn.setReadTimeout((int) readTimeout); ++ } catch (Throwable e) { ++ } ++ } ++ ++ /* ++ // Used chunked mode when available, i.e. JDK 1.5. ++ if (_proxyFactory.isChunkedPost() && conn instanceof HttpURLConnection) { ++ try { ++ HttpURLConnection httpConn = (HttpURLConnection) conn; ++ ++ httpConn.setChunkedStreamingMode(8 * 1024); ++ } catch (Throwable e) { ++ } ++ } ++ */ ++ ++ return new HessianURLConnection(url, conn); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/package.html hessian-4.0.65-fix/com/caucho/hessian/client/package.html +--- hessian-4.0.65-src/com/caucho/hessian/client/package.html 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/client/package.html 2023-08-15 18:39:22.000000000 +0800 +@@ -1,59 +1,59 @@ +- +- +-Portable client code for using Hessian services. Since this package is +-independent of all Resin code, its classes can be copied to a +-non-Resin client jar. +- +-

RPC Proxy Clients - HessianProxyFactory

+- +-Most application clients will use HessianProxyFactory to +-create stub objects. The stub objects can be called with normal +-Java calls. Because the objects are remote, the client application needs +-to be able to deal with IOException caused by an unavailable server or +-a protocol error. +- +-
+-import com.caucho.hessian.client.HessianProxyFactory;
+-
+-...
+-
+-URL url = new URL("http://localhost:8080/ejb/hello");
+-HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+-
+-System.out.println("hello: " + hello.hello());
+-
+- +-

Serialization

+- +-Since the Hessian protocol serializes Java objects to XML, the +-HessianSerializerOutput and HessianSerializerInput +-can be used for serialization. +- +-

Serialization

+-
+-OutputStream os = new FileOutputStream("test.xml");
+-HessianOutput out = new HessianSerializerOutput(os);
+-
+-out.writeObject(obj);
+-os.close();
+-
+- +-

Deserialization

+-
+-InputStream is = new FileInputStream("test.xml");
+-HessianInput in = new HessianSerializerInput(in);
+-
+-Object obj = in.readObject();
+-
+-is.close();
+-
+- +-

MicroHessianInput and MicroHessianOutput

+- +-These two classes only require classes from Java MicroEdition. So they +-can be extracted separately into a hessian-micro.jar. Because of this +-restriction and their small size, these two classes +-are ideal for limited size devices like mobile phones and PDAs. +- +- ++ ++ ++Portable client code for using Hessian services. Since this package is ++independent of all Resin code, its classes can be copied to a ++non-Resin client jar. ++ ++

RPC Proxy Clients - HessianProxyFactory

++ ++Most application clients will use HessianProxyFactory to ++create stub objects. The stub objects can be called with normal ++Java calls. Because the objects are remote, the client application needs ++to be able to deal with IOException caused by an unavailable server or ++a protocol error. ++ ++
++import com.caucho.hessian.client.HessianProxyFactory;
++
++...
++
++URL url = new URL("http://localhost:8080/ejb/hello");
++HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++
++System.out.println("hello: " + hello.hello());
++
++ ++

Serialization

++ ++Since the Hessian protocol serializes Java objects to XML, the ++HessianSerializerOutput and HessianSerializerInput ++can be used for serialization. ++ ++

Serialization

++
++OutputStream os = new FileOutputStream("test.xml");
++HessianOutput out = new HessianSerializerOutput(os);
++
++out.writeObject(obj);
++os.close();
++
++ ++

Deserialization

++
++InputStream is = new FileInputStream("test.xml");
++HessianInput in = new HessianSerializerInput(in);
++
++Object obj = in.readObject();
++
++is.close();
++
++ ++

MicroHessianInput and MicroHessianOutput

++ ++These two classes only require classes from Java MicroEdition. So they ++can be extracted separately into a hessian-micro.jar. Because of this ++restriction and their small size, these two classes ++are ideal for limited size devices like mobile phones and PDAs. ++ ++ + +\ No newline at end of file +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,169 +1,169 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Deserializing an object. +- */ +-public class AbstractDeserializer implements Deserializer { +- public static final NullDeserializer NULL = new NullDeserializer(); +- +- public Class getType() +- { +- return Object.class; +- } +- +- public boolean isReadResolve() +- { +- return false; +- } +- +- public Object readObject(AbstractHessianInput in) +- throws IOException +- { +- Object obj = in.readObject(); +- +- String className = getClass().getName(); +- +- if (obj != null) +- throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); +- else +- throw error(className + ": unexpected null value"); +- } +- +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- throw new UnsupportedOperationException(String.valueOf(this)); +- } +- +- public Object readLengthList(AbstractHessianInput in, int length) +- throws IOException +- { +- throw new UnsupportedOperationException(String.valueOf(this)); +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- Object obj = in.readObject(); +- +- String className = getClass().getName(); +- +- if (obj != null) +- throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); +- else +- throw error(className + ": unexpected null value"); +- } +- +- /** +- * Creates the field array for a class. The default +- * implementation returns a String[] array. +- * +- * @param len number of items in the array +- * @return the new empty array +- */ +- public Object []createFields(int len) +- { +- return new String[len]; +- } +- +- /** +- * Creates a field value class. The default +- * implementation returns the String. +- * +- * @param len number of items in the array +- * @return the new empty array +- */ +- public Object createField(String name) +- { +- return name; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, +- String []fieldNames) +- throws IOException +- { +- return readObject(in, (Object []) fieldNames); +- } +- +- /** +- * Reads an object instance from the input stream +- */ +- @Override +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException +- { +- throw new UnsupportedOperationException(toString()); +- } +- +- protected HessianProtocolException error(String msg) +- { +- return new HessianProtocolException(msg); +- } +- +- protected String codeName(int ch) +- { +- if (ch < 0) +- return "end of file"; +- else +- return "0x" + Integer.toHexString(ch & 0xff); +- } +- +- /** +- * The NullDeserializer exists as a marker for the factory classes so +- * they save a null result. +- */ +- static final class NullDeserializer extends AbstractDeserializer { +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Deserializing an object. ++ */ ++public class AbstractDeserializer implements Deserializer { ++ public static final NullDeserializer NULL = new NullDeserializer(); ++ ++ public Class getType() ++ { ++ return Object.class; ++ } ++ ++ public boolean isReadResolve() ++ { ++ return false; ++ } ++ ++ public Object readObject(AbstractHessianInput in) ++ throws IOException ++ { ++ Object obj = in.readObject(); ++ ++ String className = getClass().getName(); ++ ++ if (obj != null) ++ throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); ++ else ++ throw error(className + ": unexpected null value"); ++ } ++ ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(String.valueOf(this)); ++ } ++ ++ public Object readLengthList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(String.valueOf(this)); ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ Object obj = in.readObject(); ++ ++ String className = getClass().getName(); ++ ++ if (obj != null) ++ throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); ++ else ++ throw error(className + ": unexpected null value"); ++ } ++ ++ /** ++ * Creates the field array for a class. The default ++ * implementation returns a String[] array. ++ * ++ * @param len number of items in the array ++ * @return the new empty array ++ */ ++ public Object []createFields(int len) ++ { ++ return new String[len]; ++ } ++ ++ /** ++ * Creates a field value class. The default ++ * implementation returns the String. ++ * ++ * @param len number of items in the array ++ * @return the new empty array ++ */ ++ public Object createField(String name) ++ { ++ return name; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ String []fieldNames) ++ throws IOException ++ { ++ return readObject(in, (Object []) fieldNames); ++ } ++ ++ /** ++ * Reads an object instance from the input stream ++ */ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(toString()); ++ } ++ ++ protected HessianProtocolException error(String msg) ++ { ++ return new HessianProtocolException(msg); ++ } ++ ++ protected String codeName(int ch) ++ { ++ if (ch < 0) ++ return "end of file"; ++ else ++ return "0x" + Integer.toHexString(ch & 0xff); ++ } ++ ++ /** ++ * The NullDeserializer exists as a marker for the factory classes so ++ * they save a null result. ++ */ ++ static final class NullDeserializer extends AbstractDeserializer { ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializerWrapper.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializerWrapper.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializerWrapper.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializerWrapper.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,143 +1,143 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Deserializing an object. +- */ +-abstract public class AbstractDeserializerWrapper implements Deserializer { +- abstract protected Deserializer getDelegate(); +- +- @Override +- public Class getType() +- { +- return getDelegate().getType(); +- } +- +- @Override +- public boolean isReadResolve() +- { +- return getDelegate().isReadResolve(); +- } +- +- @Override +- public Object readObject(AbstractHessianInput in) +- throws IOException +- { +- return getDelegate().readObject(in); +- } +- +- @Override +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- return getDelegate().readList(in, length); +- } +- +- @Override +- public Object readLengthList(AbstractHessianInput in, int length) +- throws IOException +- { +- return getDelegate().readLengthList(in, length); +- } +- +- @Override +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- return getDelegate().readMap(in); +- } +- +- /** +- * Creates the field array for a class. The default +- * implementation returns a String[] array. +- * +- * @param len number of items in the array +- * @return the new empty array +- */ +- @Override +- public Object []createFields(int len) +- { +- return getDelegate().createFields(len); +- } +- +- /** +- * Creates a field value class. The default +- * implementation returns the String. +- * +- * @param len number of items in the array +- * @return the new empty array +- */ +- @Override +- public Object createField(String name) +- { +- return getDelegate().createField(name); +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, +- String []fieldNames) +- throws IOException +- { +- return getDelegate().readObject(in, fieldNames); +- } +- +- /** +- * Reads an object instance from the input stream +- */ +- @Override +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException +- { +- return getDelegate().readObject(in, fields); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Deserializing an object. ++ */ ++abstract public class AbstractDeserializerWrapper implements Deserializer { ++ abstract protected Deserializer getDelegate(); ++ ++ @Override ++ public Class getType() ++ { ++ return getDelegate().getType(); ++ } ++ ++ @Override ++ public boolean isReadResolve() ++ { ++ return getDelegate().isReadResolve(); ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in) ++ throws IOException ++ { ++ return getDelegate().readObject(in); ++ } ++ ++ @Override ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ return getDelegate().readList(in, length); ++ } ++ ++ @Override ++ public Object readLengthList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ return getDelegate().readLengthList(in, length); ++ } ++ ++ @Override ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ return getDelegate().readMap(in); ++ } ++ ++ /** ++ * Creates the field array for a class. The default ++ * implementation returns a String[] array. ++ * ++ * @param len number of items in the array ++ * @return the new empty array ++ */ ++ @Override ++ public Object []createFields(int len) ++ { ++ return getDelegate().createFields(len); ++ } ++ ++ /** ++ * Creates a field value class. The default ++ * implementation returns the String. ++ * ++ * @param len number of items in the array ++ * @return the new empty array ++ */ ++ @Override ++ public Object createField(String name) ++ { ++ return getDelegate().createField(name); ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ String []fieldNames) ++ throws IOException ++ { ++ return getDelegate().readObject(in, fieldNames); ++ } ++ ++ /** ++ * Reads an object instance from the input stream ++ */ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ return getDelegate().readObject(in, fields); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianInput.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianInput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,487 +1,487 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.Reader; +- +-/** +- * Abstract base class for Hessian requests. Hessian users should only +- * need to use the methods in this class. +- * +- *
+- * AbstractHessianInput in = ...; // get input
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-abstract public class AbstractHessianInput { +- private HessianRemoteResolver resolver; +- private byte []_buffer; +- +- /** +- * Initialize the Hessian stream with the underlying input stream. +- */ +- public void init(InputStream is) +- { +- } +- +- /** +- * Returns the call's method +- */ +- abstract public String getMethod(); +- +- /** +- * Sets the resolver used to lookup remote objects. +- */ +- public void setRemoteResolver(HessianRemoteResolver resolver) +- { +- this.resolver = resolver; +- } +- +- /** +- * Sets the resolver used to lookup remote objects. +- */ +- public HessianRemoteResolver getRemoteResolver() +- { +- return resolver; +- } +- +- /** +- * Sets the serializer factory. +- */ +- public void setSerializerFactory(SerializerFactory ser) +- { +- } +- +- /** +- * Reads the call +- * +- *
+-   * c major minor
+-   * 
+- */ +- abstract public int readCall() +- throws IOException; +- +- /** +- * For backward compatibility with HessianSkeleton +- */ +- public void skipOptionalCall() +- throws IOException +- { +- } +- +- /** +- * Reads a header, returning null if there are no headers. +- * +- *
+-   * H b16 b8 value
+-   * 
+- */ +- abstract public String readHeader() +- throws IOException; +- +- /** +- * Starts reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * m b16 b8 method
+-   * 
+- */ +- abstract public String readMethod() +- throws IOException; +- +- /** +- * Reads the number of method arguments +- * +- * @return -1 for a variable length (hessian 1.0) +- */ +- public int readMethodArgLength() +- throws IOException +- { +- return -1; +- } +- +- /** +- * Starts reading the call, including the headers. +- * +- *

The call expects the following protocol data +- * +- *

+-   * c major minor
+-   * m b16 b8 method
+-   * 
+- */ +- abstract public void startCall() +- throws IOException; +- +- /** +- * Completes reading the call +- * +- *

The call expects the following protocol data +- * +- *

+-   * Z
+-   * 
+- */ +- abstract public void completeCall() +- throws IOException; +- +- /** +- * Reads a reply as an object. +- * If the reply has a fault, throws the exception. +- */ +- abstract public Object readReply(Class expectedClass) +- throws Throwable; +- +- /** +- * Starts reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * r
+-   * v
+-   * 
+- */ +- abstract public void startReply() +- throws Throwable; +- +- /** +- * Starts reading the body of the reply, i.e. after the 'r' has been +- * parsed. +- */ +- public void startReplyBody() +- throws Throwable +- { +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- abstract public void completeReply() +- throws IOException; +- +- /** +- * Reads a boolean +- * +- *
+-   * T
+-   * F
+-   * 
+- */ +- abstract public boolean readBoolean() +- throws IOException; +- +- /** +- * Reads a null +- * +- *
+-   * N
+-   * 
+- */ +- abstract public void readNull() +- throws IOException; +- +- /** +- * Reads an integer +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- */ +- abstract public int readInt() +- throws IOException; +- +- /** +- * Reads a long +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- abstract public long readLong() +- throws IOException; +- +- /** +- * Reads a double. +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- abstract public double readDouble() +- throws IOException; +- +- /** +- * Reads a date. +- * +- *
+-   * T b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- abstract public long readUTCDate() +- throws IOException; +- +- /** +- * Reads a string encoded in UTF-8 +- * +- *
+-   * s b16 b8 non-final string chunk
+-   * S b16 b8 final string chunk
+-   * 
+- */ +- abstract public String readString() +- throws IOException; +- +- /** +- * Reads an XML node encoded in UTF-8 +- * +- *
+-   * x b16 b8 non-final xml chunk
+-   * X b16 b8 final xml chunk
+-   * 
+- */ +- public org.w3c.dom.Node readNode() +- throws IOException +- { +- throw new UnsupportedOperationException(getClass().getSimpleName()); +- } +- +- /** +- * Starts reading a string. All the characters must be read before +- * calling the next method. The actual characters will be read with +- * the reader's read() or read(char [], int, int). +- * +- *
+-   * s b16 b8 non-final string chunk
+-   * S b16 b8 final string chunk
+-   * 
+- */ +- abstract public Reader getReader() +- throws IOException; +- +- /** +- * Starts reading a byte array using an input stream. All the bytes +- * must be read before calling the following method. +- * +- *
+-   * b b16 b8 non-final binary chunk
+-   * B b16 b8 final binary chunk
+-   * 
+- */ +- abstract public InputStream readInputStream() +- throws IOException; +- +- /** +- * Reads data to an output stream. +- * +- *
+-   * b b16 b8 non-final binary chunk
+-   * B b16 b8 final binary chunk
+-   * 
+- */ +- public boolean readToOutputStream(OutputStream os) +- throws IOException +- { +- InputStream is = readInputStream(); +- +- if (is == null) +- return false; +- +- if (_buffer == null) +- _buffer = new byte[256]; +- +- try { +- int len; +- +- while ((len = is.read(_buffer, 0, _buffer.length)) > 0) { +- os.write(_buffer, 0, len); +- } +- +- return true; +- } finally { +- is.close(); +- } +- } +- +- +- +- /** +- * Reads a byte array. +- * +- *
+-   * b b16 b8 non-final binary chunk
+-   * B b16 b8 final binary chunk
+-   * 
+- */ +- abstract public byte []readBytes() +- throws IOException; +- +- /** +- * Reads an arbitrary object from the input stream. +- * +- * @param expectedClass the expected class if the protocol doesn't supply it. +- */ +- abstract public Object readObject(Class expectedClass) +- throws IOException; +- +- /** +- * Reads an arbitrary object from the input stream. +- */ +- abstract public Object readObject() +- throws IOException; +- +- /** +- * Reads a remote object reference to the stream. The type is the +- * type of the remote interface. +- * +- *
+-   * 'r' 't' b16 b8 type url
+-   * 
+- */ +- abstract public Object readRemote() +- throws IOException; +- +- /** +- * Reads a reference +- * +- *
+-   * R b32 b24 b16 b8
+-   * 
+- */ +- abstract public Object readRef() +- throws IOException; +- +- /** +- * Adds an object reference. +- */ +- abstract public int addRef(Object obj) +- throws IOException; +- +- /** +- * Sets an object reference. +- */ +- abstract public void setRef(int i, Object obj) +- throws IOException; +- +- /** +- * Resets the references for streaming. +- */ +- public void resetReferences() +- { +- } +- +- /** +- * Reads the start of a list +- */ +- abstract public int readListStart() +- throws IOException; +- +- /** +- * Reads the length of a list. +- */ +- abstract public int readLength() +- throws IOException; +- +- /** +- * Reads the start of a map +- */ +- abstract public int readMapStart() +- throws IOException; +- +- /** +- * Reads an object type. +- */ +- abstract public String readType() +- throws IOException; +- +- /** +- * Returns true if the data has ended. +- */ +- abstract public boolean isEnd() +- throws IOException; +- +- /** +- * Read the end byte +- */ +- abstract public void readEnd() +- throws IOException; +- +- /** +- * Read the end byte +- */ +- abstract public void readMapEnd() +- throws IOException; +- +- /** +- * Read the end byte +- */ +- abstract public void readListEnd() +- throws IOException; +- +- public void close() +- throws IOException +- { +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.Reader; ++ ++/** ++ * Abstract base class for Hessian requests. Hessian users should only ++ * need to use the methods in this class. ++ * ++ *
++ * AbstractHessianInput in = ...; // get input
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++abstract public class AbstractHessianInput { ++ private HessianRemoteResolver resolver; ++ private byte []_buffer; ++ ++ /** ++ * Initialize the Hessian stream with the underlying input stream. ++ */ ++ public void init(InputStream is) ++ { ++ } ++ ++ /** ++ * Returns the call's method ++ */ ++ abstract public String getMethod(); ++ ++ /** ++ * Sets the resolver used to lookup remote objects. ++ */ ++ public void setRemoteResolver(HessianRemoteResolver resolver) ++ { ++ this.resolver = resolver; ++ } ++ ++ /** ++ * Sets the resolver used to lookup remote objects. ++ */ ++ public HessianRemoteResolver getRemoteResolver() ++ { ++ return resolver; ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory ser) ++ { ++ } ++ ++ /** ++ * Reads the call ++ * ++ *
++   * c major minor
++   * 
++ */ ++ abstract public int readCall() ++ throws IOException; ++ ++ /** ++ * For backward compatibility with HessianSkeleton ++ */ ++ public void skipOptionalCall() ++ throws IOException ++ { ++ } ++ ++ /** ++ * Reads a header, returning null if there are no headers. ++ * ++ *
++   * H b16 b8 value
++   * 
++ */ ++ abstract public String readHeader() ++ throws IOException; ++ ++ /** ++ * Starts reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * m b16 b8 method
++   * 
++ */ ++ abstract public String readMethod() ++ throws IOException; ++ ++ /** ++ * Reads the number of method arguments ++ * ++ * @return -1 for a variable length (hessian 1.0) ++ */ ++ public int readMethodArgLength() ++ throws IOException ++ { ++ return -1; ++ } ++ ++ /** ++ * Starts reading the call, including the headers. ++ * ++ *

The call expects the following protocol data ++ * ++ *

++   * c major minor
++   * m b16 b8 method
++   * 
++ */ ++ abstract public void startCall() ++ throws IOException; ++ ++ /** ++ * Completes reading the call ++ * ++ *

The call expects the following protocol data ++ * ++ *

++   * Z
++   * 
++ */ ++ abstract public void completeCall() ++ throws IOException; ++ ++ /** ++ * Reads a reply as an object. ++ * If the reply has a fault, throws the exception. ++ */ ++ abstract public Object readReply(Class expectedClass) ++ throws Throwable; ++ ++ /** ++ * Starts reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * r
++   * v
++   * 
++ */ ++ abstract public void startReply() ++ throws Throwable; ++ ++ /** ++ * Starts reading the body of the reply, i.e. after the 'r' has been ++ * parsed. ++ */ ++ public void startReplyBody() ++ throws Throwable ++ { ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ abstract public void completeReply() ++ throws IOException; ++ ++ /** ++ * Reads a boolean ++ * ++ *
++   * T
++   * F
++   * 
++ */ ++ abstract public boolean readBoolean() ++ throws IOException; ++ ++ /** ++ * Reads a null ++ * ++ *
++   * N
++   * 
++ */ ++ abstract public void readNull() ++ throws IOException; ++ ++ /** ++ * Reads an integer ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ */ ++ abstract public int readInt() ++ throws IOException; ++ ++ /** ++ * Reads a long ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ abstract public long readLong() ++ throws IOException; ++ ++ /** ++ * Reads a double. ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ abstract public double readDouble() ++ throws IOException; ++ ++ /** ++ * Reads a date. ++ * ++ *
++   * T b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ abstract public long readUTCDate() ++ throws IOException; ++ ++ /** ++ * Reads a string encoded in UTF-8 ++ * ++ *
++   * s b16 b8 non-final string chunk
++   * S b16 b8 final string chunk
++   * 
++ */ ++ abstract public String readString() ++ throws IOException; ++ ++ /** ++ * Reads an XML node encoded in UTF-8 ++ * ++ *
++   * x b16 b8 non-final xml chunk
++   * X b16 b8 final xml chunk
++   * 
++ */ ++ public org.w3c.dom.Node readNode() ++ throws IOException ++ { ++ throw new UnsupportedOperationException(getClass().getSimpleName()); ++ } ++ ++ /** ++ * Starts reading a string. All the characters must be read before ++ * calling the next method. The actual characters will be read with ++ * the reader's read() or read(char [], int, int). ++ * ++ *
++   * s b16 b8 non-final string chunk
++   * S b16 b8 final string chunk
++   * 
++ */ ++ abstract public Reader getReader() ++ throws IOException; ++ ++ /** ++ * Starts reading a byte array using an input stream. All the bytes ++ * must be read before calling the following method. ++ * ++ *
++   * b b16 b8 non-final binary chunk
++   * B b16 b8 final binary chunk
++   * 
++ */ ++ abstract public InputStream readInputStream() ++ throws IOException; ++ ++ /** ++ * Reads data to an output stream. ++ * ++ *
++   * b b16 b8 non-final binary chunk
++   * B b16 b8 final binary chunk
++   * 
++ */ ++ public boolean readToOutputStream(OutputStream os) ++ throws IOException ++ { ++ InputStream is = readInputStream(); ++ ++ if (is == null) ++ return false; ++ ++ if (_buffer == null) ++ _buffer = new byte[256]; ++ ++ try { ++ int len; ++ ++ while ((len = is.read(_buffer, 0, _buffer.length)) > 0) { ++ os.write(_buffer, 0, len); ++ } ++ ++ return true; ++ } finally { ++ is.close(); ++ } ++ } ++ ++ ++ ++ /** ++ * Reads a byte array. ++ * ++ *
++   * b b16 b8 non-final binary chunk
++   * B b16 b8 final binary chunk
++   * 
++ */ ++ abstract public byte []readBytes() ++ throws IOException; ++ ++ /** ++ * Reads an arbitrary object from the input stream. ++ * ++ * @param expectedClass the expected class if the protocol doesn't supply it. ++ */ ++ abstract public Object readObject(Class expectedClass) ++ throws IOException; ++ ++ /** ++ * Reads an arbitrary object from the input stream. ++ */ ++ abstract public Object readObject() ++ throws IOException; ++ ++ /** ++ * Reads a remote object reference to the stream. The type is the ++ * type of the remote interface. ++ * ++ *
++   * 'r' 't' b16 b8 type url
++   * 
++ */ ++ abstract public Object readRemote() ++ throws IOException; ++ ++ /** ++ * Reads a reference ++ * ++ *
++   * R b32 b24 b16 b8
++   * 
++ */ ++ abstract public Object readRef() ++ throws IOException; ++ ++ /** ++ * Adds an object reference. ++ */ ++ abstract public int addRef(Object obj) ++ throws IOException; ++ ++ /** ++ * Sets an object reference. ++ */ ++ abstract public void setRef(int i, Object obj) ++ throws IOException; ++ ++ /** ++ * Resets the references for streaming. ++ */ ++ public void resetReferences() ++ { ++ } ++ ++ /** ++ * Reads the start of a list ++ */ ++ abstract public int readListStart() ++ throws IOException; ++ ++ /** ++ * Reads the length of a list. ++ */ ++ abstract public int readLength() ++ throws IOException; ++ ++ /** ++ * Reads the start of a map ++ */ ++ abstract public int readMapStart() ++ throws IOException; ++ ++ /** ++ * Reads an object type. ++ */ ++ abstract public String readType() ++ throws IOException; ++ ++ /** ++ * Returns true if the data has ended. ++ */ ++ abstract public boolean isEnd() ++ throws IOException; ++ ++ /** ++ * Read the end byte ++ */ ++ abstract public void readEnd() ++ throws IOException; ++ ++ /** ++ * Read the end byte ++ */ ++ abstract public void readMapEnd() ++ throws IOException; ++ ++ /** ++ * Read the end byte ++ */ ++ abstract public void readListEnd() ++ throws IOException; ++ ++ public void close() ++ throws IOException ++ { ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianOutput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,592 +1,592 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +- +-/** +- * Abstract output stream for Hessian requests. +- * +- *
+- * OutputStream os = ...; // from http connection
+- * AbstractOutput out = new HessianSerializerOutput(os);
+- * String value;
+- *
+- * out.startCall("hello");  // start hello call
+- * out.writeString("arg1"); // write a string argument
+- * out.completeCall();      // complete the call
+- * 
+- */ +-abstract public class AbstractHessianOutput { +- // serializer factory +- private SerializerFactory _defaultSerializerFactory; +- +- // serializer factory +- protected SerializerFactory _serializerFactory; +- +- private byte []_byteBuffer; +- +- /** +- * Sets the serializer factory. +- */ +- public void setSerializerFactory(SerializerFactory factory) +- { +- _serializerFactory = factory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- public SerializerFactory getSerializerFactory() +- { +- // the default serializer factory cannot be modified by external +- // callers +- if (_serializerFactory == _defaultSerializerFactory) { +- _serializerFactory = new SerializerFactory(); +- } +- +- return _serializerFactory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- protected final SerializerFactory findSerializerFactory() +- { +- SerializerFactory factory = _serializerFactory; +- +- if (factory == null) { +- factory = SerializerFactory.createDefault(); +- _defaultSerializerFactory = factory; +- _serializerFactory = factory; +- } +- +- return factory; +- } +- +- /** +- * Initialize the output with a new underlying stream. +- */ +- public void init(OutputStream os) +- { +- } +- +- public boolean setUnshared(boolean isUnshared) +- { +- throw new UnsupportedOperationException(getClass().getSimpleName()); +- } +- +- /** +- * Writes a complete method call. +- */ +- public void call(String method, Object []args) +- throws IOException +- { +- int length = args != null ? args.length : 0; +- +- startCall(method, length); +- +- for (int i = 0; i < length; i++) +- writeObject(args[i]); +- +- completeCall(); +- } +- +- /** +- * Starts the method call: +- * +- *
+-   * C
+-   * 
+- * +- * @param method the method name to call. +- */ +- abstract public void startCall() +- throws IOException; +- +- /** +- * Starts the method call: +- * +- *
+-   * C string int
+-   * 
+- * +- * @param method the method name to call. +- */ +- abstract public void startCall(String method, int length) +- throws IOException; +- +- /** +- * For Hessian 2.0, use the Header envelope instead +- * +- * @deprecated +- */ +- public void writeHeader(String name) +- throws IOException +- { +- throw new UnsupportedOperationException(getClass().getSimpleName()); +- } +- +- /** +- * Writes the method tag. +- * +- *
+-   * string
+-   * 
+- * +- * @param method the method name to call. +- */ +- abstract public void writeMethod(String method) +- throws IOException; +- +- /** +- * Completes the method call: +- * +- *
+-   * 
+- */ +- abstract public void completeCall() +- throws IOException; +- +- /** +- * Writes a boolean value to the stream. The boolean will be written +- * with the following syntax: +- * +- *
+-   * T
+-   * F
+-   * 
+- * +- * @param value the boolean value to write. +- */ +- abstract public void writeBoolean(boolean value) +- throws IOException; +- +- /** +- * Writes an integer value to the stream. The integer will be written +- * with the following syntax: +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- * +- * @param value the integer value to write. +- */ +- abstract public void writeInt(int value) +- throws IOException; +- +- /** +- * Writes a long value to the stream. The long will be written +- * with the following syntax: +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param value the long value to write. +- */ +- abstract public void writeLong(long value) +- throws IOException; +- +- /** +- * Writes a double value to the stream. The double will be written +- * with the following syntax: +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param value the double value to write. +- */ +- abstract public void writeDouble(double value) +- throws IOException; +- +- /** +- * Writes a date to the stream. +- * +- *
+-   * T  b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param time the date in milliseconds from the epoch in UTC +- */ +- abstract public void writeUTCDate(long time) +- throws IOException; +- +- /** +- * Writes a null value to the stream. +- * The null will be written with the following syntax +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- abstract public void writeNull() +- throws IOException; +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- abstract public void writeString(String value) +- throws IOException; +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- abstract public void writeString(char []buffer, int offset, int length) +- throws IOException; +- +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- abstract public void writeBytes(byte []buffer) +- throws IOException; +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- abstract public void writeBytes(byte []buffer, int offset, int length) +- throws IOException; +- +- /** +- * Writes a byte buffer to the stream. +- */ +- abstract public void writeByteBufferStart() +- throws IOException; +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- * +- * @param value the string value to write. +- */ +- abstract public void writeByteBufferPart(byte []buffer, +- int offset, +- int length) +- throws IOException; +- +- /** +- * Writes the last chunk of a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- * +- * @param value the string value to write. +- */ +- abstract public void writeByteBufferEnd(byte []buffer, +- int offset, +- int length) +- throws IOException; +- +- /** +- * Writes a full output stream. +- */ +- public void writeByteStream(InputStream is) +- throws IOException +- { +- writeByteBufferStart(); +- +- if (_byteBuffer == null) +- _byteBuffer = new byte[1024]; +- +- byte []buffer = _byteBuffer; +- +- int len; +- while ((len = is.read(buffer, 0, buffer.length)) > 0) { +- if (len < buffer.length) { +- int len2 = is.read(buffer, len, buffer.length - len); +- +- if (len2 < 0) { +- writeByteBufferEnd(buffer, 0, len); +- return; +- } +- +- len += len2; +- } +- +- writeByteBufferPart(buffer, 0, len); +- } +- +- writeByteBufferEnd(buffer, 0, 0); +- } +- +- /** +- * Writes a reference. +- * +- *
+-   * Q int
+-   * 
+- * +- * @param value the integer value to write. +- */ +- abstract protected void writeRef(int value) +- throws IOException; +- +- /** +- * Removes a reference. +- */ +- public boolean removeRef(Object obj) +- throws IOException +- { +- return false; +- } +- +- /** +- * Replaces a reference from one object to another. +- */ +- abstract public boolean replaceRef(Object oldRef, Object newRef) +- throws IOException; +- +- /** +- * Adds an object to the reference list. If the object already exists, +- * writes the reference, otherwise, the caller is responsible for +- * the serialization. +- * +- *
+-   * R b32 b24 b16 b8
+-   * 
+- * +- * @param object the object to add as a reference. +- * +- * @return true if the object has already been written. +- */ +- abstract public boolean addRef(Object object) +- throws IOException; +- +- /** +- * @param obj +- * @return +- */ +- abstract public int getRef(Object obj); +- +- /** +- * Resets the references for streaming. +- */ +- public void resetReferences() +- { +- } +- +- /** +- * Writes a generic object to the output stream. +- */ +- abstract public void writeObject(Object object) +- throws IOException; +- +- /** +- * Writes the list header to the stream. List writers will call +- * writeListBegin followed by the list contents and then +- * call writeListEnd. +- * +- *
+-   * V
+-   *   x13 java.util.ArrayList   # type
+-   *   x93                       # length=3
+-   *   x91                       # 1
+-   *   x92                       # 2
+-   *   x93                       # 3
+-   * </list>
+-   * 
+- */ +- abstract public boolean writeListBegin(int length, String type) +- throws IOException; +- +- /** +- * Writes the tail of the list to the stream. +- */ +- abstract public void writeListEnd() +- throws IOException; +- +- /** +- * Writes the map header to the stream. Map writers will call +- * writeMapBegin followed by the map contents and then +- * call writeMapEnd. +- * +- *
+-   * M type ( )* Z
+-   * 
+- */ +- abstract public void writeMapBegin(String type) +- throws IOException; +- +- /** +- * Writes the tail of the map to the stream. +- */ +- abstract public void writeMapEnd() +- throws IOException; +- +- /** +- * Writes the object header to the stream (for Hessian 2.0), or a +- * Map for Hessian 1.0. Object writers will call +- * writeObjectBegin followed by the map contents and then +- * call writeObjectEnd. +- * +- *
+-   * C type int *
+-   * C int *
+-   * 
+- * +- * @return true if the object has already been defined. +- */ +- public int writeObjectBegin(String type) +- throws IOException +- { +- writeMapBegin(type); +- +- return -2; +- } +- +- /** +- * Writes the end of the class. +- */ +- public void writeClassFieldLength(int len) +- throws IOException +- { +- } +- +- /** +- * Writes the tail of the object to the stream. +- */ +- public void writeObjectEnd() +- throws IOException +- { +- } +- +- public void writeReply(Object o) +- throws IOException +- { +- startReply(); +- writeObject(o); +- completeReply(); +- } +- +- +- public void startReply() +- throws IOException +- { +- } +- +- public void completeReply() +- throws IOException +- { +- } +- +- public void writeFault(String code, String message, Object detail) +- throws IOException +- { +- } +- +- public void flush() +- throws IOException +- { +- } +- +- public void close() +- throws IOException +- { +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++ ++/** ++ * Abstract output stream for Hessian requests. ++ * ++ *
++ * OutputStream os = ...; // from http connection
++ * AbstractOutput out = new HessianSerializerOutput(os);
++ * String value;
++ *
++ * out.startCall("hello");  // start hello call
++ * out.writeString("arg1"); // write a string argument
++ * out.completeCall();      // complete the call
++ * 
++ */ ++abstract public class AbstractHessianOutput { ++ // serializer factory ++ private SerializerFactory _defaultSerializerFactory; ++ ++ // serializer factory ++ protected SerializerFactory _serializerFactory; ++ ++ private byte []_byteBuffer; ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ // the default serializer factory cannot be modified by external ++ // callers ++ if (_serializerFactory == _defaultSerializerFactory) { ++ _serializerFactory = new SerializerFactory(); ++ } ++ ++ return _serializerFactory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ protected final SerializerFactory findSerializerFactory() ++ { ++ SerializerFactory factory = _serializerFactory; ++ ++ if (factory == null) { ++ factory = SerializerFactory.createDefault(); ++ _defaultSerializerFactory = factory; ++ _serializerFactory = factory; ++ } ++ ++ return factory; ++ } ++ ++ /** ++ * Initialize the output with a new underlying stream. ++ */ ++ public void init(OutputStream os) ++ { ++ } ++ ++ public boolean setUnshared(boolean isUnshared) ++ { ++ throw new UnsupportedOperationException(getClass().getSimpleName()); ++ } ++ ++ /** ++ * Writes a complete method call. ++ */ ++ public void call(String method, Object []args) ++ throws IOException ++ { ++ int length = args != null ? args.length : 0; ++ ++ startCall(method, length); ++ ++ for (int i = 0; i < length; i++) ++ writeObject(args[i]); ++ ++ completeCall(); ++ } ++ ++ /** ++ * Starts the method call: ++ * ++ *
++   * C
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ abstract public void startCall() ++ throws IOException; ++ ++ /** ++ * Starts the method call: ++ * ++ *
++   * C string int
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ abstract public void startCall(String method, int length) ++ throws IOException; ++ ++ /** ++ * For Hessian 2.0, use the Header envelope instead ++ * ++ * @deprecated ++ */ ++ public void writeHeader(String name) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(getClass().getSimpleName()); ++ } ++ ++ /** ++ * Writes the method tag. ++ * ++ *
++   * string
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ abstract public void writeMethod(String method) ++ throws IOException; ++ ++ /** ++ * Completes the method call: ++ * ++ *
++   * 
++ */ ++ abstract public void completeCall() ++ throws IOException; ++ ++ /** ++ * Writes a boolean value to the stream. The boolean will be written ++ * with the following syntax: ++ * ++ *
++   * T
++   * F
++   * 
++ * ++ * @param value the boolean value to write. ++ */ ++ abstract public void writeBoolean(boolean value) ++ throws IOException; ++ ++ /** ++ * Writes an integer value to the stream. The integer will be written ++ * with the following syntax: ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ abstract public void writeInt(int value) ++ throws IOException; ++ ++ /** ++ * Writes a long value to the stream. The long will be written ++ * with the following syntax: ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param value the long value to write. ++ */ ++ abstract public void writeLong(long value) ++ throws IOException; ++ ++ /** ++ * Writes a double value to the stream. The double will be written ++ * with the following syntax: ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param value the double value to write. ++ */ ++ abstract public void writeDouble(double value) ++ throws IOException; ++ ++ /** ++ * Writes a date to the stream. ++ * ++ *
++   * T  b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param time the date in milliseconds from the epoch in UTC ++ */ ++ abstract public void writeUTCDate(long time) ++ throws IOException; ++ ++ /** ++ * Writes a null value to the stream. ++ * The null will be written with the following syntax ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ abstract public void writeNull() ++ throws IOException; ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ abstract public void writeString(String value) ++ throws IOException; ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ abstract public void writeString(char []buffer, int offset, int length) ++ throws IOException; ++ ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ abstract public void writeBytes(byte []buffer) ++ throws IOException; ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ abstract public void writeBytes(byte []buffer, int offset, int length) ++ throws IOException; ++ ++ /** ++ * Writes a byte buffer to the stream. ++ */ ++ abstract public void writeByteBufferStart() ++ throws IOException; ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ abstract public void writeByteBufferPart(byte []buffer, ++ int offset, ++ int length) ++ throws IOException; ++ ++ /** ++ * Writes the last chunk of a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ abstract public void writeByteBufferEnd(byte []buffer, ++ int offset, ++ int length) ++ throws IOException; ++ ++ /** ++ * Writes a full output stream. ++ */ ++ public void writeByteStream(InputStream is) ++ throws IOException ++ { ++ writeByteBufferStart(); ++ ++ if (_byteBuffer == null) ++ _byteBuffer = new byte[1024]; ++ ++ byte []buffer = _byteBuffer; ++ ++ int len; ++ while ((len = is.read(buffer, 0, buffer.length)) > 0) { ++ if (len < buffer.length) { ++ int len2 = is.read(buffer, len, buffer.length - len); ++ ++ if (len2 < 0) { ++ writeByteBufferEnd(buffer, 0, len); ++ return; ++ } ++ ++ len += len2; ++ } ++ ++ writeByteBufferPart(buffer, 0, len); ++ } ++ ++ writeByteBufferEnd(buffer, 0, 0); ++ } ++ ++ /** ++ * Writes a reference. ++ * ++ *
++   * Q int
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ abstract protected void writeRef(int value) ++ throws IOException; ++ ++ /** ++ * Removes a reference. ++ */ ++ public boolean removeRef(Object obj) ++ throws IOException ++ { ++ return false; ++ } ++ ++ /** ++ * Replaces a reference from one object to another. ++ */ ++ abstract public boolean replaceRef(Object oldRef, Object newRef) ++ throws IOException; ++ ++ /** ++ * Adds an object to the reference list. If the object already exists, ++ * writes the reference, otherwise, the caller is responsible for ++ * the serialization. ++ * ++ *
++   * R b32 b24 b16 b8
++   * 
++ * ++ * @param object the object to add as a reference. ++ * ++ * @return true if the object has already been written. ++ */ ++ abstract public boolean addRef(Object object) ++ throws IOException; ++ ++ /** ++ * @param obj ++ * @return ++ */ ++ abstract public int getRef(Object obj); ++ ++ /** ++ * Resets the references for streaming. ++ */ ++ public void resetReferences() ++ { ++ } ++ ++ /** ++ * Writes a generic object to the output stream. ++ */ ++ abstract public void writeObject(Object object) ++ throws IOException; ++ ++ /** ++ * Writes the list header to the stream. List writers will call ++ * writeListBegin followed by the list contents and then ++ * call writeListEnd. ++ * ++ *
++   * V
++   *   x13 java.util.ArrayList   # type
++   *   x93                       # length=3
++   *   x91                       # 1
++   *   x92                       # 2
++   *   x93                       # 3
++   * </list>
++   * 
++ */ ++ abstract public boolean writeListBegin(int length, String type) ++ throws IOException; ++ ++ /** ++ * Writes the tail of the list to the stream. ++ */ ++ abstract public void writeListEnd() ++ throws IOException; ++ ++ /** ++ * Writes the map header to the stream. Map writers will call ++ * writeMapBegin followed by the map contents and then ++ * call writeMapEnd. ++ * ++ *
++   * M type ( )* Z
++   * 
++ */ ++ abstract public void writeMapBegin(String type) ++ throws IOException; ++ ++ /** ++ * Writes the tail of the map to the stream. ++ */ ++ abstract public void writeMapEnd() ++ throws IOException; ++ ++ /** ++ * Writes the object header to the stream (for Hessian 2.0), or a ++ * Map for Hessian 1.0. Object writers will call ++ * writeObjectBegin followed by the map contents and then ++ * call writeObjectEnd. ++ * ++ *
++   * C type int *
++   * C int *
++   * 
++ * ++ * @return true if the object has already been defined. ++ */ ++ public int writeObjectBegin(String type) ++ throws IOException ++ { ++ writeMapBegin(type); ++ ++ return -2; ++ } ++ ++ /** ++ * Writes the end of the class. ++ */ ++ public void writeClassFieldLength(int len) ++ throws IOException ++ { ++ } ++ ++ /** ++ * Writes the tail of the object to the stream. ++ */ ++ public void writeObjectEnd() ++ throws IOException ++ { ++ } ++ ++ public void writeReply(Object o) ++ throws IOException ++ { ++ startReply(); ++ writeObject(o); ++ completeReply(); ++ } ++ ++ ++ public void startReply() ++ throws IOException ++ { ++ } ++ ++ public void completeReply() ++ throws IOException ++ { ++ } ++ ++ public void writeFault(String code, String message, Object detail) ++ throws IOException ++ { ++ } ++ ++ public void flush() ++ throws IOException ++ { ++ } ++ ++ public void close() ++ throws IOException ++ { ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianResolver.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianResolver.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianResolver.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianResolver.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,65 +1,65 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Looks up remote objects. The default just returns a HessianRemote object. +- */ +-public class AbstractHessianResolver implements HessianRemoteResolver { +- /** +- * Looks up a proxy object. +- */ +- public Object lookup(String type, String url) +- throws IOException +- { +- return new HessianRemote(type, url); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Looks up remote objects. The default just returns a HessianRemote object. ++ */ ++public class AbstractHessianResolver implements HessianRemoteResolver { ++ /** ++ * Looks up a proxy object. ++ */ ++ public Object lookup(String type, String url) ++ throws IOException ++ { ++ return new HessianRemote(type, url); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractListDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractListDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractListDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractListDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,67 +1,67 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Deserializing a JDK 1.2 Collection. +- */ +-public class AbstractListDeserializer extends AbstractDeserializer { +- public Object readObject(AbstractHessianInput in) +- throws IOException +- { +- Object obj = in.readObject(); +- +- if (obj != null) +- throw error("expected list at " + obj.getClass().getName() + " (" + obj + ")"); +- else +- throw error("expected list at null"); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Deserializing a JDK 1.2 Collection. ++ */ ++public class AbstractListDeserializer extends AbstractDeserializer { ++ public Object readObject(AbstractHessianInput in) ++ throws IOException ++ { ++ Object obj = in.readObject(); ++ ++ if (obj != null) ++ throw error("expected list at " + obj.getClass().getName() + " (" + obj + ")"); ++ else ++ throw error("expected list at null"); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractMapDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractMapDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractMapDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractMapDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,74 +1,74 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.HashMap; +- +-/** +- * Serializing an object for known object types. +- */ +-public class AbstractMapDeserializer extends AbstractDeserializer { +- +- public Class getType() +- { +- return HashMap.class; +- } +- +- public Object readObject(AbstractHessianInput in) +- throws IOException +- { +- Object obj = in.readObject(); +- +- if (obj != null) +- throw error("expected map/object at " + obj.getClass().getName() + " (" + obj + ")"); +- else +- throw error("expected map/object at null"); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.HashMap; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class AbstractMapDeserializer extends AbstractDeserializer { ++ ++ public Class getType() ++ { ++ return HashMap.class; ++ } ++ ++ public Object readObject(AbstractHessianInput in) ++ throws IOException ++ { ++ Object obj = in.readObject(); ++ ++ if (obj != null) ++ throw error("expected map/object at " + obj.getClass().getName() + " (" + obj + ")"); ++ else ++ throw error("expected map/object at null"); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,152 +1,152 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.logging.*; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Serializing an object. +- */ +-abstract public class AbstractSerializer implements Serializer { +- public static final NullSerializer NULL = new NullSerializer(); +- +- protected static final Logger log +- = Logger.getLogger(AbstractSerializer.class.getName()); +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) { +- return; +- } +- +- try { +- Object replace = writeReplace(obj); +- +- if (replace != null) { +- // out.removeRef(obj); +- +- out.writeObject(replace); +- +- out.replaceRef(replace, obj); +- +- return; +- } +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- // log.log(Level.FINE, e.toString(), e); +- throw new HessianException(e); +- } +- +- Class cl = getClass(obj); +- +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref < -1) { +- writeObject10(obj, out); +- } +- else { +- if (ref == -1) { +- writeDefinition20(cl, out); +- +- out.writeObjectBegin(cl.getName()); +- } +- +- writeInstance(obj, out); +- } +- } +- +- protected Object writeReplace(Object obj) +- { +- return null; +- } +- +- protected Class getClass(Object obj) +- { +- return obj.getClass(); +- } +- +- protected void writeObject10(Object obj, +- AbstractHessianOutput out) +- throws IOException +- { +- throw new UnsupportedOperationException(getClass().getName()); +- } +- +- protected void writeDefinition20(Class cl, +- AbstractHessianOutput out) +- throws IOException +- { +- throw new UnsupportedOperationException(getClass().getName()); +- } +- +- protected void writeInstance(Object obj, +- AbstractHessianOutput out) +- throws IOException +- { +- throw new UnsupportedOperationException(getClass().getName()); +- } +- +- /** +- * The NullSerializer exists as a marker for the factory classes so +- * they save a null result. +- */ +- static final class NullSerializer extends AbstractSerializer { +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- throw new IllegalStateException(getClass().getName()); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.logging.*; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Serializing an object. ++ */ ++abstract public class AbstractSerializer implements Serializer { ++ public static final NullSerializer NULL = new NullSerializer(); ++ ++ protected static final Logger log ++ = Logger.getLogger(AbstractSerializer.class.getName()); ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) { ++ return; ++ } ++ ++ try { ++ Object replace = writeReplace(obj); ++ ++ if (replace != null) { ++ // out.removeRef(obj); ++ ++ out.writeObject(replace); ++ ++ out.replaceRef(replace, obj); ++ ++ return; ++ } ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ // log.log(Level.FINE, e.toString(), e); ++ throw new HessianException(e); ++ } ++ ++ Class cl = getClass(obj); ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref < -1) { ++ writeObject10(obj, out); ++ } ++ else { ++ if (ref == -1) { ++ writeDefinition20(cl, out); ++ ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ writeInstance(obj, out); ++ } ++ } ++ ++ protected Object writeReplace(Object obj) ++ { ++ return null; ++ } ++ ++ protected Class getClass(Object obj) ++ { ++ return obj.getClass(); ++ } ++ ++ protected void writeObject10(Object obj, ++ AbstractHessianOutput out) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(getClass().getName()); ++ } ++ ++ protected void writeDefinition20(Class cl, ++ AbstractHessianOutput out) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(getClass().getName()); ++ } ++ ++ protected void writeInstance(Object obj, ++ AbstractHessianOutput out) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(getClass().getName()); ++ } ++ ++ /** ++ * The NullSerializer exists as a marker for the factory classes so ++ * they save a null result. ++ */ ++ static final class NullSerializer extends AbstractSerializer { ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ throw new IllegalStateException(getClass().getName()); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,74 +1,74 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-/** +- * Factory for returning serialization methods. +- */ +-abstract public class AbstractSerializerFactory { +- /** +- * Returns the serializer for a class. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- abstract public Serializer getSerializer(Class cl) +- throws HessianProtocolException; +- +- /** +- * Returns the deserializer for a class. +- * +- * @param cl the class of the object that needs to be deserialized. +- * +- * @return a deserializer object for the serialization. +- */ +- abstract public Deserializer getDeserializer(Class cl) +- throws HessianProtocolException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++/** ++ * Factory for returning serialization methods. ++ */ ++abstract public class AbstractSerializerFactory { ++ /** ++ * Returns the serializer for a class. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ abstract public Serializer getSerializer(Class cl) ++ throws HessianProtocolException; ++ ++ /** ++ * Returns the deserializer for a class. ++ * ++ * @param cl the class of the object that needs to be deserialized. ++ * ++ * @return a deserializer object for the serialization. ++ */ ++ abstract public Deserializer getDeserializer(Class cl) ++ throws HessianProtocolException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerWrapper.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerWrapper.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerWrapper.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerWrapper.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,69 +1,69 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.logging.Logger; +- +-/** +- * Serializing an object. +- */ +-abstract public class AbstractSerializerWrapper implements Serializer { +- protected static final Logger log +- = Logger.getLogger(AbstractSerializerWrapper.class.getName()); +- +- abstract protected Serializer getDelegate(); +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- getDelegate().writeObject(obj, out); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.logging.Logger; ++ ++/** ++ * Serializing an object. ++ */ ++abstract public class AbstractSerializerWrapper implements Serializer { ++ protected static final Logger log ++ = Logger.getLogger(AbstractSerializerWrapper.class.getName()); ++ ++ abstract protected Serializer getDelegate(); ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ getDelegate().writeObject(obj, out); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,105 +1,105 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Deserializing a byte stream +- */ +-abstract public class AbstractStreamDeserializer extends AbstractDeserializer { +- abstract public Class getType(); +- +- /** +- * Reads the Hessian 1.0 style map. +- */ +- @Override +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- Object value = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if (key.equals("value")) +- value = readStreamValue(in); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- return value; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, Object []fields) +- throws IOException +- { +- String []fieldNames = (String []) fields; +- +- Object value = null; +- +- for (int i = 0; i < fieldNames.length; i++) { +- if ("value".equals(fieldNames[i])) { +- value = readStreamValue(in); +- in.addRef(value); +- } +- else { +- in.readObject(); +- } +- } +- +- return value; +- } +- +- abstract protected Object readStreamValue(AbstractHessianInput in) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Deserializing a byte stream ++ */ ++abstract public class AbstractStreamDeserializer extends AbstractDeserializer { ++ abstract public Class getType(); ++ ++ /** ++ * Reads the Hessian 1.0 style map. ++ */ ++ @Override ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ Object value = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("value")) ++ value = readStreamValue(in); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ return value; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, Object []fields) ++ throws IOException ++ { ++ String []fieldNames = (String []) fields; ++ ++ Object value = null; ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ if ("value".equals(fieldNames[i])) { ++ value = readStreamValue(in); ++ in.addRef(value); ++ } ++ else { ++ in.readObject(); ++ } ++ } ++ ++ return value; ++ } ++ ++ abstract protected Object readStreamValue(AbstractHessianInput in) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,131 +1,131 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.util.logging.Level; +- +-/** +- * Serializing an object containing a byte stream. +- */ +-abstract public class AbstractStreamSerializer extends AbstractSerializer +-{ +- /** +- * Writes the object to the output stream. +- */ +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) { +- return; +- } +- +- int ref = out.writeObjectBegin(getClassName(obj)); +- +- if (ref < -1) { +- out.writeString("value"); +- +- InputStream is = null; +- +- try { +- is = getInputStream(obj); +- } catch (Exception e) { +- log.log(Level.WARNING, e.toString(), e); +- } +- +- if (is != null) { +- try { +- out.writeByteStream(is); +- } finally { +- is.close(); +- } +- } else { +- out.writeNull(); +- } +- +- out.writeMapEnd(); +- } +- else { +- if (ref == -1) { +- out.writeClassFieldLength(1); +- out.writeString("value"); +- +- out.writeObjectBegin(getClassName(obj)); +- } +- +- InputStream is = null; +- +- try { +- is = getInputStream(obj); +- } catch (Exception e) { +- log.log(Level.WARNING, e.toString(), e); +- } +- +- try { +- if (is != null) +- out.writeByteStream(is); +- else +- out.writeNull(); +- } finally { +- if (is != null) +- is.close(); +- } +- } +- } +- +- protected String getClassName(Object obj) +- { +- return obj.getClass().getName(); +- } +- +- abstract protected InputStream getInputStream(Object obj) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.util.logging.Level; ++ ++/** ++ * Serializing an object containing a byte stream. ++ */ ++abstract public class AbstractStreamSerializer extends AbstractSerializer ++{ ++ /** ++ * Writes the object to the output stream. ++ */ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) { ++ return; ++ } ++ ++ int ref = out.writeObjectBegin(getClassName(obj)); ++ ++ if (ref < -1) { ++ out.writeString("value"); ++ ++ InputStream is = null; ++ ++ try { ++ is = getInputStream(obj); ++ } catch (Exception e) { ++ log.log(Level.WARNING, e.toString(), e); ++ } ++ ++ if (is != null) { ++ try { ++ out.writeByteStream(is); ++ } finally { ++ is.close(); ++ } ++ } else { ++ out.writeNull(); ++ } ++ ++ out.writeMapEnd(); ++ } ++ else { ++ if (ref == -1) { ++ out.writeClassFieldLength(1); ++ out.writeString("value"); ++ ++ out.writeObjectBegin(getClassName(obj)); ++ } ++ ++ InputStream is = null; ++ ++ try { ++ is = getInputStream(obj); ++ } catch (Exception e) { ++ log.log(Level.WARNING, e.toString(), e); ++ } ++ ++ try { ++ if (is != null) ++ out.writeByteStream(is); ++ else ++ out.writeNull(); ++ } finally { ++ if (is != null) ++ is.close(); ++ } ++ } ++ } ++ ++ protected String getClassName(Object obj) ++ { ++ return obj.getClass().getName(); ++ } ++ ++ abstract protected InputStream getInputStream(Object obj) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractStringValueDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStringValueDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AbstractStringValueDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStringValueDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,108 +1,108 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Constructor; +- +-/** +- * Deserializes a string-valued object like BigDecimal. +- */ +-abstract public class AbstractStringValueDeserializer +- extends AbstractDeserializer +-{ +- abstract protected Object create(String value) +- throws IOException; +- +- @Override +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String value = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if (key.equals("value")) +- value = in.readString(); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- Object object = create(value); +- +- in.addRef(object); +- +- return object; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, Object []fields) +- throws IOException +- { +- String []fieldNames = (String []) fields; +- +- String value = null; +- +- for (int i = 0; i < fieldNames.length; i++) { +- if ("value".equals(fieldNames[i])) +- value = in.readString(); +- else +- in.readObject(); +- } +- +- Object object = create(value); +- +- in.addRef(object); +- +- return object; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Constructor; ++ ++/** ++ * Deserializes a string-valued object like BigDecimal. ++ */ ++abstract public class AbstractStringValueDeserializer ++ extends AbstractDeserializer ++{ ++ abstract protected Object create(String value) ++ throws IOException; ++ ++ @Override ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String value = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("value")) ++ value = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object object = create(value); ++ ++ in.addRef(object); ++ ++ return object; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, Object []fields) ++ throws IOException ++ { ++ String []fieldNames = (String []) fields; ++ ++ String value = null; ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ if ("value".equals(fieldNames[i])) ++ value = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ Object object = create(value); ++ ++ in.addRef(object); ++ ++ return object; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AnnotationDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AnnotationDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,138 +1,138 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Constructor; +-import java.lang.reflect.Field; +-import java.lang.reflect.InvocationTargetException; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.lang.reflect.Proxy; +-import java.util.HashMap; +- +-import java.util.logging.*; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Deserializing a java annotation for known object types. +- */ +-public class AnnotationDeserializer extends AbstractMapDeserializer { +- private static final Logger log +- = Logger.getLogger(AnnotationDeserializer.class.getName()); +- +- private Class _annType; +- +- public AnnotationDeserializer(Class annType) +- { +- _annType = annType; +- } +- +- public Class getType() +- { +- return _annType; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- try { +- int ref = in.addRef(null); +- +- HashMap valueMap = new HashMap(8); +- +- while (! in.isEnd()) { +- String key = in.readString(); +- Object value = in.readObject(); +- +- valueMap.put(key, value); +- } +- +- in.readMapEnd(); +- +- return Proxy.newProxyInstance(_annType.getClassLoader(), +- new Class[] { _annType }, +- new AnnotationInvocationHandler(_annType, valueMap)); +- +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException +- { +- String []fieldNames = (String []) fields; +- +- try { +- in.addRef(null); +- +- HashMap valueMap = new HashMap(8); +- +- for (int i = 0; i < fieldNames.length; i++) { +- String name = fieldNames[i]; +- +- valueMap.put(name, in.readObject()); +- } +- +- return Proxy.newProxyInstance(_annType.getClassLoader(), +- new Class[] { _annType }, +- new AnnotationInvocationHandler(_annType, valueMap)); +- +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new HessianException(_annType.getName() + ":" + e, e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Constructor; ++import java.lang.reflect.Field; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.lang.reflect.Proxy; ++import java.util.HashMap; ++ ++import java.util.logging.*; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Deserializing a java annotation for known object types. ++ */ ++public class AnnotationDeserializer extends AbstractMapDeserializer { ++ private static final Logger log ++ = Logger.getLogger(AnnotationDeserializer.class.getName()); ++ ++ private Class _annType; ++ ++ public AnnotationDeserializer(Class annType) ++ { ++ _annType = annType; ++ } ++ ++ public Class getType() ++ { ++ return _annType; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(null); ++ ++ HashMap valueMap = new HashMap(8); ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ Object value = in.readObject(); ++ ++ valueMap.put(key, value); ++ } ++ ++ in.readMapEnd(); ++ ++ return Proxy.newProxyInstance(_annType.getClassLoader(), ++ new Class[] { _annType }, ++ new AnnotationInvocationHandler(_annType, valueMap)); ++ ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ String []fieldNames = (String []) fields; ++ ++ try { ++ in.addRef(null); ++ ++ HashMap valueMap = new HashMap(8); ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ String name = fieldNames[i]; ++ ++ valueMap.put(name, in.readObject()); ++ } ++ ++ return Proxy.newProxyInstance(_annType.getClassLoader(), ++ new Class[] { _annType }, ++ new AnnotationInvocationHandler(_annType, valueMap)); ++ ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new HessianException(_annType.getName() + ":" + e, e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AnnotationInvocationHandler.java hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationInvocationHandler.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AnnotationInvocationHandler.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationInvocationHandler.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,143 +1,143 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.annotation.Annotation; +-import java.lang.reflect.InvocationHandler; +-import java.lang.reflect.Method; +-import java.util.HashMap; +-import java.util.Map; +- +-import java.util.logging.*; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Proxy for a java annotation for known object types. +- */ +-public class AnnotationInvocationHandler implements InvocationHandler { +- private Class _annType; +- private HashMap _valueMap; +- +- public AnnotationInvocationHandler(Class annType, +- HashMap valueMap) +- { +- _annType = annType; +- _valueMap = valueMap; +- } +- +- @Override +- public Object invoke(Object proxy, Method method, Object []args) +- throws Throwable +- { +- String name = method.getName(); +- +- boolean zeroArgs = args == null || args.length == 0; +- +- if (name.equals("annotationType") && zeroArgs) +- return _annType; +- else if (name.equals("toString") && zeroArgs) +- return toString(); +- else if (name.equals("hashCode") && zeroArgs) +- return doHashCode(); +- else if (name.equals("equals") && ! zeroArgs && args.length == 1) +- return doEquals(args[0]); +- else if (! zeroArgs) +- return null; +- +- +- return _valueMap.get(method.getName()); +- } +- +- public int doHashCode() +- { +- return 13; +- } +- +- public boolean doEquals(Object value) +- { +- if (! (value instanceof Annotation)) +- return false; +- +- Annotation ann = (Annotation) value; +- +- if (! _annType.equals(ann.annotationType())) +- return false; +- +- return true; +- } +- +- public String toString() +- { +- StringBuilder sb = new StringBuilder(); +- +- sb.append("@"); +- sb.append(_annType.getName()); +- sb.append("["); +- +- boolean isFirst = true; +- for (Map.Entry entry : _valueMap.entrySet()) { +- if (! isFirst) +- sb.append(", "); +- isFirst = false; +- +- sb.append(entry.getKey()); +- sb.append("="); +- +- if (entry.getValue() instanceof String) +- sb.append('"').append(entry.getValue()).append('"'); +- else +- sb.append(entry.getValue()); +- } +- sb.append("]"); +- +- return sb.toString(); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.annotation.Annotation; ++import java.lang.reflect.InvocationHandler; ++import java.lang.reflect.Method; ++import java.util.HashMap; ++import java.util.Map; ++ ++import java.util.logging.*; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Proxy for a java annotation for known object types. ++ */ ++public class AnnotationInvocationHandler implements InvocationHandler { ++ private Class _annType; ++ private HashMap _valueMap; ++ ++ public AnnotationInvocationHandler(Class annType, ++ HashMap valueMap) ++ { ++ _annType = annType; ++ _valueMap = valueMap; ++ } ++ ++ @Override ++ public Object invoke(Object proxy, Method method, Object []args) ++ throws Throwable ++ { ++ String name = method.getName(); ++ ++ boolean zeroArgs = args == null || args.length == 0; ++ ++ if (name.equals("annotationType") && zeroArgs) ++ return _annType; ++ else if (name.equals("toString") && zeroArgs) ++ return toString(); ++ else if (name.equals("hashCode") && zeroArgs) ++ return doHashCode(); ++ else if (name.equals("equals") && ! zeroArgs && args.length == 1) ++ return doEquals(args[0]); ++ else if (! zeroArgs) ++ return null; ++ ++ ++ return _valueMap.get(method.getName()); ++ } ++ ++ public int doHashCode() ++ { ++ return 13; ++ } ++ ++ public boolean doEquals(Object value) ++ { ++ if (! (value instanceof Annotation)) ++ return false; ++ ++ Annotation ann = (Annotation) value; ++ ++ if (! _annType.equals(ann.annotationType())) ++ return false; ++ ++ return true; ++ } ++ ++ public String toString() ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ sb.append("@"); ++ sb.append(_annType.getName()); ++ sb.append("["); ++ ++ boolean isFirst = true; ++ for (Map.Entry entry : _valueMap.entrySet()) { ++ if (! isFirst) ++ sb.append(", "); ++ isFirst = false; ++ ++ sb.append(entry.getKey()); ++ sb.append("="); ++ ++ if (entry.getValue() instanceof String) ++ sb.append('"').append(entry.getValue()).append('"'); ++ else ++ sb.append(entry.getValue()); ++ } ++ sb.append("]"); ++ ++ return sb.toString(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AnnotationSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/AnnotationSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,395 +1,395 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.Serializable; +-import java.lang.annotation.Annotation; +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.lang.reflect.InvocationTargetException; +-import java.util.ArrayList; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Serializing a Java annotation +- */ +-public class AnnotationSerializer extends AbstractSerializer +-{ +- private static final Logger log +- = Logger.getLogger(AnnotationSerializer.class.getName()); +- +- private static Object []NULL_ARGS = new Object[0]; +- +- private Class _annType; +- private Method []_methods; +- private MethodSerializer []_methodSerializers; +- +- public AnnotationSerializer(Class annType) +- { +- if (! Annotation.class.isAssignableFrom(annType)) { +- throw new IllegalStateException(annType.getName() + " is invalid because it is not a java.lang.annotation.Annotation"); +- } +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) { +- return; +- } +- +- init(((Annotation) obj).annotationType()); +- +- int ref = out.writeObjectBegin(_annType.getName()); +- +- if (ref < -1) { +- writeObject10(obj, out); +- } +- else { +- if (ref == -1) { +- writeDefinition20(out); +- out.writeObjectBegin(_annType.getName()); +- } +- +- writeInstance(obj, out); +- } +- } +- +- protected void writeObject10(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- for (int i = 0; i < _methods.length; i++) { +- Method method = _methods[i]; +- +- out.writeString(method.getName()); +- +- _methodSerializers[i].serialize(out, obj, method); +- } +- +- out.writeMapEnd(); +- } +- +- private void writeDefinition20(AbstractHessianOutput out) +- throws IOException +- { +- out.writeClassFieldLength(_methods.length); +- +- for (int i = 0; i < _methods.length; i++) { +- Method method = _methods[i]; +- +- out.writeString(method.getName()); +- } +- } +- +- public void writeInstance(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- for (int i = 0; i < _methods.length; i++) { +- Method method = _methods[i]; +- +- _methodSerializers[i].serialize(out, obj, method); +- } +- } +- +- +- private void init(Class cl) +- { +- synchronized (this) { +- if (_annType != null) +- return; +- +- _annType = cl; +- +- ArrayList methods = new ArrayList(); +- +- for (Method method : _annType.getDeclaredMethods()) { +- if (method.getName().equals("hashCode") +- || method.getName().equals("toString") +- || method.getName().equals("annotationType")) { +- continue; +- } +- +- if (method.getParameterTypes().length != 0) +- continue; +- +- methods.add(method); +- +- method.setAccessible(true); +- } +- +- if (_annType == null) +- throw new IllegalStateException(cl.getName() + " is invalid because it does not have a valid annotationType()"); +- +- _methods = new Method[methods.size()]; +- methods.toArray(_methods); +- +- _methodSerializers = new MethodSerializer[_methods.length]; +- +- for (int i = 0; i < _methods.length; i++) { +- _methodSerializers[i] = getMethodSerializer(_methods[i].getReturnType()); +- } +- } +- } +- +- private Class getAnnotationType(Class cl) +- { +- if (cl == null) +- return null; +- +- if (Annotation.class.equals(cl.getSuperclass())) +- return cl; +- +- Class ifaces[] = cl.getInterfaces(); +- +- if (ifaces != null) { +- for (Class iface : ifaces) { +- if (iface.equals(Annotation.class)) +- return cl; +- +- Class annType = getAnnotationType(iface); +- +- if (annType != null) +- return annType; +- } +- } +- +- return getAnnotationType(cl.getSuperclass()); +- } +- +- private static MethodSerializer getMethodSerializer(Class type) +- { +- if (int.class.equals(type) +- || byte.class.equals(type) +- || short.class.equals(type) +- || int.class.equals(type)) { +- return IntMethodSerializer.SER; +- } +- else if (long.class.equals(type)) { +- return LongMethodSerializer.SER; +- } +- else if (double.class.equals(type) || +- float.class.equals(type)) { +- return DoubleMethodSerializer.SER; +- } +- else if (boolean.class.equals(type)) { +- return BooleanMethodSerializer.SER; +- } +- else if (String.class.equals(type)) { +- return StringMethodSerializer.SER; +- } +- else if (java.util.Date.class.equals(type) +- || java.sql.Date.class.equals(type) +- || java.sql.Timestamp.class.equals(type) +- || java.sql.Time.class.equals(type)) { +- return DateMethodSerializer.SER; +- } +- else +- return MethodSerializer.SER; +- } +- +- static HessianException error(Method method, Throwable cause) +- { +- String msg = (method.getDeclaringClass().getSimpleName() +- + "." + method.getName() + "(): " + cause); +- +- throw new HessianMethodSerializationException(msg, cause); +- } +- +- static class MethodSerializer { +- static final MethodSerializer SER = new MethodSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Method method) +- throws IOException +- { +- Object value = null; +- +- try { +- value = method.invoke(obj); +- } catch (InvocationTargetException e) { +- throw error(method, e.getCause()); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- try { +- out.writeObject(value); +- } catch (Exception e) { +- throw error(method, e); +- } +- } +- } +- +- static class BooleanMethodSerializer extends MethodSerializer { +- static final MethodSerializer SER = new BooleanMethodSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Method method) +- throws IOException +- { +- boolean value = false; +- +- try { +- value = (Boolean) method.invoke(obj); +- } catch (InvocationTargetException e) { +- throw error(method, e.getCause()); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeBoolean(value); +- } +- } +- +- static class IntMethodSerializer extends MethodSerializer { +- static final MethodSerializer SER = new IntMethodSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Method method) +- throws IOException +- { +- int value = 0; +- +- try { +- value = (Integer) method.invoke(obj); +- } catch (InvocationTargetException e) { +- throw error(method, e.getCause()); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeInt(value); +- } +- } +- +- static class LongMethodSerializer extends MethodSerializer { +- static final MethodSerializer SER = new LongMethodSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Method method) +- throws IOException +- { +- long value = 0; +- +- try { +- value = (Long) method.invoke(obj); +- } catch (InvocationTargetException e) { +- throw error(method, e.getCause()); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeLong(value); +- } +- } +- +- static class DoubleMethodSerializer extends MethodSerializer { +- static final MethodSerializer SER = new DoubleMethodSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Method method) +- throws IOException +- { +- double value = 0; +- +- try { +- value = (Double) method.invoke(obj); +- } catch (InvocationTargetException e) { +- throw error(method, e.getCause()); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeDouble(value); +- } +- } +- +- static class StringMethodSerializer extends MethodSerializer { +- static final MethodSerializer SER = new StringMethodSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Method method) +- throws IOException +- { +- String value = null; +- +- try { +- value = (String) method.invoke(obj); +- } catch (InvocationTargetException e) { +- throw error(method, e.getCause()); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeString(value); +- } +- } +- +- static class DateMethodSerializer extends MethodSerializer { +- static final MethodSerializer SER = new DateMethodSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Method method) +- throws IOException +- { +- java.util.Date value = null; +- +- try { +- value = (java.util.Date) method.invoke(obj); +- } catch (InvocationTargetException e) { +- throw error(method, e.getCause()); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- if (value == null) +- out.writeNull(); +- else +- out.writeUTCDate(value.getTime()); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.Serializable; ++import java.lang.annotation.Annotation; ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.lang.reflect.InvocationTargetException; ++import java.util.ArrayList; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Serializing a Java annotation ++ */ ++public class AnnotationSerializer extends AbstractSerializer ++{ ++ private static final Logger log ++ = Logger.getLogger(AnnotationSerializer.class.getName()); ++ ++ private static Object []NULL_ARGS = new Object[0]; ++ ++ private Class _annType; ++ private Method []_methods; ++ private MethodSerializer []_methodSerializers; ++ ++ public AnnotationSerializer(Class annType) ++ { ++ if (! Annotation.class.isAssignableFrom(annType)) { ++ throw new IllegalStateException(annType.getName() + " is invalid because it is not a java.lang.annotation.Annotation"); ++ } ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) { ++ return; ++ } ++ ++ init(((Annotation) obj).annotationType()); ++ ++ int ref = out.writeObjectBegin(_annType.getName()); ++ ++ if (ref < -1) { ++ writeObject10(obj, out); ++ } ++ else { ++ if (ref == -1) { ++ writeDefinition20(out); ++ out.writeObjectBegin(_annType.getName()); ++ } ++ ++ writeInstance(obj, out); ++ } ++ } ++ ++ protected void writeObject10(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ for (int i = 0; i < _methods.length; i++) { ++ Method method = _methods[i]; ++ ++ out.writeString(method.getName()); ++ ++ _methodSerializers[i].serialize(out, obj, method); ++ } ++ ++ out.writeMapEnd(); ++ } ++ ++ private void writeDefinition20(AbstractHessianOutput out) ++ throws IOException ++ { ++ out.writeClassFieldLength(_methods.length); ++ ++ for (int i = 0; i < _methods.length; i++) { ++ Method method = _methods[i]; ++ ++ out.writeString(method.getName()); ++ } ++ } ++ ++ public void writeInstance(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ for (int i = 0; i < _methods.length; i++) { ++ Method method = _methods[i]; ++ ++ _methodSerializers[i].serialize(out, obj, method); ++ } ++ } ++ ++ ++ private void init(Class cl) ++ { ++ synchronized (this) { ++ if (_annType != null) ++ return; ++ ++ _annType = cl; ++ ++ ArrayList methods = new ArrayList(); ++ ++ for (Method method : _annType.getDeclaredMethods()) { ++ if (method.getName().equals("hashCode") ++ || method.getName().equals("toString") ++ || method.getName().equals("annotationType")) { ++ continue; ++ } ++ ++ if (method.getParameterTypes().length != 0) ++ continue; ++ ++ methods.add(method); ++ ++ method.setAccessible(true); ++ } ++ ++ if (_annType == null) ++ throw new IllegalStateException(cl.getName() + " is invalid because it does not have a valid annotationType()"); ++ ++ _methods = new Method[methods.size()]; ++ methods.toArray(_methods); ++ ++ _methodSerializers = new MethodSerializer[_methods.length]; ++ ++ for (int i = 0; i < _methods.length; i++) { ++ _methodSerializers[i] = getMethodSerializer(_methods[i].getReturnType()); ++ } ++ } ++ } ++ ++ private Class getAnnotationType(Class cl) ++ { ++ if (cl == null) ++ return null; ++ ++ if (Annotation.class.equals(cl.getSuperclass())) ++ return cl; ++ ++ Class ifaces[] = cl.getInterfaces(); ++ ++ if (ifaces != null) { ++ for (Class iface : ifaces) { ++ if (iface.equals(Annotation.class)) ++ return cl; ++ ++ Class annType = getAnnotationType(iface); ++ ++ if (annType != null) ++ return annType; ++ } ++ } ++ ++ return getAnnotationType(cl.getSuperclass()); ++ } ++ ++ private static MethodSerializer getMethodSerializer(Class type) ++ { ++ if (int.class.equals(type) ++ || byte.class.equals(type) ++ || short.class.equals(type) ++ || int.class.equals(type)) { ++ return IntMethodSerializer.SER; ++ } ++ else if (long.class.equals(type)) { ++ return LongMethodSerializer.SER; ++ } ++ else if (double.class.equals(type) || ++ float.class.equals(type)) { ++ return DoubleMethodSerializer.SER; ++ } ++ else if (boolean.class.equals(type)) { ++ return BooleanMethodSerializer.SER; ++ } ++ else if (String.class.equals(type)) { ++ return StringMethodSerializer.SER; ++ } ++ else if (java.util.Date.class.equals(type) ++ || java.sql.Date.class.equals(type) ++ || java.sql.Timestamp.class.equals(type) ++ || java.sql.Time.class.equals(type)) { ++ return DateMethodSerializer.SER; ++ } ++ else ++ return MethodSerializer.SER; ++ } ++ ++ static HessianException error(Method method, Throwable cause) ++ { ++ String msg = (method.getDeclaringClass().getSimpleName() ++ + "." + method.getName() + "(): " + cause); ++ ++ throw new HessianMethodSerializationException(msg, cause); ++ } ++ ++ static class MethodSerializer { ++ static final MethodSerializer SER = new MethodSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Method method) ++ throws IOException ++ { ++ Object value = null; ++ ++ try { ++ value = method.invoke(obj); ++ } catch (InvocationTargetException e) { ++ throw error(method, e.getCause()); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ try { ++ out.writeObject(value); ++ } catch (Exception e) { ++ throw error(method, e); ++ } ++ } ++ } ++ ++ static class BooleanMethodSerializer extends MethodSerializer { ++ static final MethodSerializer SER = new BooleanMethodSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Method method) ++ throws IOException ++ { ++ boolean value = false; ++ ++ try { ++ value = (Boolean) method.invoke(obj); ++ } catch (InvocationTargetException e) { ++ throw error(method, e.getCause()); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeBoolean(value); ++ } ++ } ++ ++ static class IntMethodSerializer extends MethodSerializer { ++ static final MethodSerializer SER = new IntMethodSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Method method) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = (Integer) method.invoke(obj); ++ } catch (InvocationTargetException e) { ++ throw error(method, e.getCause()); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeInt(value); ++ } ++ } ++ ++ static class LongMethodSerializer extends MethodSerializer { ++ static final MethodSerializer SER = new LongMethodSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Method method) ++ throws IOException ++ { ++ long value = 0; ++ ++ try { ++ value = (Long) method.invoke(obj); ++ } catch (InvocationTargetException e) { ++ throw error(method, e.getCause()); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeLong(value); ++ } ++ } ++ ++ static class DoubleMethodSerializer extends MethodSerializer { ++ static final MethodSerializer SER = new DoubleMethodSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Method method) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = (Double) method.invoke(obj); ++ } catch (InvocationTargetException e) { ++ throw error(method, e.getCause()); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ static class StringMethodSerializer extends MethodSerializer { ++ static final MethodSerializer SER = new StringMethodSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Method method) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = (String) method.invoke(obj); ++ } catch (InvocationTargetException e) { ++ throw error(method, e.getCause()); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeString(value); ++ } ++ } ++ ++ static class DateMethodSerializer extends MethodSerializer { ++ static final MethodSerializer SER = new DateMethodSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Method method) ++ throws IOException ++ { ++ java.util.Date value = null; ++ ++ try { ++ value = (java.util.Date) method.invoke(obj); ++ } catch (InvocationTargetException e) { ++ throw error(method, e.getCause()); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ if (value == null) ++ out.writeNull(); ++ else ++ out.writeUTCDate(value.getTime()); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ArrayDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ArrayDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ArrayDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ArrayDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,164 +1,164 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Array; +-import java.util.ArrayList; +- +-/** +- * Deserializing a Java array +- */ +-public class ArrayDeserializer extends AbstractListDeserializer { +- private Class _componentType; +- private Class _type; +- +- public ArrayDeserializer(Class componentType) +- { +- _componentType = componentType; +- +- if (_componentType != null) { +- try { +- _type = Array.newInstance(_componentType, 0).getClass(); +- } catch (Exception e) { +- } +- } +- +- if (_type == null) +- _type = Object[].class; +- } +- +- public Class getType() +- { +- return _type; +- } +- +- /** +- * Reads the array. +- */ +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- if (length >= 0) { +- Object []data = createArray(length); +- +- in.addRef(data); +- +- if (_componentType != null) { +- for (int i = 0; i < data.length; i++) +- data[i] = in.readObject(_componentType); +- } +- else { +- for (int i = 0; i < data.length; i++) +- data[i] = in.readObject(); +- } +- +- in.readListEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- in.addRef(list); +- +- if (_componentType != null) { +- while (! in.isEnd()) +- list.add(in.readObject(_componentType)); +- } +- else { +- while (! in.isEnd()) +- list.add(in.readObject()); +- } +- +- in.readListEnd(); +- +- Object []data = createArray(list.size()); +- for (int i = 0; i < data.length; i++) +- data[i] = list.get(i); +- +- return data; +- } +- } +- +- /** +- * Reads the array. +- */ +- public Object readLengthList(AbstractHessianInput in, int length) +- throws IOException +- { +- Object []data = createArray(length); +- +- in.addRef(data); +- +- if (_componentType != null) { +- for (int i = 0; i < data.length; i++) +- data[i] = in.readObject(_componentType); +- } +- else { +- for (int i = 0; i < data.length; i++) +- data[i] = in.readObject(); +- } +- +- return data; +- } +- +- protected Object []createArray(int length) +- { +- if (_componentType != null) +- return (Object []) Array.newInstance(_componentType, length); +- else +- return new Object[length]; +- } +- +- public String toString() +- { +- return "ArrayDeserializer[" + _componentType + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Array; ++import java.util.ArrayList; ++ ++/** ++ * Deserializing a Java array ++ */ ++public class ArrayDeserializer extends AbstractListDeserializer { ++ private Class _componentType; ++ private Class _type; ++ ++ public ArrayDeserializer(Class componentType) ++ { ++ _componentType = componentType; ++ ++ if (_componentType != null) { ++ try { ++ _type = Array.newInstance(_componentType, 0).getClass(); ++ } catch (Exception e) { ++ } ++ } ++ ++ if (_type == null) ++ _type = Object[].class; ++ } ++ ++ public Class getType() ++ { ++ return _type; ++ } ++ ++ /** ++ * Reads the array. ++ */ ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ if (length >= 0) { ++ Object []data = createArray(length); ++ ++ in.addRef(data); ++ ++ if (_componentType != null) { ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readObject(_componentType); ++ } ++ else { ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readObject(); ++ } ++ ++ in.readListEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ in.addRef(list); ++ ++ if (_componentType != null) { ++ while (! in.isEnd()) ++ list.add(in.readObject(_componentType)); ++ } ++ else { ++ while (! in.isEnd()) ++ list.add(in.readObject()); ++ } ++ ++ in.readListEnd(); ++ ++ Object []data = createArray(list.size()); ++ for (int i = 0; i < data.length; i++) ++ data[i] = list.get(i); ++ ++ return data; ++ } ++ } ++ ++ /** ++ * Reads the array. ++ */ ++ public Object readLengthList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ Object []data = createArray(length); ++ ++ in.addRef(data); ++ ++ if (_componentType != null) { ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readObject(_componentType); ++ } ++ else { ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readObject(); ++ } ++ ++ return data; ++ } ++ ++ protected Object []createArray(int length) ++ { ++ if (_componentType != null) ++ return (Object []) Array.newInstance(_componentType, length); ++ else ++ return new Object[length]; ++ } ++ ++ public String toString() ++ { ++ return "ArrayDeserializer[" + _componentType + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ArraySerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ArraySerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ArraySerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ArraySerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,94 +1,94 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing a Java array. +- */ +-public class ArraySerializer extends AbstractSerializer { +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) +- return; +- +- Object []array = (Object []) obj; +- +- boolean hasEnd = out.writeListBegin(array.length, +- getArrayType(obj.getClass())); +- +- for (int i = 0; i < array.length; i++) +- out.writeObject(array[i]); +- +- if (hasEnd) +- out.writeListEnd(); +- } +- +- /** +- * Returns the <type> name for a <list>. +- */ +- private String getArrayType(Class cl) +- { +- if (cl.isArray()) +- return '[' + getArrayType(cl.getComponentType()); +- +- String name = cl.getName(); +- +- if (name.equals("java.lang.String")) +- return "string"; +- else if (name.equals("java.lang.Object")) +- return "object"; +- else if (name.equals("java.util.Date")) +- return "date"; +- else +- return name; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing a Java array. ++ */ ++public class ArraySerializer extends AbstractSerializer { ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ Object []array = (Object []) obj; ++ ++ boolean hasEnd = out.writeListBegin(array.length, ++ getArrayType(obj.getClass())); ++ ++ for (int i = 0; i < array.length; i++) ++ out.writeObject(array[i]); ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ } ++ ++ /** ++ * Returns the <type> name for a <list>. ++ */ ++ private String getArrayType(Class cl) ++ { ++ if (cl.isArray()) ++ return '[' + getArrayType(cl.getComponentType()); ++ ++ String name = cl.getName(); ++ ++ if (name.equals("java.lang.String")) ++ return "string"; ++ else if (name.equals("java.lang.Object")) ++ return "object"; ++ else if (name.equals("java.util.Date")) ++ return "date"; ++ else ++ return name; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BasicDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BasicDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/BasicDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/BasicDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,615 +1,615 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.ArrayList; +-import java.util.Date; +- +-/** +- * Serializing an object for known object types. +- */ +-public class BasicDeserializer extends AbstractDeserializer { +- public static final int NULL = BasicSerializer.NULL; +- public static final int BOOLEAN = BasicSerializer.BOOLEAN; +- public static final int BYTE = BasicSerializer.BYTE; +- public static final int SHORT = BasicSerializer.SHORT; +- public static final int INTEGER = BasicSerializer.INTEGER; +- public static final int LONG = BasicSerializer.LONG; +- public static final int FLOAT = BasicSerializer.FLOAT; +- public static final int DOUBLE = BasicSerializer.DOUBLE; +- public static final int CHARACTER = BasicSerializer.CHARACTER; +- public static final int CHARACTER_OBJECT = BasicSerializer.CHARACTER_OBJECT; +- public static final int STRING = BasicSerializer.STRING; +- public static final int DATE = BasicSerializer.DATE; +- public static final int NUMBER = BasicSerializer.NUMBER; +- public static final int OBJECT = BasicSerializer.OBJECT; +- +- public static final int BOOLEAN_ARRAY = BasicSerializer.BOOLEAN_ARRAY; +- public static final int BYTE_ARRAY = BasicSerializer.BYTE_ARRAY; +- public static final int SHORT_ARRAY = BasicSerializer.SHORT_ARRAY; +- public static final int INTEGER_ARRAY = BasicSerializer.INTEGER_ARRAY; +- public static final int LONG_ARRAY = BasicSerializer.LONG_ARRAY; +- public static final int FLOAT_ARRAY = BasicSerializer.FLOAT_ARRAY; +- public static final int DOUBLE_ARRAY = BasicSerializer.DOUBLE_ARRAY; +- public static final int CHARACTER_ARRAY = BasicSerializer.CHARACTER_ARRAY; +- public static final int STRING_ARRAY = BasicSerializer.STRING_ARRAY; +- public static final int OBJECT_ARRAY = BasicSerializer.OBJECT_ARRAY; +- +- private int _code; +- +- public BasicDeserializer(int code) +- { +- _code = code; +- } +- +- public Class getType() +- { +- switch (_code) { +- case NULL: +- return void.class; +- case BOOLEAN: +- return Boolean.class; +- case BYTE: +- return Byte.class; +- case SHORT: +- return Short.class; +- case INTEGER: +- return Integer.class; +- case LONG: +- return Long.class; +- case FLOAT: +- return Float.class; +- case DOUBLE: +- return Double.class; +- case CHARACTER: +- return Character.class; +- case CHARACTER_OBJECT: +- return Character.class; +- case STRING: +- return String.class; +- case DATE: +- return Date.class; +- case NUMBER: +- return Number.class; +- case OBJECT: +- return Object.class; +- +- case BOOLEAN_ARRAY: +- return boolean[].class; +- case BYTE_ARRAY: +- return byte[].class; +- case SHORT_ARRAY: +- return short[].class; +- case INTEGER_ARRAY: +- return int[].class; +- case LONG_ARRAY: +- return long[].class; +- case FLOAT_ARRAY: +- return float[].class; +- case DOUBLE_ARRAY: +- return double[].class; +- case CHARACTER_ARRAY: +- return char[].class; +- case STRING_ARRAY: +- return String[].class; +- case OBJECT_ARRAY: +- return Object[].class; +- default: +- throw new UnsupportedOperationException(); +- } +- } +- +- @Override +- public Object readObject(AbstractHessianInput in) +- throws IOException +- { +- switch (_code) { +- case NULL: +- // hessian/3490 +- in.readObject(); +- +- return null; +- +- case BOOLEAN: +- return Boolean.valueOf(in.readBoolean()); +- +- case BYTE: +- return Byte.valueOf((byte) in.readInt()); +- +- case SHORT: +- return Short.valueOf((short) in.readInt()); +- +- case INTEGER: +- return Integer.valueOf(in.readInt()); +- +- case LONG: +- return Long.valueOf(in.readLong()); +- +- case FLOAT: +- return Float.valueOf((float) in.readDouble()); +- +- case DOUBLE: +- return Double.valueOf(in.readDouble()); +- +- case STRING: +- return in.readString(); +- +- case OBJECT: +- return in.readObject(); +- +- case CHARACTER: +- { +- String s = in.readString(); +- if (s == null || s.equals("")) +- return Character.valueOf((char) 0); +- else +- return Character.valueOf(s.charAt(0)); +- } +- +- case CHARACTER_OBJECT: +- { +- String s = in.readString(); +- if (s == null || s.equals("")) +- return null; +- else +- return Character.valueOf(s.charAt(0)); +- } +- +- case DATE: +- return new Date(in.readUTCDate()); +- +- case NUMBER: +- return in.readObject(); +- +- case BYTE_ARRAY: +- return in.readBytes(); +- +- case CHARACTER_ARRAY: +- { +- String s = in.readString(); +- +- if (s == null) +- return null; +- else { +- int len = s.length(); +- char []chars = new char[len]; +- s.getChars(0, len, chars, 0); +- return chars; +- } +- } +- +- case BOOLEAN_ARRAY: +- case SHORT_ARRAY: +- case INTEGER_ARRAY: +- case LONG_ARRAY: +- case FLOAT_ARRAY: +- case DOUBLE_ARRAY: +- case STRING_ARRAY: +- { +- int code = in.readListStart(); +- +- switch (code) { +- case 'N': +- return null; +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- int length = code - 0x10; +- in.readInt(); +- +- return readLengthList(in, length); +- +- default: +- String type = in.readType(); +- length = in.readLength(); +- +- return readList(in, length); +- } +- } +- +- default: +- throw new UnsupportedOperationException(); +- } +- } +- +- @Override +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- switch (_code) { +- case BOOLEAN_ARRAY: { +- if (length >= 0) { +- boolean []data = new boolean[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readBoolean(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- while (! in.isEnd()) +- list.add(Boolean.valueOf(in.readBoolean())); +- +- in.readEnd(); +- +- boolean []data = new boolean[list.size()]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = ((Boolean) list.get(i)).booleanValue(); +- +- return data; +- } +- } +- +- case SHORT_ARRAY: { +- if (length >= 0) { +- short []data = new short[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = (short) in.readInt(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- while (! in.isEnd()) +- list.add(Short.valueOf((short) in.readInt())); +- +- in.readEnd(); +- +- short []data = new short[list.size()]; +- for (int i = 0; i < data.length; i++) +- data[i] = ((Short) list.get(i)).shortValue(); +- +- in.addRef(data); +- +- return data; +- } +- } +- +- case INTEGER_ARRAY: { +- if (length >= 0) { +- int []data = new int[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readInt(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- while (! in.isEnd()) +- list.add(Integer.valueOf(in.readInt())); +- +- +- in.readEnd(); +- +- int []data = new int[list.size()]; +- for (int i = 0; i < data.length; i++) +- data[i] = ((Integer) list.get(i)).intValue(); +- +- in.addRef(data); +- +- return data; +- } +- } +- +- case LONG_ARRAY: { +- if (length >= 0) { +- long []data = new long[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readLong(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- while (! in.isEnd()) +- list.add(Long.valueOf(in.readLong())); +- +- in.readEnd(); +- +- long []data = new long[list.size()]; +- for (int i = 0; i < data.length; i++) +- data[i] = ((Long) list.get(i)).longValue(); +- +- in.addRef(data); +- +- return data; +- } +- } +- +- case FLOAT_ARRAY: { +- if (length >= 0) { +- float []data = new float[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = (float) in.readDouble(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- while (! in.isEnd()) +- list.add(new Float(in.readDouble())); +- +- in.readEnd(); +- +- float []data = new float[list.size()]; +- for (int i = 0; i < data.length; i++) +- data[i] = ((Float) list.get(i)).floatValue(); +- +- in.addRef(data); +- +- return data; +- } +- } +- +- case DOUBLE_ARRAY: { +- if (length >= 0) { +- double []data = new double[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readDouble(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- while (! in.isEnd()) +- list.add(new Double(in.readDouble())); +- +- in.readEnd(); +- +- double []data = new double[list.size()]; +- in.addRef(data); +- for (int i = 0; i < data.length; i++) +- data[i] = ((Double) list.get(i)).doubleValue(); +- +- return data; +- } +- } +- +- case STRING_ARRAY: { +- if (length >= 0) { +- String []data = new String[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readString(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- while (! in.isEnd()) +- list.add(in.readString()); +- +- in.readEnd(); +- +- String []data = new String[list.size()]; +- in.addRef(data); +- for (int i = 0; i < data.length; i++) +- data[i] = (String) list.get(i); +- +- return data; +- } +- } +- +- case OBJECT_ARRAY: { +- if (length >= 0) { +- Object []data = new Object[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readObject(); +- +- in.readEnd(); +- +- return data; +- } +- else { +- ArrayList list = new ArrayList(); +- +- in.addRef(list); // XXX: potential issues here +- +- while (! in.isEnd()) +- list.add(in.readObject()); +- +- in.readEnd(); +- +- Object []data = new Object[list.size()]; +- for (int i = 0; i < data.length; i++) +- data[i] = (Object) list.get(i); +- +- return data; +- } +- } +- +- default: +- throw new UnsupportedOperationException(String.valueOf(this)); +- } +- } +- +- public Object readLengthList(AbstractHessianInput in, int length) +- throws IOException +- { +- switch (_code) { +- case BOOLEAN_ARRAY: { +- boolean []data = new boolean[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readBoolean(); +- +- return data; +- } +- +- case SHORT_ARRAY: { +- short []data = new short[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = (short) in.readInt(); +- +- return data; +- } +- +- case INTEGER_ARRAY: { +- int []data = new int[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readInt(); +- +- return data; +- } +- +- case LONG_ARRAY: { +- long []data = new long[length]; +- +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readLong(); +- +- return data; +- } +- +- case FLOAT_ARRAY: { +- float []data = new float[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = (float) in.readDouble(); +- +- return data; +- } +- +- case DOUBLE_ARRAY: { +- double []data = new double[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readDouble(); +- +- return data; +- } +- +- case STRING_ARRAY: { +- String []data = new String[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readString(); +- +- return data; +- } +- +- case OBJECT_ARRAY: { +- Object []data = new Object[length]; +- in.addRef(data); +- +- for (int i = 0; i < data.length; i++) +- data[i] = in.readObject(); +- +- return data; +- } +- +- default: +- throw new UnsupportedOperationException(String.valueOf(this)); +- } +- } +- +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _code + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.ArrayList; ++import java.util.Date; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class BasicDeserializer extends AbstractDeserializer { ++ public static final int NULL = BasicSerializer.NULL; ++ public static final int BOOLEAN = BasicSerializer.BOOLEAN; ++ public static final int BYTE = BasicSerializer.BYTE; ++ public static final int SHORT = BasicSerializer.SHORT; ++ public static final int INTEGER = BasicSerializer.INTEGER; ++ public static final int LONG = BasicSerializer.LONG; ++ public static final int FLOAT = BasicSerializer.FLOAT; ++ public static final int DOUBLE = BasicSerializer.DOUBLE; ++ public static final int CHARACTER = BasicSerializer.CHARACTER; ++ public static final int CHARACTER_OBJECT = BasicSerializer.CHARACTER_OBJECT; ++ public static final int STRING = BasicSerializer.STRING; ++ public static final int DATE = BasicSerializer.DATE; ++ public static final int NUMBER = BasicSerializer.NUMBER; ++ public static final int OBJECT = BasicSerializer.OBJECT; ++ ++ public static final int BOOLEAN_ARRAY = BasicSerializer.BOOLEAN_ARRAY; ++ public static final int BYTE_ARRAY = BasicSerializer.BYTE_ARRAY; ++ public static final int SHORT_ARRAY = BasicSerializer.SHORT_ARRAY; ++ public static final int INTEGER_ARRAY = BasicSerializer.INTEGER_ARRAY; ++ public static final int LONG_ARRAY = BasicSerializer.LONG_ARRAY; ++ public static final int FLOAT_ARRAY = BasicSerializer.FLOAT_ARRAY; ++ public static final int DOUBLE_ARRAY = BasicSerializer.DOUBLE_ARRAY; ++ public static final int CHARACTER_ARRAY = BasicSerializer.CHARACTER_ARRAY; ++ public static final int STRING_ARRAY = BasicSerializer.STRING_ARRAY; ++ public static final int OBJECT_ARRAY = BasicSerializer.OBJECT_ARRAY; ++ ++ private int _code; ++ ++ public BasicDeserializer(int code) ++ { ++ _code = code; ++ } ++ ++ public Class getType() ++ { ++ switch (_code) { ++ case NULL: ++ return void.class; ++ case BOOLEAN: ++ return Boolean.class; ++ case BYTE: ++ return Byte.class; ++ case SHORT: ++ return Short.class; ++ case INTEGER: ++ return Integer.class; ++ case LONG: ++ return Long.class; ++ case FLOAT: ++ return Float.class; ++ case DOUBLE: ++ return Double.class; ++ case CHARACTER: ++ return Character.class; ++ case CHARACTER_OBJECT: ++ return Character.class; ++ case STRING: ++ return String.class; ++ case DATE: ++ return Date.class; ++ case NUMBER: ++ return Number.class; ++ case OBJECT: ++ return Object.class; ++ ++ case BOOLEAN_ARRAY: ++ return boolean[].class; ++ case BYTE_ARRAY: ++ return byte[].class; ++ case SHORT_ARRAY: ++ return short[].class; ++ case INTEGER_ARRAY: ++ return int[].class; ++ case LONG_ARRAY: ++ return long[].class; ++ case FLOAT_ARRAY: ++ return float[].class; ++ case DOUBLE_ARRAY: ++ return double[].class; ++ case CHARACTER_ARRAY: ++ return char[].class; ++ case STRING_ARRAY: ++ return String[].class; ++ case OBJECT_ARRAY: ++ return Object[].class; ++ default: ++ throw new UnsupportedOperationException(); ++ } ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in) ++ throws IOException ++ { ++ switch (_code) { ++ case NULL: ++ // hessian/3490 ++ in.readObject(); ++ ++ return null; ++ ++ case BOOLEAN: ++ return Boolean.valueOf(in.readBoolean()); ++ ++ case BYTE: ++ return Byte.valueOf((byte) in.readInt()); ++ ++ case SHORT: ++ return Short.valueOf((short) in.readInt()); ++ ++ case INTEGER: ++ return Integer.valueOf(in.readInt()); ++ ++ case LONG: ++ return Long.valueOf(in.readLong()); ++ ++ case FLOAT: ++ return Float.valueOf((float) in.readDouble()); ++ ++ case DOUBLE: ++ return Double.valueOf(in.readDouble()); ++ ++ case STRING: ++ return in.readString(); ++ ++ case OBJECT: ++ return in.readObject(); ++ ++ case CHARACTER: ++ { ++ String s = in.readString(); ++ if (s == null || s.equals("")) ++ return Character.valueOf((char) 0); ++ else ++ return Character.valueOf(s.charAt(0)); ++ } ++ ++ case CHARACTER_OBJECT: ++ { ++ String s = in.readString(); ++ if (s == null || s.equals("")) ++ return null; ++ else ++ return Character.valueOf(s.charAt(0)); ++ } ++ ++ case DATE: ++ return new Date(in.readUTCDate()); ++ ++ case NUMBER: ++ return in.readObject(); ++ ++ case BYTE_ARRAY: ++ return in.readBytes(); ++ ++ case CHARACTER_ARRAY: ++ { ++ String s = in.readString(); ++ ++ if (s == null) ++ return null; ++ else { ++ int len = s.length(); ++ char []chars = new char[len]; ++ s.getChars(0, len, chars, 0); ++ return chars; ++ } ++ } ++ ++ case BOOLEAN_ARRAY: ++ case SHORT_ARRAY: ++ case INTEGER_ARRAY: ++ case LONG_ARRAY: ++ case FLOAT_ARRAY: ++ case DOUBLE_ARRAY: ++ case STRING_ARRAY: ++ { ++ int code = in.readListStart(); ++ ++ switch (code) { ++ case 'N': ++ return null; ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ int length = code - 0x10; ++ in.readInt(); ++ ++ return readLengthList(in, length); ++ ++ default: ++ String type = in.readType(); ++ length = in.readLength(); ++ ++ return readList(in, length); ++ } ++ } ++ ++ default: ++ throw new UnsupportedOperationException(); ++ } ++ } ++ ++ @Override ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ switch (_code) { ++ case BOOLEAN_ARRAY: { ++ if (length >= 0) { ++ boolean []data = new boolean[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readBoolean(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ while (! in.isEnd()) ++ list.add(Boolean.valueOf(in.readBoolean())); ++ ++ in.readEnd(); ++ ++ boolean []data = new boolean[list.size()]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = ((Boolean) list.get(i)).booleanValue(); ++ ++ return data; ++ } ++ } ++ ++ case SHORT_ARRAY: { ++ if (length >= 0) { ++ short []data = new short[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = (short) in.readInt(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ while (! in.isEnd()) ++ list.add(Short.valueOf((short) in.readInt())); ++ ++ in.readEnd(); ++ ++ short []data = new short[list.size()]; ++ for (int i = 0; i < data.length; i++) ++ data[i] = ((Short) list.get(i)).shortValue(); ++ ++ in.addRef(data); ++ ++ return data; ++ } ++ } ++ ++ case INTEGER_ARRAY: { ++ if (length >= 0) { ++ int []data = new int[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readInt(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ while (! in.isEnd()) ++ list.add(Integer.valueOf(in.readInt())); ++ ++ ++ in.readEnd(); ++ ++ int []data = new int[list.size()]; ++ for (int i = 0; i < data.length; i++) ++ data[i] = ((Integer) list.get(i)).intValue(); ++ ++ in.addRef(data); ++ ++ return data; ++ } ++ } ++ ++ case LONG_ARRAY: { ++ if (length >= 0) { ++ long []data = new long[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readLong(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ while (! in.isEnd()) ++ list.add(Long.valueOf(in.readLong())); ++ ++ in.readEnd(); ++ ++ long []data = new long[list.size()]; ++ for (int i = 0; i < data.length; i++) ++ data[i] = ((Long) list.get(i)).longValue(); ++ ++ in.addRef(data); ++ ++ return data; ++ } ++ } ++ ++ case FLOAT_ARRAY: { ++ if (length >= 0) { ++ float []data = new float[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = (float) in.readDouble(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ while (! in.isEnd()) ++ list.add(new Float(in.readDouble())); ++ ++ in.readEnd(); ++ ++ float []data = new float[list.size()]; ++ for (int i = 0; i < data.length; i++) ++ data[i] = ((Float) list.get(i)).floatValue(); ++ ++ in.addRef(data); ++ ++ return data; ++ } ++ } ++ ++ case DOUBLE_ARRAY: { ++ if (length >= 0) { ++ double []data = new double[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readDouble(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ while (! in.isEnd()) ++ list.add(new Double(in.readDouble())); ++ ++ in.readEnd(); ++ ++ double []data = new double[list.size()]; ++ in.addRef(data); ++ for (int i = 0; i < data.length; i++) ++ data[i] = ((Double) list.get(i)).doubleValue(); ++ ++ return data; ++ } ++ } ++ ++ case STRING_ARRAY: { ++ if (length >= 0) { ++ String []data = new String[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readString(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ while (! in.isEnd()) ++ list.add(in.readString()); ++ ++ in.readEnd(); ++ ++ String []data = new String[list.size()]; ++ in.addRef(data); ++ for (int i = 0; i < data.length; i++) ++ data[i] = (String) list.get(i); ++ ++ return data; ++ } ++ } ++ ++ case OBJECT_ARRAY: { ++ if (length >= 0) { ++ Object []data = new Object[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readObject(); ++ ++ in.readEnd(); ++ ++ return data; ++ } ++ else { ++ ArrayList list = new ArrayList(); ++ ++ in.addRef(list); // XXX: potential issues here ++ ++ while (! in.isEnd()) ++ list.add(in.readObject()); ++ ++ in.readEnd(); ++ ++ Object []data = new Object[list.size()]; ++ for (int i = 0; i < data.length; i++) ++ data[i] = (Object) list.get(i); ++ ++ return data; ++ } ++ } ++ ++ default: ++ throw new UnsupportedOperationException(String.valueOf(this)); ++ } ++ } ++ ++ public Object readLengthList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ switch (_code) { ++ case BOOLEAN_ARRAY: { ++ boolean []data = new boolean[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readBoolean(); ++ ++ return data; ++ } ++ ++ case SHORT_ARRAY: { ++ short []data = new short[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = (short) in.readInt(); ++ ++ return data; ++ } ++ ++ case INTEGER_ARRAY: { ++ int []data = new int[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readInt(); ++ ++ return data; ++ } ++ ++ case LONG_ARRAY: { ++ long []data = new long[length]; ++ ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readLong(); ++ ++ return data; ++ } ++ ++ case FLOAT_ARRAY: { ++ float []data = new float[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = (float) in.readDouble(); ++ ++ return data; ++ } ++ ++ case DOUBLE_ARRAY: { ++ double []data = new double[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readDouble(); ++ ++ return data; ++ } ++ ++ case STRING_ARRAY: { ++ String []data = new String[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readString(); ++ ++ return data; ++ } ++ ++ case OBJECT_ARRAY: { ++ Object []data = new Object[length]; ++ in.addRef(data); ++ ++ for (int i = 0; i < data.length; i++) ++ data[i] = in.readObject(); ++ ++ return data; ++ } ++ ++ default: ++ throw new UnsupportedOperationException(String.valueOf(this)); ++ } ++ } ++ ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _code + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BasicSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BasicSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/BasicSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/BasicSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,335 +1,335 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.Date; +- +-/** +- * Serializing an object for known object types. +- */ +-public class BasicSerializer extends AbstractSerializer +- implements ObjectSerializer +-{ +- public static final int NULL = 0; +- public static final int BOOLEAN = NULL + 1; +- public static final int BYTE = BOOLEAN + 1; +- public static final int SHORT = BYTE + 1; +- public static final int INTEGER = SHORT + 1; +- public static final int LONG = INTEGER + 1; +- public static final int FLOAT = LONG + 1; +- public static final int DOUBLE = FLOAT + 1; +- public static final int CHARACTER = DOUBLE + 1; +- public static final int CHARACTER_OBJECT = CHARACTER + 1; +- public static final int STRING = CHARACTER_OBJECT + 1; +- public static final int STRING_BUILDER = STRING + 1; +- public static final int DATE = STRING_BUILDER + 1; +- public static final int NUMBER = DATE + 1; +- public static final int OBJECT = NUMBER + 1; +- +- public static final int BOOLEAN_ARRAY = OBJECT + 1; +- public static final int BYTE_ARRAY = BOOLEAN_ARRAY + 1; +- public static final int SHORT_ARRAY = BYTE_ARRAY + 1; +- public static final int INTEGER_ARRAY = SHORT_ARRAY + 1; +- public static final int LONG_ARRAY = INTEGER_ARRAY + 1; +- public static final int FLOAT_ARRAY = LONG_ARRAY + 1; +- public static final int DOUBLE_ARRAY = FLOAT_ARRAY + 1; +- public static final int CHARACTER_ARRAY = DOUBLE_ARRAY + 1; +- public static final int STRING_ARRAY = CHARACTER_ARRAY + 1; +- public static final int OBJECT_ARRAY = STRING_ARRAY + 1; +- +- public static final int BYTE_HANDLE = OBJECT_ARRAY + 1; +- public static final int SHORT_HANDLE = BYTE_HANDLE + 1; +- public static final int FLOAT_HANDLE = SHORT_HANDLE + 1; +- +- private static final BasicSerializer BYTE_HANDLE_SERIALIZER +- = new BasicSerializer(BYTE_HANDLE); +- +- private static final BasicSerializer SHORT_HANDLE_SERIALIZER +- = new BasicSerializer(SHORT_HANDLE); +- +- private static final BasicSerializer FLOAT_HANDLE_SERIALIZER +- = new BasicSerializer(FLOAT_HANDLE); +- +- private int _code; +- +- public BasicSerializer(int code) +- { +- _code = code; +- } +- +- public Serializer getObjectSerializer() +- { +- switch (_code) { +- case BYTE: +- return BYTE_HANDLE_SERIALIZER; +- case SHORT: +- return SHORT_HANDLE_SERIALIZER; +- case FLOAT: +- return FLOAT_HANDLE_SERIALIZER; +- default: +- return this; +- } +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- switch (_code) { +- case BOOLEAN: +- out.writeBoolean(((Boolean) obj).booleanValue()); +- break; +- +- case BYTE: +- case SHORT: +- case INTEGER: +- out.writeInt(((Number) obj).intValue()); +- break; +- +- case LONG: +- out.writeLong(((Number) obj).longValue()); +- break; +- +- case FLOAT: +- case DOUBLE: +- out.writeDouble(((Number) obj).doubleValue()); +- break; +- +- case CHARACTER: +- case CHARACTER_OBJECT: +- out.writeString(String.valueOf(obj)); +- break; +- +- case STRING: +- out.writeString((String) obj); +- break; +- +- case STRING_BUILDER: +- out.writeString(((StringBuilder) obj).toString()); +- break; +- +- case DATE: +- out.writeUTCDate(((Date) obj).getTime()); +- break; +- +- case BOOLEAN_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- boolean []data = (boolean []) obj; +- boolean hasEnd = out.writeListBegin(data.length, "[boolean"); +- for (int i = 0; i < data.length; i++) +- out.writeBoolean(data[i]); +- +- if (hasEnd) +- out.writeListEnd(); +- +- break; +- } +- +- case BYTE_ARRAY: +- { +- byte []data = (byte []) obj; +- out.writeBytes(data, 0, data.length); +- break; +- } +- +- case SHORT_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- short []data = (short []) obj; +- boolean hasEnd = out.writeListBegin(data.length, "[short"); +- +- for (int i = 0; i < data.length; i++) +- out.writeInt(data[i]); +- +- if (hasEnd) +- out.writeListEnd(); +- break; +- } +- +- case INTEGER_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- int []data = (int []) obj; +- +- boolean hasEnd = out.writeListBegin(data.length, "[int"); +- +- for (int i = 0; i < data.length; i++) +- out.writeInt(data[i]); +- +- if (hasEnd) +- out.writeListEnd(); +- +- break; +- } +- +- case LONG_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- long []data = (long []) obj; +- +- boolean hasEnd = out.writeListBegin(data.length, "[long"); +- +- for (int i = 0; i < data.length; i++) +- out.writeLong(data[i]); +- +- if (hasEnd) +- out.writeListEnd(); +- break; +- } +- +- case FLOAT_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- float []data = (float []) obj; +- +- boolean hasEnd = out.writeListBegin(data.length, "[float"); +- +- for (int i = 0; i < data.length; i++) +- out.writeDouble(data[i]); +- +- if (hasEnd) +- out.writeListEnd(); +- break; +- } +- +- case DOUBLE_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- double []data = (double []) obj; +- boolean hasEnd = out.writeListBegin(data.length, "[double"); +- +- for (int i = 0; i < data.length; i++) +- out.writeDouble(data[i]); +- +- if (hasEnd) +- out.writeListEnd(); +- break; +- } +- +- case STRING_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- String []data = (String []) obj; +- +- boolean hasEnd = out.writeListBegin(data.length, "[string"); +- +- for (int i = 0; i < data.length; i++) { +- out.writeString(data[i]); +- } +- +- if (hasEnd) +- out.writeListEnd(); +- break; +- } +- +- case CHARACTER_ARRAY: +- { +- char []data = (char []) obj; +- out.writeString(data, 0, data.length); +- break; +- } +- +- case OBJECT_ARRAY: +- { +- if (out.addRef(obj)) +- return; +- +- Object []data = (Object []) obj; +- +- boolean hasEnd = out.writeListBegin(data.length, "[object"); +- +- for (int i = 0; i < data.length; i++) { +- out.writeObject(data[i]); +- } +- +- if (hasEnd) +- out.writeListEnd(); +- break; +- } +- +- case NULL: +- out.writeNull(); +- break; +- +- case OBJECT: +- ObjectHandleSerializer.SER.writeObject(obj, out); +- break; +- +- case BYTE_HANDLE: +- out.writeObject(new ByteHandle((Byte) obj)); +- break; +- +- case SHORT_HANDLE: +- out.writeObject(new ShortHandle((Short) obj)); +- break; +- +- case FLOAT_HANDLE: +- out.writeObject(new FloatHandle((Float) obj)); +- break; +- +- default: +- throw new RuntimeException(_code + " unknown code for " + obj.getClass()); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.Date; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class BasicSerializer extends AbstractSerializer ++ implements ObjectSerializer ++{ ++ public static final int NULL = 0; ++ public static final int BOOLEAN = NULL + 1; ++ public static final int BYTE = BOOLEAN + 1; ++ public static final int SHORT = BYTE + 1; ++ public static final int INTEGER = SHORT + 1; ++ public static final int LONG = INTEGER + 1; ++ public static final int FLOAT = LONG + 1; ++ public static final int DOUBLE = FLOAT + 1; ++ public static final int CHARACTER = DOUBLE + 1; ++ public static final int CHARACTER_OBJECT = CHARACTER + 1; ++ public static final int STRING = CHARACTER_OBJECT + 1; ++ public static final int STRING_BUILDER = STRING + 1; ++ public static final int DATE = STRING_BUILDER + 1; ++ public static final int NUMBER = DATE + 1; ++ public static final int OBJECT = NUMBER + 1; ++ ++ public static final int BOOLEAN_ARRAY = OBJECT + 1; ++ public static final int BYTE_ARRAY = BOOLEAN_ARRAY + 1; ++ public static final int SHORT_ARRAY = BYTE_ARRAY + 1; ++ public static final int INTEGER_ARRAY = SHORT_ARRAY + 1; ++ public static final int LONG_ARRAY = INTEGER_ARRAY + 1; ++ public static final int FLOAT_ARRAY = LONG_ARRAY + 1; ++ public static final int DOUBLE_ARRAY = FLOAT_ARRAY + 1; ++ public static final int CHARACTER_ARRAY = DOUBLE_ARRAY + 1; ++ public static final int STRING_ARRAY = CHARACTER_ARRAY + 1; ++ public static final int OBJECT_ARRAY = STRING_ARRAY + 1; ++ ++ public static final int BYTE_HANDLE = OBJECT_ARRAY + 1; ++ public static final int SHORT_HANDLE = BYTE_HANDLE + 1; ++ public static final int FLOAT_HANDLE = SHORT_HANDLE + 1; ++ ++ private static final BasicSerializer BYTE_HANDLE_SERIALIZER ++ = new BasicSerializer(BYTE_HANDLE); ++ ++ private static final BasicSerializer SHORT_HANDLE_SERIALIZER ++ = new BasicSerializer(SHORT_HANDLE); ++ ++ private static final BasicSerializer FLOAT_HANDLE_SERIALIZER ++ = new BasicSerializer(FLOAT_HANDLE); ++ ++ private int _code; ++ ++ public BasicSerializer(int code) ++ { ++ _code = code; ++ } ++ ++ public Serializer getObjectSerializer() ++ { ++ switch (_code) { ++ case BYTE: ++ return BYTE_HANDLE_SERIALIZER; ++ case SHORT: ++ return SHORT_HANDLE_SERIALIZER; ++ case FLOAT: ++ return FLOAT_HANDLE_SERIALIZER; ++ default: ++ return this; ++ } ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ switch (_code) { ++ case BOOLEAN: ++ out.writeBoolean(((Boolean) obj).booleanValue()); ++ break; ++ ++ case BYTE: ++ case SHORT: ++ case INTEGER: ++ out.writeInt(((Number) obj).intValue()); ++ break; ++ ++ case LONG: ++ out.writeLong(((Number) obj).longValue()); ++ break; ++ ++ case FLOAT: ++ case DOUBLE: ++ out.writeDouble(((Number) obj).doubleValue()); ++ break; ++ ++ case CHARACTER: ++ case CHARACTER_OBJECT: ++ out.writeString(String.valueOf(obj)); ++ break; ++ ++ case STRING: ++ out.writeString((String) obj); ++ break; ++ ++ case STRING_BUILDER: ++ out.writeString(((StringBuilder) obj).toString()); ++ break; ++ ++ case DATE: ++ out.writeUTCDate(((Date) obj).getTime()); ++ break; ++ ++ case BOOLEAN_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ boolean []data = (boolean []) obj; ++ boolean hasEnd = out.writeListBegin(data.length, "[boolean"); ++ for (int i = 0; i < data.length; i++) ++ out.writeBoolean(data[i]); ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ ++ break; ++ } ++ ++ case BYTE_ARRAY: ++ { ++ byte []data = (byte []) obj; ++ out.writeBytes(data, 0, data.length); ++ break; ++ } ++ ++ case SHORT_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ short []data = (short []) obj; ++ boolean hasEnd = out.writeListBegin(data.length, "[short"); ++ ++ for (int i = 0; i < data.length; i++) ++ out.writeInt(data[i]); ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ break; ++ } ++ ++ case INTEGER_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ int []data = (int []) obj; ++ ++ boolean hasEnd = out.writeListBegin(data.length, "[int"); ++ ++ for (int i = 0; i < data.length; i++) ++ out.writeInt(data[i]); ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ ++ break; ++ } ++ ++ case LONG_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ long []data = (long []) obj; ++ ++ boolean hasEnd = out.writeListBegin(data.length, "[long"); ++ ++ for (int i = 0; i < data.length; i++) ++ out.writeLong(data[i]); ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ break; ++ } ++ ++ case FLOAT_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ float []data = (float []) obj; ++ ++ boolean hasEnd = out.writeListBegin(data.length, "[float"); ++ ++ for (int i = 0; i < data.length; i++) ++ out.writeDouble(data[i]); ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ break; ++ } ++ ++ case DOUBLE_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ double []data = (double []) obj; ++ boolean hasEnd = out.writeListBegin(data.length, "[double"); ++ ++ for (int i = 0; i < data.length; i++) ++ out.writeDouble(data[i]); ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ break; ++ } ++ ++ case STRING_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ String []data = (String []) obj; ++ ++ boolean hasEnd = out.writeListBegin(data.length, "[string"); ++ ++ for (int i = 0; i < data.length; i++) { ++ out.writeString(data[i]); ++ } ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ break; ++ } ++ ++ case CHARACTER_ARRAY: ++ { ++ char []data = (char []) obj; ++ out.writeString(data, 0, data.length); ++ break; ++ } ++ ++ case OBJECT_ARRAY: ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ Object []data = (Object []) obj; ++ ++ boolean hasEnd = out.writeListBegin(data.length, "[object"); ++ ++ for (int i = 0; i < data.length; i++) { ++ out.writeObject(data[i]); ++ } ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ break; ++ } ++ ++ case NULL: ++ out.writeNull(); ++ break; ++ ++ case OBJECT: ++ ObjectHandleSerializer.SER.writeObject(obj, out); ++ break; ++ ++ case BYTE_HANDLE: ++ out.writeObject(new ByteHandle((Byte) obj)); ++ break; ++ ++ case SHORT_HANDLE: ++ out.writeObject(new ShortHandle((Short) obj)); ++ break; ++ ++ case FLOAT_HANDLE: ++ out.writeObject(new FloatHandle((Float) obj)); ++ break; ++ ++ default: ++ throw new RuntimeException(_code + " unknown code for " + obj.getClass()); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BeanDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BeanDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/BeanDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/BeanDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,296 +1,296 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Constructor; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.HashMap; +-import java.util.Locale; +- +-/** +- * Serializing an object for known object types. +- */ +-public class BeanDeserializer extends AbstractMapDeserializer { +- private Class _type; +- private HashMap _methodMap; +- private Method _readResolve; +- private Constructor _constructor; +- private Object []_constructorArgs; +- +- public BeanDeserializer(Class cl) +- { +- _type = cl; +- _methodMap = getMethodMap(cl); +- +- _readResolve = getReadResolve(cl); +- +- Constructor []constructors = cl.getConstructors(); +- int bestLength = Integer.MAX_VALUE; +- +- for (int i = 0; i < constructors.length; i++) { +- if (constructors[i].getParameterTypes().length < bestLength) { +- _constructor = constructors[i]; +- bestLength = _constructor.getParameterTypes().length; +- } +- } +- +- if (_constructor != null) { +- _constructor.setAccessible(true); +- Class []params = _constructor.getParameterTypes(); +- _constructorArgs = new Object[params.length]; +- for (int i = 0; i < params.length; i++) { +- _constructorArgs[i] = getParamArg(params[i]); +- } +- } +- } +- +- public Class getType() +- { +- return _type; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- try { +- Object obj = instantiate(); +- +- return readMap(in, obj); +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- public Object readMap(AbstractHessianInput in, Object obj) +- throws IOException +- { +- try { +- int ref = in.addRef(obj); +- +- while (! in.isEnd()) { +- Object key = in.readObject(); +- +- Method method = (Method) _methodMap.get(key); +- +- if (method != null) { +- Object value = in.readObject(method.getParameterTypes()[0]); +- +- method.invoke(obj, new Object[] {value }); +- } +- else { +- Object value = in.readObject(); +- } +- } +- +- in.readMapEnd(); +- +- Object resolve = resolve(obj); +- +- if (obj != resolve) +- in.setRef(ref, resolve); +- +- return resolve; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- private Object resolve(Object obj) +- { +- // if there's a readResolve method, call it +- try { +- if (_readResolve != null) +- return _readResolve.invoke(obj, new Object[0]); +- } catch (Exception e) { +- } +- +- return obj; +- } +- +- protected Object instantiate() +- throws Exception +- { +- return _constructor.newInstance(_constructorArgs); +- } +- +- /** +- * Returns the readResolve method +- */ +- protected Method getReadResolve(Class cl) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (method.getName().equals("readResolve") && +- method.getParameterTypes().length == 0) +- return method; +- } +- } +- +- return null; +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- protected HashMap getMethodMap(Class cl) +- { +- HashMap methodMap = new HashMap(); +- +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (Modifier.isStatic(method.getModifiers())) +- continue; +- +- String name = method.getName(); +- +- if (! name.startsWith("set")) +- continue; +- +- Class []paramTypes = method.getParameterTypes(); +- if (paramTypes.length != 1) +- continue; +- +- if (! method.getReturnType().equals(void.class)) +- continue; +- +- if (findGetter(methods, name, paramTypes[0]) == null) +- continue; +- +- // XXX: could parameterize the handler to only deal with public +- try { +- method.setAccessible(true); +- } catch (Throwable e) { +- e.printStackTrace(); +- } +- +- name = name.substring(3); +- +- int j = 0; +- for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { +- } +- +- if (j == 1) +- name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); +- else if (j > 1) +- name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); +- +- +- methodMap.put(name, method); +- } +- } +- +- return methodMap; +- } +- +- /** +- * Finds any matching setter. +- */ +- private Method findGetter(Method []methods, String setterName, Class arg) +- { +- String getterName = "get" + setterName.substring(3); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (! method.getName().equals(getterName)) +- continue; +- +- if (! method.getReturnType().equals(arg)) +- continue; +- +- Class []params = method.getParameterTypes(); +- +- if (params.length == 0) +- return method; +- } +- +- return null; +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- protected static Object getParamArg(Class cl) +- { +- if (! cl.isPrimitive()) +- return null; +- else if (boolean.class.equals(cl)) +- return Boolean.FALSE; +- else if (byte.class.equals(cl)) +- return Byte.valueOf((byte) 0); +- else if (short.class.equals(cl)) +- return Short.valueOf((short) 0); +- else if (char.class.equals(cl)) +- return Character.valueOf((char) 0); +- else if (int.class.equals(cl)) +- return Integer.valueOf(0); +- else if (long.class.equals(cl)) +- return Long.valueOf(0); +- else if (float.class.equals(cl)) +- return Double.valueOf(0); +- else if (double.class.equals(cl)) +- return Double.valueOf(0); +- else +- throw new UnsupportedOperationException(); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Constructor; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.HashMap; ++import java.util.Locale; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class BeanDeserializer extends AbstractMapDeserializer { ++ private Class _type; ++ private HashMap _methodMap; ++ private Method _readResolve; ++ private Constructor _constructor; ++ private Object []_constructorArgs; ++ ++ public BeanDeserializer(Class cl) ++ { ++ _type = cl; ++ _methodMap = getMethodMap(cl); ++ ++ _readResolve = getReadResolve(cl); ++ ++ Constructor []constructors = cl.getConstructors(); ++ int bestLength = Integer.MAX_VALUE; ++ ++ for (int i = 0; i < constructors.length; i++) { ++ if (constructors[i].getParameterTypes().length < bestLength) { ++ _constructor = constructors[i]; ++ bestLength = _constructor.getParameterTypes().length; ++ } ++ } ++ ++ if (_constructor != null) { ++ _constructor.setAccessible(true); ++ Class []params = _constructor.getParameterTypes(); ++ _constructorArgs = new Object[params.length]; ++ for (int i = 0; i < params.length; i++) { ++ _constructorArgs[i] = getParamArg(params[i]); ++ } ++ } ++ } ++ ++ public Class getType() ++ { ++ return _type; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readMap(in, obj); ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ public Object readMap(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ while (! in.isEnd()) { ++ Object key = in.readObject(); ++ ++ Method method = (Method) _methodMap.get(key); ++ ++ if (method != null) { ++ Object value = in.readObject(method.getParameterTypes()[0]); ++ ++ method.invoke(obj, new Object[] {value }); ++ } ++ else { ++ Object value = in.readObject(); ++ } ++ } ++ ++ in.readMapEnd(); ++ ++ Object resolve = resolve(obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ private Object resolve(Object obj) ++ { ++ // if there's a readResolve method, call it ++ try { ++ if (_readResolve != null) ++ return _readResolve.invoke(obj, new Object[0]); ++ } catch (Exception e) { ++ } ++ ++ return obj; ++ } ++ ++ protected Object instantiate() ++ throws Exception ++ { ++ return _constructor.newInstance(_constructorArgs); ++ } ++ ++ /** ++ * Returns the readResolve method ++ */ ++ protected Method getReadResolve(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("readResolve") && ++ method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected HashMap getMethodMap(Class cl) ++ { ++ HashMap methodMap = new HashMap(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (Modifier.isStatic(method.getModifiers())) ++ continue; ++ ++ String name = method.getName(); ++ ++ if (! name.startsWith("set")) ++ continue; ++ ++ Class []paramTypes = method.getParameterTypes(); ++ if (paramTypes.length != 1) ++ continue; ++ ++ if (! method.getReturnType().equals(void.class)) ++ continue; ++ ++ if (findGetter(methods, name, paramTypes[0]) == null) ++ continue; ++ ++ // XXX: could parameterize the handler to only deal with public ++ try { ++ method.setAccessible(true); ++ } catch (Throwable e) { ++ e.printStackTrace(); ++ } ++ ++ name = name.substring(3); ++ ++ int j = 0; ++ for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { ++ } ++ ++ if (j == 1) ++ name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); ++ else if (j > 1) ++ name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); ++ ++ ++ methodMap.put(name, method); ++ } ++ } ++ ++ return methodMap; ++ } ++ ++ /** ++ * Finds any matching setter. ++ */ ++ private Method findGetter(Method []methods, String setterName, Class arg) ++ { ++ String getterName = "get" + setterName.substring(3); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (! method.getName().equals(getterName)) ++ continue; ++ ++ if (! method.getReturnType().equals(arg)) ++ continue; ++ ++ Class []params = method.getParameterTypes(); ++ ++ if (params.length == 0) ++ return method; ++ } ++ ++ return null; ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected static Object getParamArg(Class cl) ++ { ++ if (! cl.isPrimitive()) ++ return null; ++ else if (boolean.class.equals(cl)) ++ return Boolean.FALSE; ++ else if (byte.class.equals(cl)) ++ return Byte.valueOf((byte) 0); ++ else if (short.class.equals(cl)) ++ return Short.valueOf((short) 0); ++ else if (char.class.equals(cl)) ++ return Character.valueOf((char) 0); ++ else if (int.class.equals(cl)) ++ return Integer.valueOf(0); ++ else if (long.class.equals(cl)) ++ return Long.valueOf(0); ++ else if (float.class.equals(cl)) ++ return Double.valueOf(0); ++ else if (double.class.equals(cl)) ++ return Double.valueOf(0); ++ else ++ throw new UnsupportedOperationException(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,316 +1,316 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.ArrayList; +-import java.util.Collections; +-import java.util.Comparator; +-import java.util.Locale; +-import java.util.logging.*; +- +-/** +- * Serializing an object for known object types. +- */ +-public class BeanSerializer extends AbstractSerializer { +- private static final Logger log +- = Logger.getLogger(BeanSerializer.class.getName()); +- +- private static final Object []NULL_ARGS = new Object[0]; +- private Method []_methods; +- private String []_names; +- +- private Object _writeReplaceFactory; +- private Method _writeReplace; +- +- public BeanSerializer(Class cl, ClassLoader loader) +- { +- introspectWriteReplace(cl, loader); +- +- ArrayList primitiveMethods = new ArrayList(); +- ArrayList compoundMethods = new ArrayList(); +- +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (Modifier.isStatic(method.getModifiers())) +- continue; +- +- if (method.getParameterTypes().length != 0) +- continue; +- +- String name = method.getName(); +- +- if (! name.startsWith("get")) +- continue; +- +- Class type = method.getReturnType(); +- +- if (type.equals(void.class)) +- continue; +- +- if (findSetter(methods, name, type) == null) +- continue; +- +- // XXX: could parameterize the handler to only deal with public +- method.setAccessible(true); +- +- if (type.isPrimitive() +- || type.getName().startsWith("java.lang.") +- && ! type.equals(Object.class)) +- primitiveMethods.add(method); +- else +- compoundMethods.add(method); +- } +- } +- +- ArrayList methodList = new ArrayList(); +- methodList.addAll(primitiveMethods); +- methodList.addAll(compoundMethods); +- +- Collections.sort(methodList, new MethodNameCmp()); +- +- _methods = new Method[methodList.size()]; +- methodList.toArray(_methods); +- +- _names = new String[_methods.length]; +- +- for (int i = 0; i < _methods.length; i++) { +- String name = _methods[i].getName(); +- +- name = name.substring(3); +- +- int j = 0; +- for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { +- } +- +- if (j == 1) +- name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); +- else if (j > 1) +- name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); +- +- _names[i] = name; +- } +- } +- +- private void introspectWriteReplace(Class cl, ClassLoader loader) +- { +- try { +- String className = cl.getName() + "HessianSerializer"; +- +- Class serializerClass = Class.forName(className, false, loader); +- +- Object serializerObject = serializerClass.newInstance(); +- +- Method writeReplace = getWriteReplace(serializerClass, cl); +- +- if (writeReplace != null) { +- _writeReplaceFactory = serializerObject; +- _writeReplace = writeReplace; +- +- return; +- } +- } catch (ClassNotFoundException e) { +- } catch (Exception e) { +- log.log(Level.FINER, e.toString(), e); +- } +- +- _writeReplace = getWriteReplace(cl); +- } +- +- /** +- * Returns the writeReplace method +- */ +- protected Method getWriteReplace(Class cl) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (method.getName().equals("writeReplace") && +- method.getParameterTypes().length == 0) +- return method; +- } +- } +- +- return null; +- } +- +- /** +- * Returns the writeReplace method +- */ +- protected Method getWriteReplace(Class cl, Class param) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- for (Method method : cl.getDeclaredMethods()) { +- if (method.getName().equals("writeReplace") +- && method.getParameterTypes().length == 1 +- && param.equals(method.getParameterTypes()[0])) +- return method; +- } +- } +- +- return null; +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) +- return; +- +- Class cl = obj.getClass(); +- +- try { +- if (_writeReplace != null) { +- Object repl; +- +- if (_writeReplaceFactory != null) +- repl = _writeReplace.invoke(_writeReplaceFactory, obj); +- else +- repl = _writeReplace.invoke(obj); +- +- // out.removeRef(obj); +- +- out.writeObject(repl); +- +- out.replaceRef(repl, obj); +- +- return; +- } +- } catch (Exception e) { +- log.log(Level.FINER, e.toString(), e); +- } +- +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref < -1) { +- // Hessian 1.1 uses a map +- +- for (int i = 0; i < _methods.length; i++) { +- Method method = _methods[i]; +- Object value = null; +- +- try { +- value = _methods[i].invoke(obj, (Object []) null); +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeString(_names[i]); +- +- out.writeObject(value); +- } +- +- out.writeMapEnd(); +- } +- else { +- if (ref == -1) { +- out.writeInt(_names.length); +- +- for (int i = 0; i < _names.length; i++) +- out.writeString(_names[i]); +- +- out.writeObjectBegin(cl.getName()); +- } +- +- for (int i = 0; i < _methods.length; i++) { +- Method method = _methods[i]; +- Object value = null; +- +- try { +- value = _methods[i].invoke(obj, (Object []) null); +- } catch (Exception e) { +- log.log(Level.FINER, e.toString(), e); +- } +- +- out.writeObject(value); +- } +- } +- } +- +- /** +- * Finds any matching setter. +- */ +- private Method findSetter(Method []methods, String getterName, Class arg) +- { +- String setterName = "set" + getterName.substring(3); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (! method.getName().equals(setterName)) +- continue; +- +- if (! method.getReturnType().equals(void.class)) +- continue; +- +- Class []params = method.getParameterTypes(); +- +- if (params.length == 1 && params[0].equals(arg)) +- return method; +- } +- +- return null; +- } +- +- static class MethodNameCmp implements Comparator { +- public int compare(Method a, Method b) +- { +- return a.getName().compareTo(b.getName()); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.Collections; ++import java.util.Comparator; ++import java.util.Locale; ++import java.util.logging.*; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class BeanSerializer extends AbstractSerializer { ++ private static final Logger log ++ = Logger.getLogger(BeanSerializer.class.getName()); ++ ++ private static final Object []NULL_ARGS = new Object[0]; ++ private Method []_methods; ++ private String []_names; ++ ++ private Object _writeReplaceFactory; ++ private Method _writeReplace; ++ ++ public BeanSerializer(Class cl, ClassLoader loader) ++ { ++ introspectWriteReplace(cl, loader); ++ ++ ArrayList primitiveMethods = new ArrayList(); ++ ArrayList compoundMethods = new ArrayList(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (Modifier.isStatic(method.getModifiers())) ++ continue; ++ ++ if (method.getParameterTypes().length != 0) ++ continue; ++ ++ String name = method.getName(); ++ ++ if (! name.startsWith("get")) ++ continue; ++ ++ Class type = method.getReturnType(); ++ ++ if (type.equals(void.class)) ++ continue; ++ ++ if (findSetter(methods, name, type) == null) ++ continue; ++ ++ // XXX: could parameterize the handler to only deal with public ++ method.setAccessible(true); ++ ++ if (type.isPrimitive() ++ || type.getName().startsWith("java.lang.") ++ && ! type.equals(Object.class)) ++ primitiveMethods.add(method); ++ else ++ compoundMethods.add(method); ++ } ++ } ++ ++ ArrayList methodList = new ArrayList(); ++ methodList.addAll(primitiveMethods); ++ methodList.addAll(compoundMethods); ++ ++ Collections.sort(methodList, new MethodNameCmp()); ++ ++ _methods = new Method[methodList.size()]; ++ methodList.toArray(_methods); ++ ++ _names = new String[_methods.length]; ++ ++ for (int i = 0; i < _methods.length; i++) { ++ String name = _methods[i].getName(); ++ ++ name = name.substring(3); ++ ++ int j = 0; ++ for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { ++ } ++ ++ if (j == 1) ++ name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); ++ else if (j > 1) ++ name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); ++ ++ _names[i] = name; ++ } ++ } ++ ++ private void introspectWriteReplace(Class cl, ClassLoader loader) ++ { ++ try { ++ String className = cl.getName() + "HessianSerializer"; ++ ++ Class serializerClass = Class.forName(className, false, loader); ++ ++ Object serializerObject = serializerClass.newInstance(); ++ ++ Method writeReplace = getWriteReplace(serializerClass, cl); ++ ++ if (writeReplace != null) { ++ _writeReplaceFactory = serializerObject; ++ _writeReplace = writeReplace; ++ ++ return; ++ } ++ } catch (ClassNotFoundException e) { ++ } catch (Exception e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _writeReplace = getWriteReplace(cl); ++ } ++ ++ /** ++ * Returns the writeReplace method ++ */ ++ protected Method getWriteReplace(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("writeReplace") && ++ method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ /** ++ * Returns the writeReplace method ++ */ ++ protected Method getWriteReplace(Class cl, Class param) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ for (Method method : cl.getDeclaredMethods()) { ++ if (method.getName().equals("writeReplace") ++ && method.getParameterTypes().length == 1 ++ && param.equals(method.getParameterTypes()[0])) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ Class cl = obj.getClass(); ++ ++ try { ++ if (_writeReplace != null) { ++ Object repl; ++ ++ if (_writeReplaceFactory != null) ++ repl = _writeReplace.invoke(_writeReplaceFactory, obj); ++ else ++ repl = _writeReplace.invoke(obj); ++ ++ // out.removeRef(obj); ++ ++ out.writeObject(repl); ++ ++ out.replaceRef(repl, obj); ++ ++ return; ++ } ++ } catch (Exception e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref < -1) { ++ // Hessian 1.1 uses a map ++ ++ for (int i = 0; i < _methods.length; i++) { ++ Method method = _methods[i]; ++ Object value = null; ++ ++ try { ++ value = _methods[i].invoke(obj, (Object []) null); ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeString(_names[i]); ++ ++ out.writeObject(value); ++ } ++ ++ out.writeMapEnd(); ++ } ++ else { ++ if (ref == -1) { ++ out.writeInt(_names.length); ++ ++ for (int i = 0; i < _names.length; i++) ++ out.writeString(_names[i]); ++ ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ for (int i = 0; i < _methods.length; i++) { ++ Method method = _methods[i]; ++ Object value = null; ++ ++ try { ++ value = _methods[i].invoke(obj, (Object []) null); ++ } catch (Exception e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ out.writeObject(value); ++ } ++ } ++ } ++ ++ /** ++ * Finds any matching setter. ++ */ ++ private Method findSetter(Method []methods, String getterName, Class arg) ++ { ++ String setterName = "set" + getterName.substring(3); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (! method.getName().equals(setterName)) ++ continue; ++ ++ if (! method.getReturnType().equals(void.class)) ++ continue; ++ ++ Class []params = method.getParameterTypes(); ++ ++ if (params.length == 1 && params[0].equals(arg)) ++ return method; ++ } ++ ++ return null; ++ } ++ ++ static class MethodNameCmp implements Comparator { ++ public int compare(Method a, Method b) ++ { ++ return a.getName().compareTo(b.getName()); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializerFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,82 +1,82 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-/** +- * Factory for returning serialization methods. +- */ +-public class BeanSerializerFactory extends SerializerFactory { +- /** +- * Returns the default serializer for a class that isn't matched +- * directly. Application can override this method to produce +- * bean-style serialization instead of field serialization. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- protected Serializer getDefaultSerializer(Class cl) +- { +- return new BeanSerializer(cl, getClassLoader()); +- } +- +- /** +- * Returns the default deserializer for a class that isn't matched +- * directly. Application can override this method to produce +- * bean-style serialization instead of field serialization. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- protected Deserializer getDefaultDeserializer(Class cl) +- { +- return new BeanDeserializer(cl); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++/** ++ * Factory for returning serialization methods. ++ */ ++public class BeanSerializerFactory extends SerializerFactory { ++ /** ++ * Returns the default serializer for a class that isn't matched ++ * directly. Application can override this method to produce ++ * bean-style serialization instead of field serialization. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ protected Serializer getDefaultSerializer(Class cl) ++ { ++ return new BeanSerializer(cl, getClassLoader()); ++ } ++ ++ /** ++ * Returns the default deserializer for a class that isn't matched ++ * directly. Application can override this method to produce ++ * bean-style serialization instead of field serialization. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ protected Deserializer getDefaultDeserializer(Class cl) ++ { ++ return new BeanDeserializer(cl); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BigDecimalDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BigDecimalDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/BigDecimalDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/BigDecimalDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,68 +1,68 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.math.BigDecimal; +- +-/** +- * Deserializing a BigDecimal +- */ +-public class BigDecimalDeserializer extends AbstractStringValueDeserializer { +- @Override +- public Class getType() +- { +- return BigDecimal.class; +- } +- +- @Override +- protected Object create(String value) +- { +- return new BigDecimal(value); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.math.BigDecimal; ++ ++/** ++ * Deserializing a BigDecimal ++ */ ++public class BigDecimalDeserializer extends AbstractStringValueDeserializer { ++ @Override ++ public Class getType() ++ { ++ return BigDecimal.class; ++ } ++ ++ @Override ++ protected Object create(String value) ++ { ++ return new BigDecimal(value); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ByteArraySerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ByteArraySerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ByteArraySerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ByteArraySerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,82 +1,82 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing an object for known object types. +- */ +-public class ByteArraySerializer extends AbstractSerializer +- implements ObjectSerializer +-{ +- public static final ByteArraySerializer SER = new ByteArraySerializer(); +- +- private ByteArraySerializer() +- { +- } +- +- @Override +- public Serializer getObjectSerializer() +- { +- return this; +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- byte []data = (byte []) obj; +- +- if (data != null) +- out.writeBytes(data, 0, data.length); +- else +- out.writeNull(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class ByteArraySerializer extends AbstractSerializer ++ implements ObjectSerializer ++{ ++ public static final ByteArraySerializer SER = new ByteArraySerializer(); ++ ++ private ByteArraySerializer() ++ { ++ } ++ ++ @Override ++ public Serializer getObjectSerializer() ++ { ++ return this; ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ byte []data = (byte []) obj; ++ ++ if (data != null) ++ out.writeBytes(data, 0, data.length); ++ else ++ out.writeNull(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ByteHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/ByteHandle.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ByteHandle.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ByteHandle.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,83 +1,83 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.net.URL; +-import java.io.Serializable; +- +-/** +- * Handle for Java Byte objects. +- */ +-public class ByteHandle implements Serializable { +- private byte _value; +- +- private ByteHandle() +- { +- } +- +- public ByteHandle(byte value) +- { +- _value = value; +- } +- +- public byte getValue() +- { +- return _value; +- } +- +- public Object readResolve() +- { +- return new Byte(_value); +- } +- +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _value + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.net.URL; ++import java.io.Serializable; ++ ++/** ++ * Handle for Java Byte objects. ++ */ ++public class ByteHandle implements Serializable { ++ private byte _value; ++ ++ private ByteHandle() ++ { ++ } ++ ++ public ByteHandle(byte value) ++ { ++ _value = value; ++ } ++ ++ public byte getValue() ++ { ++ return _value; ++ } ++ ++ public Object readResolve() ++ { ++ return new Byte(_value); ++ } ++ ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _value + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CalendarHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/CalendarHandle.java +--- hessian-4.0.65-src/com/caucho/hessian/io/CalendarHandle.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/CalendarHandle.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,93 +1,93 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.Calendar; +-import java.util.Date; +-import java.util.GregorianCalendar; +- +-/** +- * Handle for a calendar object. +- */ +-public class CalendarHandle implements java.io.Serializable, HessianHandle { +- private Class type; +- private Date date; +- +- public CalendarHandle() +- { +- } +- +- public CalendarHandle(Class type, long time) +- { +- if (! GregorianCalendar.class.equals(type)) +- this.type = type; +- +- this.date = new Date(time); +- } +- +- private Object readResolve() +- { +- try { +- Calendar cal; +- +- if (this.type != null) +- cal = (Calendar) this.type.newInstance(); +- else +- cal = new GregorianCalendar(); +- +- cal.setTimeInMillis(this.date.getTime()); +- +- return cal; +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.Calendar; ++import java.util.Date; ++import java.util.GregorianCalendar; ++ ++/** ++ * Handle for a calendar object. ++ */ ++public class CalendarHandle implements java.io.Serializable, HessianHandle { ++ private Class type; ++ private Date date; ++ ++ public CalendarHandle() ++ { ++ } ++ ++ public CalendarHandle(Class type, long time) ++ { ++ if (! GregorianCalendar.class.equals(type)) ++ this.type = type; ++ ++ this.date = new Date(time); ++ } ++ ++ private Object readResolve() ++ { ++ try { ++ Calendar cal; ++ ++ if (this.type != null) ++ cal = (Calendar) this.type.newInstance(); ++ else ++ cal = new GregorianCalendar(); ++ ++ cal.setTimeInMillis(this.date.getTime()); ++ ++ return cal; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CalendarSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/CalendarSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/CalendarSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/CalendarSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,70 +1,70 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.Calendar; +- +-/** +- * Serializing a calendar. +- */ +-public class CalendarSerializer extends AbstractSerializer { +- public static final Serializer SER = new CalendarSerializer(); +- +- /** +- * java.util.Calendar serializes to com.caucho.hessian.io.CalendarHandle +- */ +- @Override +- public Object writeReplace(Object obj) +- { +- Calendar cal = (Calendar) obj; +- +- return new CalendarHandle(cal.getClass(), cal.getTimeInMillis()); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.Calendar; ++ ++/** ++ * Serializing a calendar. ++ */ ++public class CalendarSerializer extends AbstractSerializer { ++ public static final Serializer SER = new CalendarSerializer(); ++ ++ /** ++ * java.util.Calendar serializes to com.caucho.hessian.io.CalendarHandle ++ */ ++ @Override ++ public Object writeReplace(Object obj) ++ { ++ Calendar cal = (Calendar) obj; ++ ++ return new CalendarHandle(cal.getClass(), cal.getTimeInMillis()); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ClassDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ClassDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ClassDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ClassDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,162 +1,162 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.HashMap; +- +-/** +- * Deserializing a JDK 1.2 Class. +- */ +-public class ClassDeserializer extends AbstractMapDeserializer { +- private static final HashMap _primClasses +- = new HashMap(); +- +- private ClassLoader _loader; +- +- public ClassDeserializer(ClassLoader loader) +- { +- _loader = loader; +- } +- +- public Class getType() +- { +- return Class.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- int ref = in.addRef(null); +- +- String name = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if (key.equals("name")) +- name = in.readString(); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- Object value = create(name); +- +- in.setRef(ref, value); +- +- return value; +- } +- +- public Object readObject(AbstractHessianInput in, Object []fields) +- throws IOException +- { +- String []fieldNames = (String []) fields; +- +- int ref = in.addRef(null); +- +- String name = null; +- +- for (int i = 0; i < fieldNames.length; i++) { +- if ("name".equals(fieldNames[i])) +- name = in.readString(); +- else +- in.readObject(); +- } +- +- Object value = create(name); +- +- in.setRef(ref, value); +- +- return value; +- } +- +- Object create(String name) +- throws IOException +- { +- if (name == null) +- throw new IOException("Serialized Class expects name."); +- +- Class cl = _primClasses.get(name); +- +- if (cl != null) +- return cl; +- +- try { +- if (_loader != null) +- return Class.forName(name, false, _loader); +- else +- return Class.forName(name); +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- static { +- _primClasses.put("void", void.class); +- _primClasses.put("boolean", boolean.class); +- _primClasses.put("java.lang.Boolean", Boolean.class); +- _primClasses.put("byte", byte.class); +- _primClasses.put("java.lang.Byte", Byte.class); +- _primClasses.put("char", char.class); +- _primClasses.put("java.lang.Character", Character.class); +- _primClasses.put("short", short.class); +- _primClasses.put("java.lang.Short", Short.class); +- _primClasses.put("int", int.class); +- _primClasses.put("java.lang.Integer", Integer.class); +- _primClasses.put("long", long.class); +- _primClasses.put("java.lang.Long", Long.class); +- _primClasses.put("float", float.class); +- _primClasses.put("java.lang.Float", Float.class); +- _primClasses.put("double", double.class); +- _primClasses.put("java.lang.Double", Double.class); +- _primClasses.put("java.lang.String", String.class); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.HashMap; ++ ++/** ++ * Deserializing a JDK 1.2 Class. ++ */ ++public class ClassDeserializer extends AbstractMapDeserializer { ++ private static final HashMap _primClasses ++ = new HashMap(); ++ ++ private ClassLoader _loader; ++ ++ public ClassDeserializer(ClassLoader loader) ++ { ++ _loader = loader; ++ } ++ ++ public Class getType() ++ { ++ return Class.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ int ref = in.addRef(null); ++ ++ String name = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("name")) ++ name = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object value = create(name); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ public Object readObject(AbstractHessianInput in, Object []fields) ++ throws IOException ++ { ++ String []fieldNames = (String []) fields; ++ ++ int ref = in.addRef(null); ++ ++ String name = null; ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ if ("name".equals(fieldNames[i])) ++ name = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ Object value = create(name); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ Object create(String name) ++ throws IOException ++ { ++ if (name == null) ++ throw new IOException("Serialized Class expects name."); ++ ++ Class cl = _primClasses.get(name); ++ ++ if (cl != null) ++ return cl; ++ ++ try { ++ if (_loader != null) ++ return Class.forName(name, false, _loader); ++ else ++ return Class.forName(name); ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ static { ++ _primClasses.put("void", void.class); ++ _primClasses.put("boolean", boolean.class); ++ _primClasses.put("java.lang.Boolean", Boolean.class); ++ _primClasses.put("byte", byte.class); ++ _primClasses.put("java.lang.Byte", Byte.class); ++ _primClasses.put("char", char.class); ++ _primClasses.put("java.lang.Character", Character.class); ++ _primClasses.put("short", short.class); ++ _primClasses.put("java.lang.Short", Short.class); ++ _primClasses.put("int", int.class); ++ _primClasses.put("java.lang.Integer", Integer.class); ++ _primClasses.put("long", long.class); ++ _primClasses.put("java.lang.Long", Long.class); ++ _primClasses.put("float", float.class); ++ _primClasses.put("java.lang.Float", Float.class); ++ _primClasses.put("double", double.class); ++ _primClasses.put("java.lang.Double", Double.class); ++ _primClasses.put("java.lang.String", String.class); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ClassFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/ClassFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ClassFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ClassFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,225 +1,225 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.ArrayList; +-import java.util.HashMap; +-import java.util.regex.Pattern; +- +-/** +- * Loads a class from the classloader. +- */ +-public class ClassFactory +-{ +- private static ArrayList _staticAllowList; +- +- private static ArrayList _staticDenyList; +- +- private ClassLoader _loader; +- +- private boolean _isWhitelist; +- +- private ArrayList _allowList; +- +- ClassFactory(ClassLoader loader) +- { +- _loader = loader; +- } +- +- public Class load(String className) +- throws ClassNotFoundException +- { +- if (isAllow(className)) { +- return Class.forName(className, false, _loader); +- } +- else { +- return HashMap.class; +- } +- } +- +- private boolean isAllow(String className) +- { +- ArrayList allowList = _allowList; +- +- if (allowList == null) { +- Boolean isAllow = isAllow(_staticDenyList, className); +- +- if (isAllow != null) { +- return isAllow; +- } +- else { +- return true; +- } +- +- } +- +- Boolean isAllow = isAllow(_allowList, className); +- if (isAllow != null) { +- return isAllow; +- } +- +- isAllow = isAllow(_staticAllowList, className); +- +- if (isAllow != null) { +- return isAllow; +- } +- +- return ! _isWhitelist; +- } +- +- private Boolean isAllow(ArrayList allowList, String className) +- { +- if (allowList == null) { +- return null; +- } +- +- int size = allowList.size(); +- for (int i = 0; i < size; i++) { +- Allow allow = allowList.get(i); +- +- Boolean isAllow = allow.allow(className); +- +- if (isAllow != null) { +- return isAllow; +- } +- } +- +- return null; +- } +- +- public void setWhitelist(boolean isWhitelist) +- { +- initAllow(); +- +- _isWhitelist = isWhitelist; +- } +- +- /** +- * Allow a class or package based on a pattern. +- * +- * Examples: "java.util.*", "com.foo.io.Bean" +- */ +- public void allow(String pattern) +- { +- initAllow(); +- +- synchronized (this) { +- _allowList.add(new Allow(toPattern(pattern), true)); +- } +- } +- +- /** +- * Deny a class or package based on a pattern. +- * +- * Examples: "java.util.*", "com.foo.io.Bean" +- */ +- public void deny(String pattern) +- { +- initAllow(); +- +- synchronized (this) { +- _allowList.add(new Allow(toPattern(pattern), false)); +- } +- } +- +- private String toPattern(String pattern) +- { +- pattern = pattern.replace(".", "\\."); +- pattern = pattern.replace("*", ".*"); +- +- return pattern; +- } +- +- private void initAllow() +- { +- synchronized (this) { +- if (_allowList == null) { +- _allowList = new ArrayList(); +- _isWhitelist = true; +- } +- } +- } +- +- static class Allow { +- private Boolean _isAllow; +- private Pattern _pattern; +- +- private Allow(String pattern, boolean isAllow) +- { +- _isAllow = isAllow; +- _pattern = Pattern.compile(pattern); +- } +- +- Boolean allow(String className) +- { +- if (_pattern.matcher(className).matches()) { +- return _isAllow; +- } +- else { +- return null; +- } +- } +- } +- +- static { +- ArrayList blacklist = new ArrayList(); +- +- blacklist.add(new Allow("java\\.lang\\.Runtime", false)); +- blacklist.add(new Allow("java\\.lang\\.Process", false)); +- blacklist.add(new Allow("java\\.lang\\.System", false)); +- blacklist.add(new Allow("java\\.lang\\.Thread", false)); +- +- _staticAllowList = new ArrayList(blacklist); +- +- _staticAllowList.add(new Allow("java\\..+", true)); +- _staticAllowList.add(new Allow("javax\\.management\\..+", true)); +- +- _staticDenyList = new ArrayList(blacklist); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.ArrayList; ++import java.util.HashMap; ++import java.util.regex.Pattern; ++ ++/** ++ * Loads a class from the classloader. ++ */ ++public class ClassFactory ++{ ++ private static ArrayList _staticAllowList; ++ ++ private static ArrayList _staticDenyList; ++ ++ private ClassLoader _loader; ++ ++ private boolean _isWhitelist; ++ ++ private ArrayList _allowList; ++ ++ ClassFactory(ClassLoader loader) ++ { ++ _loader = loader; ++ } ++ ++ public Class load(String className) ++ throws ClassNotFoundException ++ { ++ if (isAllow(className)) { ++ return Class.forName(className, false, _loader); ++ } ++ else { ++ return HashMap.class; ++ } ++ } ++ ++ private boolean isAllow(String className) ++ { ++ ArrayList allowList = _allowList; ++ ++ if (allowList == null) { ++ Boolean isAllow = isAllow(_staticDenyList, className); ++ ++ if (isAllow != null) { ++ return isAllow; ++ } ++ else { ++ return true; ++ } ++ ++ } ++ ++ Boolean isAllow = isAllow(_allowList, className); ++ if (isAllow != null) { ++ return isAllow; ++ } ++ ++ isAllow = isAllow(_staticAllowList, className); ++ ++ if (isAllow != null) { ++ return isAllow; ++ } ++ ++ return ! _isWhitelist; ++ } ++ ++ private Boolean isAllow(ArrayList allowList, String className) ++ { ++ if (allowList == null) { ++ return null; ++ } ++ ++ int size = allowList.size(); ++ for (int i = 0; i < size; i++) { ++ Allow allow = allowList.get(i); ++ ++ Boolean isAllow = allow.allow(className); ++ ++ if (isAllow != null) { ++ return isAllow; ++ } ++ } ++ ++ return null; ++ } ++ ++ public void setWhitelist(boolean isWhitelist) ++ { ++ initAllow(); ++ ++ _isWhitelist = isWhitelist; ++ } ++ ++ /** ++ * Allow a class or package based on a pattern. ++ * ++ * Examples: "java.util.*", "com.foo.io.Bean" ++ */ ++ public void allow(String pattern) ++ { ++ initAllow(); ++ ++ synchronized (this) { ++ _allowList.add(new Allow(toPattern(pattern), true)); ++ } ++ } ++ ++ /** ++ * Deny a class or package based on a pattern. ++ * ++ * Examples: "java.util.*", "com.foo.io.Bean" ++ */ ++ public void deny(String pattern) ++ { ++ initAllow(); ++ ++ synchronized (this) { ++ _allowList.add(new Allow(toPattern(pattern), false)); ++ } ++ } ++ ++ private String toPattern(String pattern) ++ { ++ pattern = pattern.replace(".", "\\."); ++ pattern = pattern.replace("*", ".*"); ++ ++ return pattern; ++ } ++ ++ private void initAllow() ++ { ++ synchronized (this) { ++ if (_allowList == null) { ++ _allowList = new ArrayList(); ++ _isWhitelist = true; ++ } ++ } ++ } ++ ++ static class Allow { ++ private Boolean _isAllow; ++ private Pattern _pattern; ++ ++ private Allow(String pattern, boolean isAllow) ++ { ++ _isAllow = isAllow; ++ _pattern = Pattern.compile(pattern); ++ } ++ ++ Boolean allow(String className) ++ { ++ if (_pattern.matcher(className).matches()) { ++ return _isAllow; ++ } ++ else { ++ return null; ++ } ++ } ++ } ++ ++ static { ++ ArrayList blacklist = new ArrayList(); ++ ++ blacklist.add(new Allow("java\\.lang\\.Runtime", false)); ++ blacklist.add(new Allow("java\\.lang\\.Process", false)); ++ blacklist.add(new Allow("java\\.lang\\.System", false)); ++ blacklist.add(new Allow("java\\.lang\\.Thread", false)); ++ ++ _staticAllowList = new ArrayList(blacklist); ++ ++ _staticAllowList.add(new Allow("java\\..+", true)); ++ _staticAllowList.add(new Allow("javax\\.management\\..+", true)); ++ ++ _staticDenyList = new ArrayList(blacklist); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ClassSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ClassSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ClassSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ClassSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,87 +1,87 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing a remote object. +- */ +-public class ClassSerializer extends AbstractSerializer { +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- Class cl = (Class) obj; +- +- if (cl == null) { +- out.writeNull(); +- } +- else if (out.addRef(obj)) { +- return; +- } +- else { +- int ref = out.writeObjectBegin("java.lang.Class"); +- +- if (ref < -1) { +- out.writeString("name"); +- out.writeString(cl.getName()); +- out.writeMapEnd(); +- } +- else { +- if (ref == -1) { +- out.writeInt(1); +- out.writeString("name"); +- out.writeObjectBegin("java.lang.Class"); +- } +- +- out.writeString(cl.getName()); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing a remote object. ++ */ ++public class ClassSerializer extends AbstractSerializer { ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ Class cl = (Class) obj; ++ ++ if (cl == null) { ++ out.writeNull(); ++ } ++ else if (out.addRef(obj)) { ++ return; ++ } ++ else { ++ int ref = out.writeObjectBegin("java.lang.Class"); ++ ++ if (ref < -1) { ++ out.writeString("name"); ++ out.writeString(cl.getName()); ++ out.writeMapEnd(); ++ } ++ else { ++ if (ref == -1) { ++ out.writeInt(1); ++ out.writeString("name"); ++ out.writeObjectBegin("java.lang.Class"); ++ } ++ ++ out.writeString(cl.getName()); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CollectionDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/CollectionDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/CollectionDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/CollectionDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,139 +1,139 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.*; +- +-/** +- * Deserializing a JDK 1.2 Collection. +- */ +-public class CollectionDeserializer extends AbstractListDeserializer { +- private Class _type; +- +- public CollectionDeserializer(Class type) +- { +- _type = type; +- } +- +- public Class getType() +- { +- return _type; +- } +- +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- Collection list = createList(); +- +- in.addRef(list); +- +- while (! in.isEnd()) +- list.add(in.readObject()); +- +- in.readEnd(); +- +- return list; +- } +- +- public Object readLengthList(AbstractHessianInput in, int length) +- throws IOException +- { +- Collection list = createList(); +- +- in.addRef(list); +- +- for (; length > 0; length--) +- list.add(in.readObject()); +- +- return list; +- } +- +- private Collection createList() +- throws IOException +- { +- Collection list = null; +- +- if (_type == null) +- list = new ArrayList(); +- else if (! _type.isInterface()) { +- try { +- list = (Collection) _type.newInstance(); +- } catch (Exception e) { +- } +- } +- +- if (list != null) { +- } +- else if (SortedSet.class.isAssignableFrom(_type)) +- list = new TreeSet(); +- else if (Set.class.isAssignableFrom(_type)) +- list = new HashSet(); +- else if (List.class.isAssignableFrom(_type)) +- list = new ArrayList(); +- else if (Collection.class.isAssignableFrom(_type)) +- list = new ArrayList(); +- else { +- try { +- list = (Collection) _type.newInstance(); +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- return list; +- } +- +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _type + "]"; +- } +-} +- +- ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.*; ++ ++/** ++ * Deserializing a JDK 1.2 Collection. ++ */ ++public class CollectionDeserializer extends AbstractListDeserializer { ++ private Class _type; ++ ++ public CollectionDeserializer(Class type) ++ { ++ _type = type; ++ } ++ ++ public Class getType() ++ { ++ return _type; ++ } ++ ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ Collection list = createList(); ++ ++ in.addRef(list); ++ ++ while (! in.isEnd()) ++ list.add(in.readObject()); ++ ++ in.readEnd(); ++ ++ return list; ++ } ++ ++ public Object readLengthList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ Collection list = createList(); ++ ++ in.addRef(list); ++ ++ for (; length > 0; length--) ++ list.add(in.readObject()); ++ ++ return list; ++ } ++ ++ private Collection createList() ++ throws IOException ++ { ++ Collection list = null; ++ ++ if (_type == null) ++ list = new ArrayList(); ++ else if (! _type.isInterface()) { ++ try { ++ list = (Collection) _type.newInstance(); ++ } catch (Exception e) { ++ } ++ } ++ ++ if (list != null) { ++ } ++ else if (SortedSet.class.isAssignableFrom(_type)) ++ list = new TreeSet(); ++ else if (Set.class.isAssignableFrom(_type)) ++ list = new HashSet(); ++ else if (List.class.isAssignableFrom(_type)) ++ list = new ArrayList(); ++ else if (Collection.class.isAssignableFrom(_type)) ++ list = new ArrayList(); ++ else { ++ try { ++ list = (Collection) _type.newInstance(); ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ return list; ++ } ++ ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _type + "]"; ++ } ++} ++ ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CollectionSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/CollectionSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/CollectionSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/CollectionSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,123 +1,123 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.Serializable; +-import java.util.ArrayList; +-import java.util.Collection; +-import java.util.Iterator; +- +-/** +- * Serializing a JDK 1.2 Collection. +- */ +-public class CollectionSerializer extends AbstractSerializer +-{ +- private boolean _sendJavaType = true; +- +- /** +- * Set true if the java type of the collection should be sent. +- */ +- public void setSendJavaType(boolean sendJavaType) +- { +- _sendJavaType = sendJavaType; +- } +- +- /** +- * Return true if the java type of the collection should be sent. +- */ +- public boolean getSendJavaType() +- { +- return _sendJavaType; +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) +- return; +- +- Collection list = (Collection) obj; +- +- Class cl = obj.getClass(); +- boolean hasEnd; +- +- if (cl.equals(ArrayList.class) +- || ! Serializable.class.isAssignableFrom(cl)) { +- hasEnd = out.writeListBegin(list.size(), null); +- } +- else if (! _sendJavaType) { +- hasEnd = false; +- +- // hessian/3a19 +- for (; cl != null; cl = cl.getSuperclass()) { +- if (cl.getName().startsWith("java.")) { +- hasEnd = out.writeListBegin(list.size(), cl.getName()); +- break; +- } +- } +- +- if (cl == null) +- hasEnd = out.writeListBegin(list.size(), null); +- } +- else { +- hasEnd = out.writeListBegin(list.size(), obj.getClass().getName()); +- } +- +- Iterator iter = list.iterator(); +- while (iter.hasNext()) { +- Object value = iter.next(); +- +- out.writeObject(value); +- } +- +- if (hasEnd) +- out.writeListEnd(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.Serializable; ++import java.util.ArrayList; ++import java.util.Collection; ++import java.util.Iterator; ++ ++/** ++ * Serializing a JDK 1.2 Collection. ++ */ ++public class CollectionSerializer extends AbstractSerializer ++{ ++ private boolean _sendJavaType = true; ++ ++ /** ++ * Set true if the java type of the collection should be sent. ++ */ ++ public void setSendJavaType(boolean sendJavaType) ++ { ++ _sendJavaType = sendJavaType; ++ } ++ ++ /** ++ * Return true if the java type of the collection should be sent. ++ */ ++ public boolean getSendJavaType() ++ { ++ return _sendJavaType; ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ Collection list = (Collection) obj; ++ ++ Class cl = obj.getClass(); ++ boolean hasEnd; ++ ++ if (cl.equals(ArrayList.class) ++ || ! Serializable.class.isAssignableFrom(cl)) { ++ hasEnd = out.writeListBegin(list.size(), null); ++ } ++ else if (! _sendJavaType) { ++ hasEnd = false; ++ ++ // hessian/3a19 ++ for (; cl != null; cl = cl.getSuperclass()) { ++ if (cl.getName().startsWith("java.")) { ++ hasEnd = out.writeListBegin(list.size(), cl.getName()); ++ break; ++ } ++ } ++ ++ if (cl == null) ++ hasEnd = out.writeListBegin(list.size(), null); ++ } ++ else { ++ hasEnd = out.writeListBegin(list.size(), obj.getClass().getName()); ++ } ++ ++ Iterator iter = list.iterator(); ++ while (iter.hasNext()) { ++ Object value = iter.next(); ++ ++ out.writeObject(value); ++ } ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ContextSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/ContextSerializerFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ContextSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ContextSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,507 +1,519 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.InputStream; +-import java.lang.ref.SoftReference; +-import java.lang.ref.WeakReference; +-import java.net.InetAddress; +-import java.net.URL; +-import java.util.Enumeration; +-import java.util.HashMap; +-import java.util.HashSet; +-import java.util.Map; +-import java.util.Properties; +-import java.util.WeakHashMap; +-import java.util.concurrent.ConcurrentHashMap; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * The classloader-specific Factory for returning serialization +- */ +-public class ContextSerializerFactory +-{ +- private static final Logger log +- = Logger.getLogger(ContextSerializerFactory.class.getName()); +- +- private static Deserializer OBJECT_DESERIALIZER +- = new BasicDeserializer(BasicDeserializer.OBJECT); +- +- private static final WeakHashMap> +- _contextRefMap +- = new WeakHashMap>(); +- +- private static final ClassLoader _systemClassLoader; +- +- private static HashMap _staticSerializerMap; +- private static HashMap _staticDeserializerMap; +- private static HashMap _staticClassNameMap; +- +- private ContextSerializerFactory _parent; +- private WeakReference _loaderRef; +- +- private final HashSet _serializerFiles = new HashSet(); +- private final HashSet _deserializerFiles = new HashSet(); +- +- private final HashMap _serializerClassMap +- = new HashMap(); +- +- private final ConcurrentHashMap _customSerializerMap +- = new ConcurrentHashMap(); +- +- private final HashMap,Serializer> _serializerInterfaceMap +- = new HashMap,Serializer>(); +- +- private final HashMap _deserializerClassMap +- = new HashMap(); +- +- private final HashMap _deserializerClassNameMap +- = new HashMap(); +- +- private final ConcurrentHashMap _customDeserializerMap +- = new ConcurrentHashMap(); +- +- private final HashMap,Deserializer> _deserializerInterfaceMap +- = new HashMap,Deserializer>(); +- +- public ContextSerializerFactory(ContextSerializerFactory parent, +- ClassLoader loader) +- { +- if (loader == null) +- loader = _systemClassLoader; +- +- _loaderRef = new WeakReference(loader); +- +- init(); +- } +- +- public static ContextSerializerFactory create() +- { +- return create(Thread.currentThread().getContextClassLoader()); +- } +- +- public static ContextSerializerFactory create(ClassLoader loader) +- { +- synchronized (_contextRefMap) { +- SoftReference factoryRef +- = _contextRefMap.get(loader); +- +- ContextSerializerFactory factory = null; +- +- if (factoryRef != null) +- factory = factoryRef.get(); +- +- if (factory == null) { +- ContextSerializerFactory parent = null; +- +- if (loader != null) +- parent = create(loader.getParent()); +- +- factory = new ContextSerializerFactory(parent, loader); +- factoryRef = new SoftReference(factory); +- +- _contextRefMap.put(loader, factoryRef); +- } +- +- return factory; +- } +- } +- +- public ClassLoader getClassLoader() +- { +- WeakReference loaderRef = _loaderRef; +- +- if (loaderRef != null) +- return loaderRef.get(); +- else +- return null; +- } +- +- /** +- * Returns the serializer for a given class. +- */ +- public Serializer getSerializer(String className) +- { +- Serializer serializer = _serializerClassMap.get(className); +- +- if (serializer == AbstractSerializer.NULL) +- return null; +- else +- return serializer; +- } +- +- /** +- * Returns a custom serializer the class +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- public Serializer getCustomSerializer(Class cl) +- { +- Serializer serializer = _customSerializerMap.get(cl.getName()); +- +- if (serializer == AbstractSerializer.NULL) +- return null; +- else if (serializer != null) +- return serializer; +- +- try { +- Class serClass = Class.forName(cl.getName() + "HessianSerializer", +- false, cl.getClassLoader()); +- +- Serializer ser = (Serializer) serClass.newInstance(); +- +- _customSerializerMap.put(cl.getName(), ser); +- +- return ser; +- } catch (ClassNotFoundException e) { +- log.log(Level.ALL, e.toString(), e); +- } catch (Exception e) { +- throw new HessianException(e); +- } +- +- _customSerializerMap.put(cl.getName(), AbstractSerializer.NULL); +- +- return null; +- } +- +- /** +- * Returns the deserializer for a given class. +- */ +- public Deserializer getDeserializer(String className) +- { +- Deserializer deserializer = _deserializerClassMap.get(className); +- +- if (deserializer != null && deserializer != AbstractDeserializer.NULL) { +- return deserializer; +- } +- +- deserializer = _deserializerInterfaceMap.get(className); +- +- if (deserializer != null && deserializer != AbstractDeserializer.NULL) { +- return deserializer; +- } +- +- return null; +- } +- +- /** +- * Returns a custom deserializer the class +- * +- * @param cl the class of the object that needs to be deserialized. +- * +- * @return a deserializer object for the deserialization. +- */ +- public Deserializer getCustomDeserializer(Class cl) +- { +- Deserializer deserializer = _customDeserializerMap.get(cl.getName()); +- +- if (deserializer == AbstractDeserializer.NULL) +- return null; +- else if (deserializer != null) +- return deserializer; +- +- try { +- Class serClass = Class.forName(cl.getName() + "HessianDeserializer", +- false, cl.getClassLoader()); +- +- Deserializer ser = (Deserializer) serClass.newInstance(); +- +- _customDeserializerMap.put(cl.getName(), ser); +- +- return ser; +- } catch (ClassNotFoundException e) { +- log.log(Level.ALL, e.toString(), e); +- } catch (Exception e) { +- throw new HessianException(e); +- } +- +- _customDeserializerMap.put(cl.getName(), AbstractDeserializer.NULL); +- +- return null; +- } +- +- /** +- * Initialize the factory +- */ +- private void init() +- { +- if (_parent != null) { +- _serializerFiles.addAll(_parent._serializerFiles); +- _deserializerFiles.addAll(_parent._deserializerFiles); +- +- _serializerClassMap.putAll(_parent._serializerClassMap); +- _deserializerClassMap.putAll(_parent._deserializerClassMap); +- } +- +- if (_parent == null) { +- _serializerClassMap.putAll(_staticSerializerMap); +- _deserializerClassMap.putAll(_staticDeserializerMap); +- _deserializerClassNameMap.putAll(_staticClassNameMap); +- } +- +- HashMap classMap; +- +- classMap = new HashMap(); +- initSerializerFiles("META-INF/hessian/serializers", +- _serializerFiles, +- classMap, +- Serializer.class); +- +- for (Map.Entry entry : classMap.entrySet()) { +- try { +- Serializer ser = (Serializer) entry.getValue().newInstance(); +- +- if (entry.getKey().isInterface()) +- _serializerInterfaceMap.put(entry.getKey(), ser); +- else +- _serializerClassMap.put(entry.getKey().getName(), ser); +- } catch (Exception e) { +- throw new HessianException(e); +- } +- } +- +- classMap = new HashMap(); +- initSerializerFiles("META-INF/hessian/deserializers", +- _deserializerFiles, +- classMap, +- Deserializer.class); +- +- for (Map.Entry entry : classMap.entrySet()) { +- try { +- Deserializer ser = (Deserializer) entry.getValue().newInstance(); +- +- if (entry.getKey().isInterface()) +- _deserializerInterfaceMap.put(entry.getKey(), ser); +- else { +- _deserializerClassMap.put(entry.getKey().getName(), ser); +- } +- } catch (Exception e) { +- throw new HessianException(e); +- } +- } +- } +- +- private void initSerializerFiles(String fileName, +- HashSet fileList, +- HashMap classMap, +- Class type) +- { +- try { +- ClassLoader classLoader = getClassLoader(); +- +- // on systems with the security manager enabled, the system classloader +- // is null +- if (classLoader == null) +- return; +- +- Enumeration iter; +- +- iter = classLoader.getResources(fileName); +- while (iter.hasMoreElements()) { +- URL url = (URL) iter.nextElement(); +- +- if (fileList.contains(url.toString())) +- continue; +- +- fileList.add(url.toString()); +- +- InputStream is = null; +- try { +- is = url.openStream(); +- +- Properties props = new Properties(); +- props.load(is); +- +- for (Map.Entry entry : props.entrySet()) { +- String apiName = (String) entry.getKey(); +- String serializerName = (String) entry.getValue(); +- +- Class apiClass = null; +- Class serializerClass = null; +- +- try { +- apiClass = Class.forName(apiName, false, classLoader); +- } catch (ClassNotFoundException e) { +- log.fine(url + ": " + apiName + " is not available in this context: " + getClassLoader()); +- continue; +- } +- +- try { +- serializerClass = Class.forName(serializerName, false, classLoader); +- } catch (ClassNotFoundException e) { +- log.fine(url + ": " + serializerName + " is not available in this context: " + getClassLoader()); +- continue; +- } +- +- if (! type.isAssignableFrom(serializerClass)) +- throw new HessianException(url + ": " + serializerClass.getName() + " is invalid because it does not implement " + type.getName()); +- +- classMap.put(apiClass, serializerClass); +- } +- } finally { +- if (is != null) +- is.close(); +- } +- } +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new HessianException(e); +- } +- } +- +- private static void addBasic(Class cl, String typeName, int type) +- { +- _staticSerializerMap.put(cl.getName(), new BasicSerializer(type)); +- +- Deserializer deserializer = new BasicDeserializer(type); +- _staticDeserializerMap.put(cl.getName(), deserializer); +- _staticClassNameMap.put(typeName, deserializer); +- } +- +- static { +- _staticSerializerMap = new HashMap(); +- _staticDeserializerMap = new HashMap(); +- _staticClassNameMap = new HashMap(); +- +- FieldDeserializer2Factory fieldFactory = FieldDeserializer2Factory.create(); +- +- addBasic(void.class, "void", BasicSerializer.NULL); +- +- addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); +- addBasic(Byte.class, "byte", BasicSerializer.BYTE); +- addBasic(Short.class, "short", BasicSerializer.SHORT); +- addBasic(Integer.class, "int", BasicSerializer.INTEGER); +- addBasic(Long.class, "long", BasicSerializer.LONG); +- addBasic(Float.class, "float", BasicSerializer.FLOAT); +- addBasic(Double.class, "double", BasicSerializer.DOUBLE); +- addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); +- addBasic(String.class, "string", BasicSerializer.STRING); +- addBasic(Object.class, "object", BasicSerializer.OBJECT); +- addBasic(java.util.Date.class, "date", BasicSerializer.DATE); +- +- addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); +- addBasic(byte.class, "byte", BasicSerializer.BYTE); +- addBasic(short.class, "short", BasicSerializer.SHORT); +- addBasic(int.class, "int", BasicSerializer.INTEGER); +- addBasic(long.class, "long", BasicSerializer.LONG); +- addBasic(float.class, "float", BasicSerializer.FLOAT); +- addBasic(double.class, "double", BasicSerializer.DOUBLE); +- addBasic(char.class, "char", BasicSerializer.CHARACTER); +- +- addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); +- addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); +- _staticSerializerMap.put(byte[].class.getName(), ByteArraySerializer.SER); +- addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); +- addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); +- addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); +- addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); +- addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); +- addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); +- addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); +- addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); +- +- Deserializer objectDeserializer = new JavaDeserializer(Object.class, fieldFactory); +- _staticDeserializerMap.put("object", objectDeserializer); +- _staticClassNameMap.put("object", objectDeserializer); +- +- _staticSerializerMap.put(Class.class.getName(), new ClassSerializer()); +- +- _staticDeserializerMap.put(Number.class.getName(), new BasicDeserializer(BasicSerializer.NUMBER)); +- +- /* +- for (Class cl : new Class[] { BigDecimal.class, File.class, ObjectName.class }) { +- _staticSerializerMap.put(cl, StringValueSerializer.SER); +- _staticDeserializerMap.put(cl, new StringValueDeserializer(cl)); +- } +- +- _staticSerializerMap.put(ObjectName.class, StringValueSerializer.SER); +- try { +- _staticDeserializerMap.put(ObjectName.class, +- new StringValueDeserializer(ObjectName.class)); +- } catch (Throwable e) { +- } +- */ +- +- _staticSerializerMap.put(InetAddress.class.getName(), +- InetAddressSerializer.create()); +- +- _staticSerializerMap.put(java.sql.Date.class.getName(), +- new SqlDateSerializer()); +- _staticSerializerMap.put(java.sql.Time.class.getName(), +- new SqlDateSerializer()); +- _staticSerializerMap.put(java.sql.Timestamp.class.getName(), +- new SqlDateSerializer()); +- +- _staticDeserializerMap.put(java.sql.Date.class.getName(), +- new SqlDateDeserializer(java.sql.Date.class)); +- _staticDeserializerMap.put(java.sql.Time.class.getName(), +- new SqlDateDeserializer(java.sql.Time.class)); +- _staticDeserializerMap.put(java.sql.Timestamp.class.getName(), +- new SqlDateDeserializer(java.sql.Timestamp.class)); +- +- // hessian/3bb5 +- _staticDeserializerMap.put(StackTraceElement.class.getName(), +- new StackTraceElementDeserializer(fieldFactory)); +- +- ClassLoader systemClassLoader = null; +- try { +- systemClassLoader = ClassLoader.getSystemClassLoader(); +- } catch (Exception e) { +- } +- +- _systemClassLoader = systemClassLoader; +- } +-} +- ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.InputStream; ++import java.lang.ref.SoftReference; ++import java.lang.ref.WeakReference; ++import java.net.InetAddress; ++import java.net.URL; ++import java.util.Enumeration; ++import java.util.HashMap; ++import java.util.HashSet; ++import java.util.Map; ++import java.util.Properties; ++import java.util.WeakHashMap; ++import java.util.concurrent.ConcurrentHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * The classloader-specific Factory for returning serialization ++ */ ++public class ContextSerializerFactory ++{ ++ private static final Logger log ++ = Logger.getLogger(ContextSerializerFactory.class.getName()); ++ ++ private static Deserializer OBJECT_DESERIALIZER ++ = new BasicDeserializer(BasicDeserializer.OBJECT); ++ ++ private static final WeakHashMap> ++ _contextRefMap ++ = new WeakHashMap>(); ++ ++ private static final ClassLoader _systemClassLoader; ++ ++ private static HashMap _staticSerializerMap; ++ private static HashMap _staticDeserializerMap; ++ private static HashMap _staticClassNameMap; ++ ++ private ContextSerializerFactory _parent; ++ private WeakReference _loaderRef; ++ ++ private final HashSet _serializerFiles = new HashSet(); ++ private final HashSet _deserializerFiles = new HashSet(); ++ ++ private final HashMap _serializerClassMap ++ = new HashMap(); ++ ++ private final ConcurrentHashMap _customSerializerMap ++ = new ConcurrentHashMap(); ++ ++ private final HashMap,Serializer> _serializerInterfaceMap ++ = new HashMap,Serializer>(); ++ ++ private final HashMap _deserializerClassMap ++ = new HashMap(); ++ ++ private final HashMap _deserializerClassNameMap ++ = new HashMap(); ++ ++ private final ConcurrentHashMap _customDeserializerMap ++ = new ConcurrentHashMap(); ++ ++ private final HashMap,Deserializer> _deserializerInterfaceMap ++ = new HashMap,Deserializer>(); ++ ++ public ContextSerializerFactory(ContextSerializerFactory parent, ++ ClassLoader loader) ++ { ++ if (loader == null) ++ loader = _systemClassLoader; ++ ++ _loaderRef = new WeakReference(loader); ++ ++ init(); ++ } ++ ++ public static ContextSerializerFactory create() ++ { ++ return create(Thread.currentThread().getContextClassLoader()); ++ } ++ ++ public static ContextSerializerFactory create(ClassLoader loader) ++ { ++ synchronized (_contextRefMap) { ++ SoftReference factoryRef ++ = _contextRefMap.get(loader); ++ ++ ContextSerializerFactory factory = null; ++ ++ if (factoryRef != null) ++ factory = factoryRef.get(); ++ ++ if (factory == null) { ++ ContextSerializerFactory parent = null; ++ ++ if (loader != null) ++ parent = create(loader.getParent()); ++ ++ factory = new ContextSerializerFactory(parent, loader); ++ factoryRef = new SoftReference(factory); ++ ++ _contextRefMap.put(loader, factoryRef); ++ } ++ ++ return factory; ++ } ++ } ++ ++ public ClassLoader getClassLoader() ++ { ++ WeakReference loaderRef = _loaderRef; ++ ++ if (loaderRef != null) ++ return loaderRef.get(); ++ else ++ return null; ++ } ++ ++ /** ++ * Returns the serializer for a given class. ++ */ ++ public Serializer getSerializer(String className) ++ { ++ Serializer serializer = _serializerClassMap.get(className); ++ ++ if (serializer == AbstractSerializer.NULL) ++ return null; ++ else ++ return serializer; ++ } ++ ++ /** ++ * Returns a custom serializer the class ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ public Serializer getCustomSerializer(Class cl) ++ { ++ Serializer serializer = _customSerializerMap.get(cl.getName()); ++ ++ if (serializer == AbstractSerializer.NULL) ++ return null; ++ else if (serializer != null) ++ return serializer; ++ ++ try { ++ String className = cl.getName() + "HessianSerializer"; ++ ++ if (cl.getName().equals("java.util.Locale")) { ++ className = "com.caucho.hessian.io.LocaleHessianSerializer"; ++ } ++ ++ Class serClass = Class.forName(className, false, ++ Thread.currentThread().getContextClassLoader()); ++ ++ Serializer ser = (Serializer) serClass.newInstance(); ++ ++ _customSerializerMap.put(cl.getName(), ser); ++ ++ return ser; ++ } catch (ClassNotFoundException e) { ++ log.log(Level.ALL, e.toString(), e); ++ } catch (Exception e) { ++ throw new HessianException(e); ++ } ++ ++ _customSerializerMap.put(cl.getName(), AbstractSerializer.NULL); ++ ++ return null; ++ } ++ ++ /** ++ * Returns the deserializer for a given class. ++ */ ++ public Deserializer getDeserializer(String className) ++ { ++ Deserializer deserializer = _deserializerClassMap.get(className); ++ ++ if (deserializer != null && deserializer != AbstractDeserializer.NULL) { ++ return deserializer; ++ } ++ ++ deserializer = _deserializerInterfaceMap.get(className); ++ ++ if (deserializer != null && deserializer != AbstractDeserializer.NULL) { ++ return deserializer; ++ } ++ ++ return null; ++ } ++ ++ /** ++ * Returns a custom deserializer the class ++ * ++ * @param cl the class of the object that needs to be deserialized. ++ * ++ * @return a deserializer object for the deserialization. ++ */ ++ public Deserializer getCustomDeserializer(Class cl) ++ { ++ Deserializer deserializer = _customDeserializerMap.get(cl.getName()); ++ ++ if (deserializer == AbstractDeserializer.NULL) ++ return null; ++ else if (deserializer != null) ++ return deserializer; ++ ++ try { ++ String className = cl.getName() + "HessianDeserializer"; ++ ++ if (cl.getName().equals("java.util.Locale")) { ++ className = "com.caucho.hessian.io.LocaleHessianDeserializer"; ++ } ++ ++ Class serClass = Class.forName(className, false, ++ Thread.currentThread().getContextClassLoader()); ++ ++ Deserializer ser = (Deserializer) serClass.newInstance(); ++ ++ _customDeserializerMap.put(cl.getName(), ser); ++ ++ return ser; ++ } catch (ClassNotFoundException e) { ++ log.log(Level.ALL, e.toString(), e); ++ } catch (Exception e) { ++ throw new HessianException(e); ++ } ++ ++ _customDeserializerMap.put(cl.getName(), AbstractDeserializer.NULL); ++ ++ return null; ++ } ++ ++ /** ++ * Initialize the factory ++ */ ++ private void init() ++ { ++ if (_parent != null) { ++ _serializerFiles.addAll(_parent._serializerFiles); ++ _deserializerFiles.addAll(_parent._deserializerFiles); ++ ++ _serializerClassMap.putAll(_parent._serializerClassMap); ++ _deserializerClassMap.putAll(_parent._deserializerClassMap); ++ } ++ ++ if (_parent == null) { ++ _serializerClassMap.putAll(_staticSerializerMap); ++ _deserializerClassMap.putAll(_staticDeserializerMap); ++ _deserializerClassNameMap.putAll(_staticClassNameMap); ++ } ++ ++ HashMap classMap; ++ ++ classMap = new HashMap(); ++ initSerializerFiles("META-INF/hessian/serializers", ++ _serializerFiles, ++ classMap, ++ Serializer.class); ++ ++ for (Map.Entry entry : classMap.entrySet()) { ++ try { ++ Serializer ser = (Serializer) entry.getValue().newInstance(); ++ ++ if (entry.getKey().isInterface()) ++ _serializerInterfaceMap.put(entry.getKey(), ser); ++ else ++ _serializerClassMap.put(entry.getKey().getName(), ser); ++ } catch (Exception e) { ++ throw new HessianException(e); ++ } ++ } ++ ++ classMap = new HashMap(); ++ initSerializerFiles("META-INF/hessian/deserializers", ++ _deserializerFiles, ++ classMap, ++ Deserializer.class); ++ ++ for (Map.Entry entry : classMap.entrySet()) { ++ try { ++ Deserializer ser = (Deserializer) entry.getValue().newInstance(); ++ ++ if (entry.getKey().isInterface()) ++ _deserializerInterfaceMap.put(entry.getKey(), ser); ++ else { ++ _deserializerClassMap.put(entry.getKey().getName(), ser); ++ } ++ } catch (Exception e) { ++ throw new HessianException(e); ++ } ++ } ++ } ++ ++ private void initSerializerFiles(String fileName, ++ HashSet fileList, ++ HashMap classMap, ++ Class type) ++ { ++ try { ++ ClassLoader classLoader = getClassLoader(); ++ ++ // on systems with the security manager enabled, the system classloader ++ // is null ++ if (classLoader == null) ++ return; ++ ++ Enumeration iter; ++ ++ iter = classLoader.getResources(fileName); ++ while (iter.hasMoreElements()) { ++ URL url = (URL) iter.nextElement(); ++ ++ if (fileList.contains(url.toString())) ++ continue; ++ ++ fileList.add(url.toString()); ++ ++ InputStream is = null; ++ try { ++ is = url.openStream(); ++ ++ Properties props = new Properties(); ++ props.load(is); ++ ++ for (Map.Entry entry : props.entrySet()) { ++ String apiName = (String) entry.getKey(); ++ String serializerName = (String) entry.getValue(); ++ ++ Class apiClass = null; ++ Class serializerClass = null; ++ ++ try { ++ apiClass = Class.forName(apiName, false, classLoader); ++ } catch (ClassNotFoundException e) { ++ log.fine(url + ": " + apiName + " is not available in this context: " + getClassLoader()); ++ continue; ++ } ++ ++ try { ++ serializerClass = Class.forName(serializerName, false, classLoader); ++ } catch (ClassNotFoundException e) { ++ log.fine(url + ": " + serializerName + " is not available in this context: " + getClassLoader()); ++ continue; ++ } ++ ++ if (! type.isAssignableFrom(serializerClass)) ++ throw new HessianException(url + ": " + serializerClass.getName() + " is invalid because it does not implement " + type.getName()); ++ ++ classMap.put(apiClass, serializerClass); ++ } ++ } finally { ++ if (is != null) ++ is.close(); ++ } ++ } ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new HessianException(e); ++ } ++ } ++ ++ private static void addBasic(Class cl, String typeName, int type) ++ { ++ _staticSerializerMap.put(cl.getName(), new BasicSerializer(type)); ++ ++ Deserializer deserializer = new BasicDeserializer(type); ++ _staticDeserializerMap.put(cl.getName(), deserializer); ++ _staticClassNameMap.put(typeName, deserializer); ++ } ++ ++ static { ++ _staticSerializerMap = new HashMap(); ++ _staticDeserializerMap = new HashMap(); ++ _staticClassNameMap = new HashMap(); ++ ++ FieldDeserializer2Factory fieldFactory = FieldDeserializer2Factory.create(); ++ ++ addBasic(void.class, "void", BasicSerializer.NULL); ++ ++ addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); ++ addBasic(Byte.class, "byte", BasicSerializer.BYTE); ++ addBasic(Short.class, "short", BasicSerializer.SHORT); ++ addBasic(Integer.class, "int", BasicSerializer.INTEGER); ++ addBasic(Long.class, "long", BasicSerializer.LONG); ++ addBasic(Float.class, "float", BasicSerializer.FLOAT); ++ addBasic(Double.class, "double", BasicSerializer.DOUBLE); ++ addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); ++ addBasic(String.class, "string", BasicSerializer.STRING); ++ addBasic(Object.class, "object", BasicSerializer.OBJECT); ++ addBasic(java.util.Date.class, "date", BasicSerializer.DATE); ++ ++ addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); ++ addBasic(byte.class, "byte", BasicSerializer.BYTE); ++ addBasic(short.class, "short", BasicSerializer.SHORT); ++ addBasic(int.class, "int", BasicSerializer.INTEGER); ++ addBasic(long.class, "long", BasicSerializer.LONG); ++ addBasic(float.class, "float", BasicSerializer.FLOAT); ++ addBasic(double.class, "double", BasicSerializer.DOUBLE); ++ addBasic(char.class, "char", BasicSerializer.CHARACTER); ++ ++ addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); ++ addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); ++ _staticSerializerMap.put(byte[].class.getName(), ByteArraySerializer.SER); ++ addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); ++ addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); ++ addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); ++ addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); ++ addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); ++ addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); ++ addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); ++ addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); ++ ++ Deserializer objectDeserializer = new JavaDeserializer(Object.class, fieldFactory); ++ _staticDeserializerMap.put("object", objectDeserializer); ++ _staticClassNameMap.put("object", objectDeserializer); ++ ++ _staticSerializerMap.put(Class.class.getName(), new ClassSerializer()); ++ ++ _staticDeserializerMap.put(Number.class.getName(), new BasicDeserializer(BasicSerializer.NUMBER)); ++ ++ /* ++ for (Class cl : new Class[] { BigDecimal.class, File.class, ObjectName.class }) { ++ _staticSerializerMap.put(cl, StringValueSerializer.SER); ++ _staticDeserializerMap.put(cl, new StringValueDeserializer(cl)); ++ } ++ ++ _staticSerializerMap.put(ObjectName.class, StringValueSerializer.SER); ++ try { ++ _staticDeserializerMap.put(ObjectName.class, ++ new StringValueDeserializer(ObjectName.class)); ++ } catch (Throwable e) { ++ } ++ */ ++ ++ _staticSerializerMap.put(InetAddress.class.getName(), ++ InetAddressSerializer.create()); ++ ++ _staticSerializerMap.put(java.sql.Date.class.getName(), ++ new SqlDateSerializer()); ++ _staticSerializerMap.put(java.sql.Time.class.getName(), ++ new SqlDateSerializer()); ++ _staticSerializerMap.put(java.sql.Timestamp.class.getName(), ++ new SqlDateSerializer()); ++ ++ _staticDeserializerMap.put(java.sql.Date.class.getName(), ++ new SqlDateDeserializer(java.sql.Date.class)); ++ _staticDeserializerMap.put(java.sql.Time.class.getName(), ++ new SqlDateDeserializer(java.sql.Time.class)); ++ _staticDeserializerMap.put(java.sql.Timestamp.class.getName(), ++ new SqlDateDeserializer(java.sql.Timestamp.class)); ++ ++ // hessian/3bb5 ++ _staticDeserializerMap.put(StackTraceElement.class.getName(), ++ new StackTraceElementDeserializer(fieldFactory)); ++ ++ ClassLoader systemClassLoader = null; ++ try { ++ systemClassLoader = ClassLoader.getSystemClassLoader(); ++ } catch (Exception e) { ++ } ++ ++ _systemClassLoader = systemClassLoader; ++ } ++} ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Deflation.java hessian-4.0.65-fix/com/caucho/hessian/io/Deflation.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Deflation.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Deflation.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,205 +1,205 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.*; +-import java.util.zip.*; +- +-import java.io.*; +- +-import com.caucho.hessian.io.*; +- +-public class Deflation extends HessianEnvelope { +- public Deflation() +- { +- } +- +- public Hessian2Output wrap(Hessian2Output out) +- throws IOException +- { +- OutputStream os = new DeflateOutputStream(out); +- +- Hessian2Output filterOut = new Hessian2Output(os); +- +- filterOut.setCloseStreamOnClose(true); +- +- return filterOut; +- } +- +- public Hessian2Input unwrap(Hessian2Input in) +- throws IOException +- { +- int version = in.readEnvelope(); +- +- String method = in.readMethod(); +- +- if (! method.equals(getClass().getName())) +- throw new IOException("expected hessian Envelope method '" + +- getClass().getName() + "' at '" + method + "'"); +- +- return unwrapHeaders(in); +- } +- +- public Hessian2Input unwrapHeaders(Hessian2Input in) +- throws IOException +- { +- InputStream is = new DeflateInputStream(in); +- +- Hessian2Input filter = new Hessian2Input(is); +- +- filter.setCloseStreamOnClose(true); +- +- return filter; +- } +- +- static class DeflateOutputStream extends OutputStream { +- private Hessian2Output _out; +- private OutputStream _bodyOut; +- private DeflaterOutputStream _deflateOut; +- +- DeflateOutputStream(Hessian2Output out) +- throws IOException +- { +- _out = out; +- +- _out.startEnvelope(Deflation.class.getName()); +- +- _out.writeInt(0); +- +- _bodyOut = _out.getBytesOutputStream(); +- +- _deflateOut = new DeflaterOutputStream(_bodyOut); +- } +- +- public void write(int ch) +- throws IOException +- { +- _deflateOut.write(ch); +- } +- +- public void write(byte []buffer, int offset, int length) +- throws IOException +- { +- _deflateOut.write(buffer, offset, length); +- } +- +- public void close() +- throws IOException +- { +- Hessian2Output out = _out; +- _out = null; +- +- if (out != null) { +- _deflateOut.close(); +- _bodyOut.close(); +- +- out.writeInt(0); +- +- out.completeEnvelope(); +- +- out.close(); +- } +- } +- } +- +- static class DeflateInputStream extends InputStream { +- private Hessian2Input _in; +- +- private InputStream _bodyIn; +- private InflaterInputStream _inflateIn; +- +- DeflateInputStream(Hessian2Input in) +- throws IOException +- { +- _in = in; +- +- int len = in.readInt(); +- +- if (len != 0) +- throw new IOException("expected no headers"); +- +- _bodyIn = _in.readInputStream(); +- +- _inflateIn = new InflaterInputStream(_bodyIn); +- } +- +- public int read() +- throws IOException +- { +- return _inflateIn.read(); +- } +- +- public int read(byte []buffer, int offset, int length) +- throws IOException +- { +- return _inflateIn.read(buffer, offset, length); +- } +- +- public void close() +- throws IOException +- { +- Hessian2Input in = _in; +- _in = null; +- +- if (in != null) { +- _inflateIn.close(); +- _bodyIn.close(); +- +- int len = in.readInt(); +- +- if (len != 0) +- throw new IOException("Unexpected footer"); +- +- in.completeEnvelope(); +- +- in.close(); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.*; ++import java.util.zip.*; ++ ++import java.io.*; ++ ++import com.caucho.hessian.io.*; ++ ++public class Deflation extends HessianEnvelope { ++ public Deflation() ++ { ++ } ++ ++ public Hessian2Output wrap(Hessian2Output out) ++ throws IOException ++ { ++ OutputStream os = new DeflateOutputStream(out); ++ ++ Hessian2Output filterOut = new Hessian2Output(os); ++ ++ filterOut.setCloseStreamOnClose(true); ++ ++ return filterOut; ++ } ++ ++ public Hessian2Input unwrap(Hessian2Input in) ++ throws IOException ++ { ++ int version = in.readEnvelope(); ++ ++ String method = in.readMethod(); ++ ++ if (! method.equals(getClass().getName())) ++ throw new IOException("expected hessian Envelope method '" + ++ getClass().getName() + "' at '" + method + "'"); ++ ++ return unwrapHeaders(in); ++ } ++ ++ public Hessian2Input unwrapHeaders(Hessian2Input in) ++ throws IOException ++ { ++ InputStream is = new DeflateInputStream(in); ++ ++ Hessian2Input filter = new Hessian2Input(is); ++ ++ filter.setCloseStreamOnClose(true); ++ ++ return filter; ++ } ++ ++ static class DeflateOutputStream extends OutputStream { ++ private Hessian2Output _out; ++ private OutputStream _bodyOut; ++ private DeflaterOutputStream _deflateOut; ++ ++ DeflateOutputStream(Hessian2Output out) ++ throws IOException ++ { ++ _out = out; ++ ++ _out.startEnvelope(Deflation.class.getName()); ++ ++ _out.writeInt(0); ++ ++ _bodyOut = _out.getBytesOutputStream(); ++ ++ _deflateOut = new DeflaterOutputStream(_bodyOut); ++ } ++ ++ public void write(int ch) ++ throws IOException ++ { ++ _deflateOut.write(ch); ++ } ++ ++ public void write(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ _deflateOut.write(buffer, offset, length); ++ } ++ ++ public void close() ++ throws IOException ++ { ++ Hessian2Output out = _out; ++ _out = null; ++ ++ if (out != null) { ++ _deflateOut.close(); ++ _bodyOut.close(); ++ ++ out.writeInt(0); ++ ++ out.completeEnvelope(); ++ ++ out.close(); ++ } ++ } ++ } ++ ++ static class DeflateInputStream extends InputStream { ++ private Hessian2Input _in; ++ ++ private InputStream _bodyIn; ++ private InflaterInputStream _inflateIn; ++ ++ DeflateInputStream(Hessian2Input in) ++ throws IOException ++ { ++ _in = in; ++ ++ int len = in.readInt(); ++ ++ if (len != 0) ++ throw new IOException("expected no headers"); ++ ++ _bodyIn = _in.readInputStream(); ++ ++ _inflateIn = new InflaterInputStream(_bodyIn); ++ } ++ ++ public int read() ++ throws IOException ++ { ++ return _inflateIn.read(); ++ } ++ ++ public int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ return _inflateIn.read(buffer, offset, length); ++ } ++ ++ public void close() ++ throws IOException ++ { ++ Hessian2Input in = _in; ++ _in = null; ++ ++ if (in != null) { ++ _inflateIn.close(); ++ _bodyIn.close(); ++ ++ int len = in.readInt(); ++ ++ if (len != 0) ++ throw new IOException("Unexpected footer"); ++ ++ in.completeEnvelope(); ++ ++ in.close(); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Deserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/Deserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Deserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Deserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,108 +1,108 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Deserializing an object. Custom deserializers should extend +- * from AbstractDeserializer to avoid issues with signature +- * changes. +- */ +-public interface Deserializer { +- public Class getType(); +- +- public boolean isReadResolve(); +- +- public Object readObject(AbstractHessianInput in) +- throws IOException; +- +- public Object readList(AbstractHessianInput in, int length) +- throws IOException; +- +- public Object readLengthList(AbstractHessianInput in, int length) +- throws IOException; +- +- public Object readMap(AbstractHessianInput in) +- throws IOException; +- +- /** +- * Creates an empty array for the deserializers field +- * entries. +- * +- * @param len number of fields to be read +- * @return empty array of the proper field type. +- */ +- public Object []createFields(int len); +- +- /** +- * Returns the deserializer's field reader for the given name. +- * +- * @param name the field name +- * @return the deserializer's internal field reader +- */ +- public Object createField(String name); +- +- /** +- * Reads the object from the input stream, given the field +- * definition. +- * +- * @param in the input stream +- * @param fields the deserializer's own field marshal +- * @return the new object +- * @throws IOException +- */ +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException; +- +- public Object readObject(AbstractHessianInput in, +- String []fieldNames) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Deserializing an object. Custom deserializers should extend ++ * from AbstractDeserializer to avoid issues with signature ++ * changes. ++ */ ++public interface Deserializer { ++ public Class getType(); ++ ++ public boolean isReadResolve(); ++ ++ public Object readObject(AbstractHessianInput in) ++ throws IOException; ++ ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException; ++ ++ public Object readLengthList(AbstractHessianInput in, int length) ++ throws IOException; ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException; ++ ++ /** ++ * Creates an empty array for the deserializers field ++ * entries. ++ * ++ * @param len number of fields to be read ++ * @return empty array of the proper field type. ++ */ ++ public Object []createFields(int len); ++ ++ /** ++ * Returns the deserializer's field reader for the given name. ++ * ++ * @param name the field name ++ * @return the deserializer's internal field reader ++ */ ++ public Object createField(String name); ++ ++ /** ++ * Reads the object from the input stream, given the field ++ * definition. ++ * ++ * @param in the input stream ++ * @param fields the deserializer's own field marshal ++ * @return the new object ++ * @throws IOException ++ */ ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException; ++ ++ public Object readObject(AbstractHessianInput in, ++ String []fieldNames) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/EnumDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,140 +1,140 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Method; +- +-/** +- * Deserializing an enum valued object +- */ +-public class EnumDeserializer extends AbstractDeserializer { +- private Class _enumType; +- private Method _valueOf; +- +- public EnumDeserializer(Class cl) +- { +- // hessian/33b[34], hessian/3bb[78] +- if (cl.isEnum()) +- _enumType = cl; +- else if (cl.getSuperclass().isEnum()) +- _enumType = cl.getSuperclass(); +- else +- throw new RuntimeException("Class " + cl.getName() + " is not an enum"); +- +- try { +- _valueOf = _enumType.getMethod("valueOf", +- new Class[] { Class.class, String.class }); +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- public Class getType() +- { +- return _enumType; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String name = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if (key.equals("name")) +- name = in.readString(); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- Object obj = create(name); +- +- in.addRef(obj); +- +- return obj; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, Object []fields) +- throws IOException +- { +- String []fieldNames = (String []) fields; +- String name = null; +- +- for (int i = 0; i < fieldNames.length; i++) { +- if ("name".equals(fieldNames[i])) +- name = in.readString(); +- else +- in.readObject(); +- } +- +- Object obj = create(name); +- +- in.addRef(obj); +- +- return obj; +- } +- +- private Object create(String name) +- throws IOException +- { +- if (name == null) +- throw new IOException(_enumType.getName() + " expects name."); +- +- try { +- return _valueOf.invoke(null, _enumType, name); +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Method; ++ ++/** ++ * Deserializing an enum valued object ++ */ ++public class EnumDeserializer extends AbstractDeserializer { ++ private Class _enumType; ++ private Method _valueOf; ++ ++ public EnumDeserializer(Class cl) ++ { ++ // hessian/33b[34], hessian/3bb[78] ++ if (cl.isEnum()) ++ _enumType = cl; ++ else if (cl.getSuperclass().isEnum()) ++ _enumType = cl.getSuperclass(); ++ else ++ throw new RuntimeException("Class " + cl.getName() + " is not an enum"); ++ ++ try { ++ _valueOf = _enumType.getMethod("valueOf", ++ new Class[] { Class.class, String.class }); ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ public Class getType() ++ { ++ return _enumType; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String name = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("name")) ++ name = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object obj = create(name); ++ ++ in.addRef(obj); ++ ++ return obj; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, Object []fields) ++ throws IOException ++ { ++ String []fieldNames = (String []) fields; ++ String name = null; ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ if ("name".equals(fieldNames[i])) ++ name = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ Object obj = create(name); ++ ++ in.addRef(obj); ++ ++ return obj; ++ } ++ ++ private Object create(String name) ++ throws IOException ++ { ++ if (name == null) ++ throw new IOException(_enumType.getName() + " expects name."); ++ ++ try { ++ return _valueOf.invoke(null, _enumType, name); ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/EnumSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,108 +1,108 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Method; +- +-/** +- * Serializing an object for known object types. +- */ +-public class EnumSerializer extends AbstractSerializer { +- private Method _name; +- +- public EnumSerializer(Class cl) +- { +- // hessian/32b[12], hessian/3ab[23] +- if (! cl.isEnum() && cl.getSuperclass().isEnum()) +- cl = cl.getSuperclass(); +- +- try { +- _name = cl.getMethod("name", new Class[0]); +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) +- return; +- +- Class cl = obj.getClass(); +- +- if (! cl.isEnum() && cl.getSuperclass().isEnum()) +- cl = cl.getSuperclass(); +- +- String name = null; +- try { +- name = (String) _name.invoke(obj, (Object[]) null); +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref < -1) { +- out.writeString("name"); +- out.writeString(name); +- out.writeMapEnd(); +- } +- else { +- if (ref == -1) { +- out.writeClassFieldLength(1); +- out.writeString("name"); +- out.writeObjectBegin(cl.getName()); +- } +- +- out.writeString(name); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Method; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class EnumSerializer extends AbstractSerializer { ++ private Method _name; ++ ++ public EnumSerializer(Class cl) ++ { ++ // hessian/32b[12], hessian/3ab[23] ++ if (! cl.isEnum() && cl.getSuperclass().isEnum()) ++ cl = cl.getSuperclass(); ++ ++ try { ++ _name = cl.getMethod("name", new Class[0]); ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ Class cl = obj.getClass(); ++ ++ if (! cl.isEnum() && cl.getSuperclass().isEnum()) ++ cl = cl.getSuperclass(); ++ ++ String name = null; ++ try { ++ name = (String) _name.invoke(obj, (Object[]) null); ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref < -1) { ++ out.writeString("name"); ++ out.writeString(name); ++ out.writeMapEnd(); ++ } ++ else { ++ if (ref == -1) { ++ out.writeClassFieldLength(1); ++ out.writeString("name"); ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ out.writeString(name); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumerationDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/EnumerationDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,84 +1,84 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.Vector; +- +-/** +- * Deserializing a JDK 1.2 Collection. +- */ +-public class EnumerationDeserializer extends AbstractListDeserializer { +- private static EnumerationDeserializer _deserializer; +- +- public static EnumerationDeserializer create() +- { +- if (_deserializer == null) +- _deserializer = new EnumerationDeserializer(); +- +- return _deserializer; +- } +- +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- Vector list = new Vector(); +- +- in.addRef(list); +- +- while (! in.isEnd()) +- list.add(in.readObject()); +- +- in.readEnd(); +- +- return list.elements(); +- } +-} +- +- ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.Vector; ++ ++/** ++ * Deserializing a JDK 1.2 Collection. ++ */ ++public class EnumerationDeserializer extends AbstractListDeserializer { ++ private static EnumerationDeserializer _deserializer; ++ ++ public static EnumerationDeserializer create() ++ { ++ if (_deserializer == null) ++ _deserializer = new EnumerationDeserializer(); ++ ++ return _deserializer; ++ } ++ ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ Vector list = new Vector(); ++ ++ in.addRef(list); ++ ++ while (! in.isEnd()) ++ list.add(in.readObject()); ++ ++ in.readEnd(); ++ ++ return list.elements(); ++ } ++} ++ ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumerationSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/EnumerationSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,84 +1,84 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.Enumeration; +- +-/** +- * Serializing a JDK 1.2 Enumeration. +- */ +-public class EnumerationSerializer extends AbstractSerializer { +- private static EnumerationSerializer _serializer; +- +- public static EnumerationSerializer create() +- { +- if (_serializer == null) +- _serializer = new EnumerationSerializer(); +- +- return _serializer; +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- Enumeration iter = (Enumeration) obj; +- +- boolean hasEnd = out.writeListBegin(-1, null); +- +- while (iter.hasMoreElements()) { +- Object value = iter.nextElement(); +- +- out.writeObject(value); +- } +- +- if (hasEnd) +- out.writeListEnd(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.Enumeration; ++ ++/** ++ * Serializing a JDK 1.2 Enumeration. ++ */ ++public class EnumerationSerializer extends AbstractSerializer { ++ private static EnumerationSerializer _serializer; ++ ++ public static EnumerationSerializer create() ++ { ++ if (_serializer == null) ++ _serializer = new EnumerationSerializer(); ++ ++ return _serializer; ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ Enumeration iter = (Enumeration) obj; ++ ++ boolean hasEnd = out.writeListBegin(-1, null); ++ ++ while (iter.hasMoreElements()) { ++ Object value = iter.nextElement(); ++ ++ out.writeObject(value); ++ } ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnvelopeFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/EnvelopeFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/EnvelopeFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/EnvelopeFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,57 +1,57 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.logging.*; +- +-public class EnvelopeFactory +-{ +- private static final Logger log +- = Logger.getLogger(EnvelopeFactory.class.getName()); +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.logging.*; ++ ++public class EnvelopeFactory ++{ ++ private static final Logger log ++ = Logger.getLogger(EnvelopeFactory.class.getName()); ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ExtSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/ExtSerializerFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ExtSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ExtSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,107 +1,107 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.HashMap; +- +-/** +- * Factory for returning serialization methods. +- */ +-public class ExtSerializerFactory extends AbstractSerializerFactory { +- private HashMap _serializerMap = new HashMap(); +- private HashMap _deserializerMap = new HashMap(); +- +- /** +- * Adds a serializer. +- * +- * @param cl the class of the serializer +- * @param serializer the serializer +- */ +- public void addSerializer(Class cl, Serializer serializer) +- { +- _serializerMap.put(cl, serializer); +- } +- +- /** +- * Adds a deserializer. +- * +- * @param cl the class of the deserializer +- * @param deserializer the deserializer +- */ +- public void addDeserializer(Class cl, Deserializer deserializer) +- { +- _deserializerMap.put(cl, deserializer); +- } +- +- /** +- * Returns the serializer for a class. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- public Serializer getSerializer(Class cl) +- throws HessianProtocolException +- { +- return (Serializer) _serializerMap.get(cl); +- } +- +- /** +- * Returns the deserializer for a class. +- * +- * @param cl the class of the object that needs to be deserialized. +- * +- * @return a deserializer object for the serialization. +- */ +- public Deserializer getDeserializer(Class cl) +- throws HessianProtocolException +- { +- return (Deserializer) _deserializerMap.get(cl); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.HashMap; ++ ++/** ++ * Factory for returning serialization methods. ++ */ ++public class ExtSerializerFactory extends AbstractSerializerFactory { ++ private HashMap _serializerMap = new HashMap(); ++ private HashMap _deserializerMap = new HashMap(); ++ ++ /** ++ * Adds a serializer. ++ * ++ * @param cl the class of the serializer ++ * @param serializer the serializer ++ */ ++ public void addSerializer(Class cl, Serializer serializer) ++ { ++ _serializerMap.put(cl, serializer); ++ } ++ ++ /** ++ * Adds a deserializer. ++ * ++ * @param cl the class of the deserializer ++ * @param deserializer the deserializer ++ */ ++ public void addDeserializer(Class cl, Deserializer deserializer) ++ { ++ _deserializerMap.put(cl, deserializer); ++ } ++ ++ /** ++ * Returns the serializer for a class. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ public Serializer getSerializer(Class cl) ++ throws HessianProtocolException ++ { ++ return (Serializer) _serializerMap.get(cl); ++ } ++ ++ /** ++ * Returns the deserializer for a class. ++ * ++ * @param cl the class of the object that needs to be deserialized. ++ * ++ * @return a deserializer object for the serialization. ++ */ ++ public Deserializer getDeserializer(Class cl) ++ throws HessianProtocolException ++ { ++ return (Deserializer) _deserializerMap.get(cl); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2.java hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2.java +--- hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,59 +1,59 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing an object for known object types. +- */ +-public interface FieldDeserializer2 { +- void deserialize(AbstractHessianInput in, Object obj) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public interface FieldDeserializer2 { ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2Factory.java hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2Factory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2Factory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2Factory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,500 +1,500 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Field; +-import java.lang.reflect.Modifier; +-import java.util.logging.Logger; +- +-/** +- * Serializing an object for known object types. +- */ +-public class FieldDeserializer2Factory { +- private static final Logger log +- = Logger.getLogger(JavaDeserializer.class.getName()); +- +- public static FieldDeserializer2Factory create() +- { +- boolean isEnableUnsafeSerializer = (UnsafeSerializer.isEnabled() +- && UnsafeDeserializer.isEnabled()); +- +- if (isEnableUnsafeSerializer) { +- return new FieldDeserializer2FactoryUnsafe(); +- } +- else { +- return new FieldDeserializer2Factory(); +- } +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- FieldDeserializer2 create(Field field) +- { +- if (Modifier.isTransient(field.getModifiers()) +- || Modifier.isStatic(field.getModifiers())) { +- return NullFieldDeserializer.DESER; +- } +- +- // XXX: could parameterize the handler to only deal with public +- try { +- field.setAccessible(true); +- } catch (Throwable e) { +- e.printStackTrace(); +- } +- +- Class type = field.getType(); +- FieldDeserializer2 deser; +- +- if (String.class.equals(type)) +- deser = new StringFieldDeserializer(field); +- else if (byte.class.equals(type)) { +- deser = new ByteFieldDeserializer(field); +- } +- else if (short.class.equals(type)) { +- deser = new ShortFieldDeserializer(field); +- } +- else if (int.class.equals(type)) { +- deser = new IntFieldDeserializer(field); +- } +- else if (long.class.equals(type)) { +- deser = new LongFieldDeserializer(field); +- } +- else if (float.class.equals(type)) { +- deser = new FloatFieldDeserializer(field); +- } +- else if (double.class.equals(type)) { +- deser = new DoubleFieldDeserializer(field); +- } +- else if (boolean.class.equals(type)) { +- deser = new BooleanFieldDeserializer(field); +- } +- else if (java.sql.Date.class.equals(type)) { +- deser = new SqlDateFieldDeserializer(field); +- } +- else if (java.sql.Timestamp.class.equals(type)) { +- deser = new SqlTimestampFieldDeserializer(field); +- } +- else if (java.sql.Time.class.equals(type)) { +- deser = new SqlTimeFieldDeserializer(field); +- } +- else { +- deser = new ObjectFieldDeserializer(field); +- } +- +- return deser; +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- protected static Object getParamArg(Class cl) +- { +- if (! cl.isPrimitive()) +- return null; +- else if (boolean.class.equals(cl)) +- return Boolean.FALSE; +- else if (byte.class.equals(cl)) +- return new Byte((byte) 0); +- else if (short.class.equals(cl)) +- return new Short((short) 0); +- else if (char.class.equals(cl)) +- return new Character((char) 0); +- else if (int.class.equals(cl)) +- return Integer.valueOf(0); +- else if (long.class.equals(cl)) +- return Long.valueOf(0); +- else if (float.class.equals(cl)) +- return Float.valueOf(0); +- else if (double.class.equals(cl)) +- return Double.valueOf(0); +- else +- throw new UnsupportedOperationException(); +- } +- +- static class NullFieldDeserializer implements FieldDeserializer2 { +- static NullFieldDeserializer DESER = new NullFieldDeserializer(); +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- in.readObject(); +- } +- } +- +- static class ObjectFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- ObjectFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- Object value = null; +- +- try { +- value = in.readObject(_field.getType()); +- +- _field.set(obj, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class BooleanFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- BooleanFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- boolean value = false; +- +- try { +- value = in.readBoolean(); +- +- _field.setBoolean(obj, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class ByteFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- ByteFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- int value = 0; +- +- try { +- value = in.readInt(); +- +- _field.setByte(obj, (byte) value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class ShortFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- ShortFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- int value = 0; +- +- try { +- value = in.readInt(); +- +- _field.setShort(obj, (short) value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class IntFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- IntFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- int value = 0; +- +- try { +- value = in.readInt(); +- +- _field.setInt(obj, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class LongFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- LongFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- long value = 0; +- +- try { +- value = in.readLong(); +- +- _field.setLong(obj, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class FloatFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- FloatFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- double value = 0; +- +- try { +- value = in.readDouble(); +- +- _field.setFloat(obj, (float) value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class DoubleFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- DoubleFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- double value = 0; +- +- try { +- value = in.readDouble(); +- +- _field.setDouble(obj, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class StringFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- StringFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- String value = null; +- +- try { +- value = in.readString(); +- +- _field.set(obj, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class SqlDateFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- SqlDateFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- java.sql.Date value = null; +- +- try { +- java.util.Date date = (java.util.Date) in.readObject(); +- +- if (date != null) { +- value = new java.sql.Date(date.getTime()); +- +- _field.set(obj, value); +- } +- else { +- _field.set(obj, null); +- } +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- SqlTimestampFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- java.sql.Timestamp value = null; +- +- try { +- java.util.Date date = (java.util.Date) in.readObject(); +- +- if (date != null) { +- value = new java.sql.Timestamp(date.getTime()); +- +- _field.set(obj, value); +- } +- else { +- _field.set(obj, null); +- } +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class SqlTimeFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- +- SqlTimeFieldDeserializer(Field field) +- { +- _field = field; +- } +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- java.sql.Time value = null; +- +- try { +- java.util.Date date = (java.util.Date) in.readObject(); +- +- if (date != null) { +- value = new java.sql.Time(date.getTime()); +- +- _field.set(obj, value); +- } +- else { +- _field.set(obj, null); +- } +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static void logDeserializeError(Field field, Object obj, Object value, +- Throwable e) +- throws IOException +- { +- String fieldName = (field.getDeclaringClass().getName() +- + "." + field.getName()); +- +- if (e instanceof HessianFieldException) +- throw (HessianFieldException) e; +- else if (e instanceof IOException) +- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); +- +- if (value != null) +- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" +- + " cannot be assigned to '" + field.getType().getName() + "'", e); +- else +- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Field; ++import java.lang.reflect.Modifier; ++import java.util.logging.Logger; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class FieldDeserializer2Factory { ++ private static final Logger log ++ = Logger.getLogger(JavaDeserializer.class.getName()); ++ ++ public static FieldDeserializer2Factory create() ++ { ++ boolean isEnableUnsafeSerializer = (UnsafeSerializer.isEnabled() ++ && UnsafeDeserializer.isEnabled()); ++ ++ if (isEnableUnsafeSerializer) { ++ return new FieldDeserializer2FactoryUnsafe(); ++ } ++ else { ++ return new FieldDeserializer2Factory(); ++ } ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ FieldDeserializer2 create(Field field) ++ { ++ if (Modifier.isTransient(field.getModifiers()) ++ || Modifier.isStatic(field.getModifiers())) { ++ return NullFieldDeserializer.DESER; ++ } ++ ++ // XXX: could parameterize the handler to only deal with public ++ try { ++ field.setAccessible(true); ++ } catch (Throwable e) { ++ e.printStackTrace(); ++ } ++ ++ Class type = field.getType(); ++ FieldDeserializer2 deser; ++ ++ if (String.class.equals(type)) ++ deser = new StringFieldDeserializer(field); ++ else if (byte.class.equals(type)) { ++ deser = new ByteFieldDeserializer(field); ++ } ++ else if (short.class.equals(type)) { ++ deser = new ShortFieldDeserializer(field); ++ } ++ else if (int.class.equals(type)) { ++ deser = new IntFieldDeserializer(field); ++ } ++ else if (long.class.equals(type)) { ++ deser = new LongFieldDeserializer(field); ++ } ++ else if (float.class.equals(type)) { ++ deser = new FloatFieldDeserializer(field); ++ } ++ else if (double.class.equals(type)) { ++ deser = new DoubleFieldDeserializer(field); ++ } ++ else if (boolean.class.equals(type)) { ++ deser = new BooleanFieldDeserializer(field); ++ } ++ else if (java.sql.Date.class.equals(type)) { ++ deser = new SqlDateFieldDeserializer(field); ++ } ++ else if (java.sql.Timestamp.class.equals(type)) { ++ deser = new SqlTimestampFieldDeserializer(field); ++ } ++ else if (java.sql.Time.class.equals(type)) { ++ deser = new SqlTimeFieldDeserializer(field); ++ } ++ else { ++ deser = new ObjectFieldDeserializer(field); ++ } ++ ++ return deser; ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected static Object getParamArg(Class cl) ++ { ++ if (! cl.isPrimitive()) ++ return null; ++ else if (boolean.class.equals(cl)) ++ return Boolean.FALSE; ++ else if (byte.class.equals(cl)) ++ return new Byte((byte) 0); ++ else if (short.class.equals(cl)) ++ return new Short((short) 0); ++ else if (char.class.equals(cl)) ++ return new Character((char) 0); ++ else if (int.class.equals(cl)) ++ return Integer.valueOf(0); ++ else if (long.class.equals(cl)) ++ return Long.valueOf(0); ++ else if (float.class.equals(cl)) ++ return Float.valueOf(0); ++ else if (double.class.equals(cl)) ++ return Double.valueOf(0); ++ else ++ throw new UnsupportedOperationException(); ++ } ++ ++ static class NullFieldDeserializer implements FieldDeserializer2 { ++ static NullFieldDeserializer DESER = new NullFieldDeserializer(); ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ in.readObject(); ++ } ++ } ++ ++ static class ObjectFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ ObjectFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ Object value = null; ++ ++ try { ++ value = in.readObject(_field.getType()); ++ ++ _field.set(obj, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class BooleanFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ BooleanFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ boolean value = false; ++ ++ try { ++ value = in.readBoolean(); ++ ++ _field.setBoolean(obj, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ByteFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ ByteFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _field.setByte(obj, (byte) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ShortFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ ShortFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _field.setShort(obj, (short) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class IntFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ IntFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _field.setInt(obj, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class LongFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ LongFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ long value = 0; ++ ++ try { ++ value = in.readLong(); ++ ++ _field.setLong(obj, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class FloatFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ FloatFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _field.setFloat(obj, (float) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class DoubleFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ DoubleFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _field.setDouble(obj, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class StringFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ StringFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = in.readString(); ++ ++ _field.set(obj, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlDateFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ SqlDateFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Date value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ ++ if (date != null) { ++ value = new java.sql.Date(date.getTime()); ++ ++ _field.set(obj, value); ++ } ++ else { ++ _field.set(obj, null); ++ } ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ SqlTimestampFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Timestamp value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ ++ if (date != null) { ++ value = new java.sql.Timestamp(date.getTime()); ++ ++ _field.set(obj, value); ++ } ++ else { ++ _field.set(obj, null); ++ } ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimeFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ ++ SqlTimeFieldDeserializer(Field field) ++ { ++ _field = field; ++ } ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Time value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ ++ if (date != null) { ++ value = new java.sql.Time(date.getTime()); ++ ++ _field.set(obj, value); ++ } ++ else { ++ _field.set(obj, null); ++ } ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static void logDeserializeError(Field field, Object obj, Object value, ++ Throwable e) ++ throws IOException ++ { ++ String fieldName = (field.getDeclaringClass().getName() ++ + "." + field.getName()); ++ ++ if (e instanceof HessianFieldException) ++ throw (HessianFieldException) e; ++ else if (e instanceof IOException) ++ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); ++ ++ if (value != null) ++ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" ++ + " cannot be assigned to '" + field.getType().getName() + "'", e); ++ else ++ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java +--- hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,569 +1,569 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Field; +-import java.lang.reflect.Modifier; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import sun.misc.Unsafe; +- +-/** +- * Serializing an object for known object types. +- */ +-public class FieldDeserializer2FactoryUnsafe extends FieldDeserializer2Factory { +- private static final Logger log +- = Logger.getLogger(JavaDeserializer.class.getName()); +- +- private static boolean _isEnabled; +- @SuppressWarnings("restriction") +- private static Unsafe _unsafe; +- +- /** +- * Creates a map of the classes fields. +- */ +- @Override +- public FieldDeserializer2 create(Field field) +- { +- if (Modifier.isTransient(field.getModifiers()) +- || Modifier.isStatic(field.getModifiers())) { +- return NullFieldDeserializer.DESER; +- } +- +- /* +- // XXX: could parameterize the handler to only deal with public +- try { +- field.setAccessible(true); +- } catch (Throwable e) { +- e.printStackTrace(); +- } +- */ +- +- Class type = field.getType(); +- FieldDeserializer2 deser; +- +- if (String.class.equals(type)) { +- deser = new StringFieldDeserializer(field); +- } +- else if (byte.class.equals(type)) { +- deser = new ByteFieldDeserializer(field); +- } +- else if (char.class.equals(type)) { +- deser = new CharFieldDeserializer(field); +- } +- else if (short.class.equals(type)) { +- deser = new ShortFieldDeserializer(field); +- } +- else if (int.class.equals(type)) { +- deser = new IntFieldDeserializer(field); +- } +- else if (long.class.equals(type)) { +- deser = new LongFieldDeserializer(field); +- } +- else if (float.class.equals(type)) { +- deser = new FloatFieldDeserializer(field); +- } +- else if (double.class.equals(type)) { +- deser = new DoubleFieldDeserializer(field); +- } +- else if (boolean.class.equals(type)) { +- deser = new BooleanFieldDeserializer(field); +- } +- else if (java.sql.Date.class.equals(type)) { +- deser = new SqlDateFieldDeserializer(field); +- } +- else if (java.sql.Timestamp.class.equals(type)) { +- deser = new SqlTimestampFieldDeserializer(field); +- } +- else if (java.sql.Time.class.equals(type)) { +- deser = new SqlTimeFieldDeserializer(field); +- } +- else { +- deser = new ObjectFieldDeserializer(field); +- } +- +- return deser; +- } +- +- static class NullFieldDeserializer implements FieldDeserializer2 { +- static NullFieldDeserializer DESER = new NullFieldDeserializer(); +- +- @Override +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- in.readObject(); +- } +- } +- +- static class ObjectFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- ObjectFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- Object value = null; +- +- try { +- value = in.readObject(_field.getType()); +- +- _unsafe.putObject(obj, _offset, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class BooleanFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- BooleanFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- boolean value = false; +- +- try { +- value = in.readBoolean(); +- +- _unsafe.putBoolean(obj, _offset, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class ByteFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- ByteFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- int value = 0; +- +- try { +- value = in.readInt(); +- +- _unsafe.putByte(obj, _offset, (byte) value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class CharFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- CharFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- String value = null; +- +- try { +- value = in.readString(); +- +- char ch; +- +- if (value != null && value.length() > 0) +- ch = value.charAt(0); +- else +- ch = 0; +- +- _unsafe.putChar(obj, _offset, ch); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class ShortFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- ShortFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- int value = 0; +- +- try { +- value = in.readInt(); +- +- _unsafe.putShort(obj, _offset, (short) value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class IntFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- IntFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- int value = 0; +- +- try { +- value = in.readInt(); +- +- _unsafe.putInt(obj, _offset, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class LongFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- LongFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- long value = 0; +- +- try { +- value = in.readLong(); +- +- _unsafe.putLong(obj, _offset, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class FloatFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- FloatFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- double value = 0; +- +- try { +- value = in.readDouble(); +- +- _unsafe.putFloat(obj, _offset, (float) value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class DoubleFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- DoubleFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- double value = 0; +- +- try { +- value = in.readDouble(); +- +- _unsafe.putDouble(obj, _offset, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class StringFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- StringFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- String value = null; +- +- try { +- value = in.readString(); +- +- _unsafe.putObject(obj, _offset, value); +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class SqlDateFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- SqlDateFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- java.sql.Date value = null; +- +- try { +- java.util.Date date = (java.util.Date) in.readObject(); +- +- if (date != null) { +- value = new java.sql.Date(date.getTime()); +- +- _unsafe.putObject(obj, _offset, value); +- } else { +- _unsafe.putObject(obj, _offset, null); +- } +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- SqlTimestampFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- java.sql.Timestamp value = null; +- +- try { +- java.util.Date date = (java.util.Date) in.readObject(); +- +- if (date != null) { +- value = new java.sql.Timestamp(date.getTime()); +- +- _unsafe.putObject(obj, _offset, value); +- } +- else { +- _unsafe.putObject(obj, _offset, null); +- } +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static class SqlTimeFieldDeserializer implements FieldDeserializer2 { +- private final Field _field; +- private final long _offset; +- +- @SuppressWarnings("restriction") +- SqlTimeFieldDeserializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(_field); +- } +- +- @SuppressWarnings("restriction") +- public void deserialize(AbstractHessianInput in, Object obj) +- throws IOException +- { +- java.sql.Time value = null; +- +- try { +- java.util.Date date = (java.util.Date) in.readObject(); +- +- if (date != null) { +- value = new java.sql.Time(date.getTime()); +- +- _unsafe.putObject(obj, _offset, value); +- } else { +- _unsafe.putObject(obj, _offset, null); +- } +- } catch (Exception e) { +- logDeserializeError(_field, obj, value, e); +- } +- } +- } +- +- static void logDeserializeError(Field field, Object obj, Object value, +- Throwable e) +- throws IOException +- { +- String fieldName = (field.getDeclaringClass().getName() +- + "." + field.getName()); +- +- if (e instanceof HessianFieldException) +- throw (HessianFieldException) e; +- else if (e instanceof IOException) +- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); +- +- if (value != null) +- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" +- + " cannot be assigned to '" + field.getType().getName() + "'", e); +- else +- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); +- } +- +- static { +- boolean isEnabled = false; +- +- try { +- Class unsafe = Class.forName("sun.misc.Unsafe"); +- Field theUnsafe = null; +- for (Field field : unsafe.getDeclaredFields()) { +- if (field.getName().equals("theUnsafe")) +- theUnsafe = field; +- } +- +- if (theUnsafe != null) { +- theUnsafe.setAccessible(true); +- _unsafe = (Unsafe) theUnsafe.get(null); +- } +- +- isEnabled = _unsafe != null; +- +- String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); +- +- if ("false".equals(unsafeProp)) +- isEnabled = false; +- } catch (Throwable e) { +- log.log(Level.FINER, e.toString(), e); +- } +- +- _isEnabled = isEnabled; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Field; ++import java.lang.reflect.Modifier; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import sun.misc.Unsafe; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class FieldDeserializer2FactoryUnsafe extends FieldDeserializer2Factory { ++ private static final Logger log ++ = Logger.getLogger(JavaDeserializer.class.getName()); ++ ++ private static boolean _isEnabled; ++ @SuppressWarnings("restriction") ++ private static Unsafe _unsafe; ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ @Override ++ public FieldDeserializer2 create(Field field) ++ { ++ if (Modifier.isTransient(field.getModifiers()) ++ || Modifier.isStatic(field.getModifiers())) { ++ return NullFieldDeserializer.DESER; ++ } ++ ++ /* ++ // XXX: could parameterize the handler to only deal with public ++ try { ++ field.setAccessible(true); ++ } catch (Throwable e) { ++ e.printStackTrace(); ++ } ++ */ ++ ++ Class type = field.getType(); ++ FieldDeserializer2 deser; ++ ++ if (String.class.equals(type)) { ++ deser = new StringFieldDeserializer(field); ++ } ++ else if (byte.class.equals(type)) { ++ deser = new ByteFieldDeserializer(field); ++ } ++ else if (char.class.equals(type)) { ++ deser = new CharFieldDeserializer(field); ++ } ++ else if (short.class.equals(type)) { ++ deser = new ShortFieldDeserializer(field); ++ } ++ else if (int.class.equals(type)) { ++ deser = new IntFieldDeserializer(field); ++ } ++ else if (long.class.equals(type)) { ++ deser = new LongFieldDeserializer(field); ++ } ++ else if (float.class.equals(type)) { ++ deser = new FloatFieldDeserializer(field); ++ } ++ else if (double.class.equals(type)) { ++ deser = new DoubleFieldDeserializer(field); ++ } ++ else if (boolean.class.equals(type)) { ++ deser = new BooleanFieldDeserializer(field); ++ } ++ else if (java.sql.Date.class.equals(type)) { ++ deser = new SqlDateFieldDeserializer(field); ++ } ++ else if (java.sql.Timestamp.class.equals(type)) { ++ deser = new SqlTimestampFieldDeserializer(field); ++ } ++ else if (java.sql.Time.class.equals(type)) { ++ deser = new SqlTimeFieldDeserializer(field); ++ } ++ else { ++ deser = new ObjectFieldDeserializer(field); ++ } ++ ++ return deser; ++ } ++ ++ static class NullFieldDeserializer implements FieldDeserializer2 { ++ static NullFieldDeserializer DESER = new NullFieldDeserializer(); ++ ++ @Override ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ in.readObject(); ++ } ++ } ++ ++ static class ObjectFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ObjectFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ Object value = null; ++ ++ try { ++ value = in.readObject(_field.getType()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class BooleanFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ BooleanFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ boolean value = false; ++ ++ try { ++ value = in.readBoolean(); ++ ++ _unsafe.putBoolean(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ByteFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ByteFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putByte(obj, _offset, (byte) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class CharFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ CharFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = in.readString(); ++ ++ char ch; ++ ++ if (value != null && value.length() > 0) ++ ch = value.charAt(0); ++ else ++ ch = 0; ++ ++ _unsafe.putChar(obj, _offset, ch); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ShortFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ShortFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putShort(obj, _offset, (short) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class IntFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ IntFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putInt(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class LongFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ LongFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ long value = 0; ++ ++ try { ++ value = in.readLong(); ++ ++ _unsafe.putLong(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class FloatFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ FloatFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _unsafe.putFloat(obj, _offset, (float) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class DoubleFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ DoubleFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _unsafe.putDouble(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class StringFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ StringFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = in.readString(); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlDateFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlDateFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Date value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ ++ if (date != null) { ++ value = new java.sql.Date(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } else { ++ _unsafe.putObject(obj, _offset, null); ++ } ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlTimestampFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Timestamp value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ ++ if (date != null) { ++ value = new java.sql.Timestamp(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } ++ else { ++ _unsafe.putObject(obj, _offset, null); ++ } ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimeFieldDeserializer implements FieldDeserializer2 { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlTimeFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ public void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Time value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ ++ if (date != null) { ++ value = new java.sql.Time(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } else { ++ _unsafe.putObject(obj, _offset, null); ++ } ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static void logDeserializeError(Field field, Object obj, Object value, ++ Throwable e) ++ throws IOException ++ { ++ String fieldName = (field.getDeclaringClass().getName() ++ + "." + field.getName()); ++ ++ if (e instanceof HessianFieldException) ++ throw (HessianFieldException) e; ++ else if (e instanceof IOException) ++ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); ++ ++ if (value != null) ++ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" ++ + " cannot be assigned to '" + field.getType().getName() + "'", e); ++ else ++ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); ++ } ++ ++ static { ++ boolean isEnabled = false; ++ ++ try { ++ Class unsafe = Class.forName("sun.misc.Unsafe"); ++ Field theUnsafe = null; ++ for (Field field : unsafe.getDeclaredFields()) { ++ if (field.getName().equals("theUnsafe")) ++ theUnsafe = field; ++ } ++ ++ if (theUnsafe != null) { ++ theUnsafe.setAccessible(true); ++ _unsafe = (Unsafe) theUnsafe.get(null); ++ } ++ ++ isEnabled = _unsafe != null; ++ ++ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); ++ ++ if ("false".equals(unsafeProp)) ++ isEnabled = false; ++ } catch (Throwable e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _isEnabled = isEnabled; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FileDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/FileDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/FileDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/FileDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,71 +1,71 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.File; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Deserializing a File +- */ +-public class FileDeserializer extends AbstractStringValueDeserializer { +- @Override +- public Class getType() +- { +- return File.class; +- } +- +- @Override +- protected Object create(String value) +- { +- return new File(value); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.File; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Deserializing a File ++ */ ++public class FileDeserializer extends AbstractStringValueDeserializer { ++ @Override ++ public Class getType() ++ { ++ return File.class; ++ } ++ ++ @Override ++ protected Object create(String value) ++ { ++ return new File(value); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FloatHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/FloatHandle.java +--- hessian-4.0.65-src/com/caucho/hessian/io/FloatHandle.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/FloatHandle.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,83 +1,83 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.net.URL; +-import java.io.Serializable; +- +-/** +- * Handle for Java Float objects. +- */ +-public class FloatHandle implements Serializable { +- private float _value; +- +- private FloatHandle() +- { +- } +- +- public FloatHandle(float value) +- { +- _value = value; +- } +- +- public float getValue() +- { +- return _value; +- } +- +- public Object readResolve() +- { +- return new Float(_value); +- } +- +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _value + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.net.URL; ++import java.io.Serializable; ++ ++/** ++ * Handle for Java Float objects. ++ */ ++public class FloatHandle implements Serializable { ++ private float _value; ++ ++ private FloatHandle() ++ { ++ } ++ ++ public FloatHandle(float value) ++ { ++ _value = value; ++ } ++ ++ public float getValue() ++ { ++ return _value; ++ } ++ ++ public Object readResolve() ++ { ++ return new Float(_value); ++ } ++ ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _value + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Constants.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Constants.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Constants.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Constants.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,146 +1,146 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-public interface Hessian2Constants +-{ +- public static final int BC_BINARY = 'B'; // final chunk +- public static final int BC_BINARY_CHUNK = 'A'; // non-final chunk +- public static final int BC_BINARY_DIRECT = 0x20; // 1-byte length binary +- public static final int BINARY_DIRECT_MAX = 0x0f; +- public static final int BC_BINARY_SHORT = 0x34; // 2-byte length binary +- public static final int BINARY_SHORT_MAX = 0x3ff; // 0-1023 binary +- +- public static final int BC_CLASS_DEF = 'C'; // object/class definition +- +- public static final int BC_DATE = 0x4a; // 64-bit millisecond UTC date +- public static final int BC_DATE_MINUTE = 0x4b; // 32-bit minute UTC date +- +- public static final int BC_DOUBLE = 'D'; // IEEE 64-bit double +- +- public static final int BC_DOUBLE_ZERO = 0x5b; +- public static final int BC_DOUBLE_ONE = 0x5c; +- public static final int BC_DOUBLE_BYTE = 0x5d; +- public static final int BC_DOUBLE_SHORT = 0x5e; +- public static final int BC_DOUBLE_MILL = 0x5f; +- +- public static final int BC_FALSE = 'F'; // boolean false +- +- public static final int BC_INT = 'I'; // 32-bit int +- +- public static final int INT_DIRECT_MIN = -0x10; +- public static final int INT_DIRECT_MAX = 0x2f; +- public static final int BC_INT_ZERO = 0x90; +- +- public static final int INT_BYTE_MIN = -0x800; +- public static final int INT_BYTE_MAX = 0x7ff; +- public static final int BC_INT_BYTE_ZERO = 0xc8; +- +- public static final int BC_END = 'Z'; +- +- public static final int INT_SHORT_MIN = -0x40000; +- public static final int INT_SHORT_MAX = 0x3ffff; +- public static final int BC_INT_SHORT_ZERO = 0xd4; +- +- public static final int BC_LIST_VARIABLE = 0x55; +- public static final int BC_LIST_FIXED = 'V'; +- public static final int BC_LIST_VARIABLE_UNTYPED = 0x57; +- public static final int BC_LIST_FIXED_UNTYPED = 0x58; +- +- public static final int BC_LIST_DIRECT = 0x70; +- public static final int BC_LIST_DIRECT_UNTYPED = 0x78; +- public static final int LIST_DIRECT_MAX = 0x7; +- +- public static final int BC_LONG = 'L'; // 64-bit signed integer +- public static final long LONG_DIRECT_MIN = -0x08; +- public static final long LONG_DIRECT_MAX = 0x0f; +- public static final int BC_LONG_ZERO = 0xe0; +- +- public static final long LONG_BYTE_MIN = -0x800; +- public static final long LONG_BYTE_MAX = 0x7ff; +- public static final int BC_LONG_BYTE_ZERO = 0xf8; +- +- public static final int LONG_SHORT_MIN = -0x40000; +- public static final int LONG_SHORT_MAX = 0x3ffff; +- public static final int BC_LONG_SHORT_ZERO = 0x3c; +- +- public static final int BC_LONG_INT = 0x59; +- +- public static final int BC_MAP = 'M'; +- public static final int BC_MAP_UNTYPED = 'H'; +- +- public static final int BC_NULL = 'N'; +- +- public static final int BC_OBJECT = 'O'; +- public static final int BC_OBJECT_DEF = 'C'; +- +- public static final int BC_OBJECT_DIRECT = 0x60; +- public static final int OBJECT_DIRECT_MAX = 0x0f; +- +- public static final int BC_REF = 0x51; +- +- public static final int BC_STRING = 'S'; // final string +- public static final int BC_STRING_CHUNK = 'R'; // non-final string +- +- public static final int BC_STRING_DIRECT = 0x00; +- public static final int STRING_DIRECT_MAX = 0x1f; +- public static final int BC_STRING_SHORT = 0x30; +- public static final int STRING_SHORT_MAX = 0x3ff; +- +- public static final int BC_TRUE = 'T'; +- +- public static final int P_PACKET_CHUNK = 0x4f; +- public static final int P_PACKET = 'P'; +- +- public static final int P_PACKET_DIRECT = 0x80; +- public static final int PACKET_DIRECT_MAX = 0x7f; +- +- public static final int P_PACKET_SHORT = 0x70; +- public static final int PACKET_SHORT_MAX = 0xfff; +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++public interface Hessian2Constants ++{ ++ public static final int BC_BINARY = 'B'; // final chunk ++ public static final int BC_BINARY_CHUNK = 'A'; // non-final chunk ++ public static final int BC_BINARY_DIRECT = 0x20; // 1-byte length binary ++ public static final int BINARY_DIRECT_MAX = 0x0f; ++ public static final int BC_BINARY_SHORT = 0x34; // 2-byte length binary ++ public static final int BINARY_SHORT_MAX = 0x3ff; // 0-1023 binary ++ ++ public static final int BC_CLASS_DEF = 'C'; // object/class definition ++ ++ public static final int BC_DATE = 0x4a; // 64-bit millisecond UTC date ++ public static final int BC_DATE_MINUTE = 0x4b; // 32-bit minute UTC date ++ ++ public static final int BC_DOUBLE = 'D'; // IEEE 64-bit double ++ ++ public static final int BC_DOUBLE_ZERO = 0x5b; ++ public static final int BC_DOUBLE_ONE = 0x5c; ++ public static final int BC_DOUBLE_BYTE = 0x5d; ++ public static final int BC_DOUBLE_SHORT = 0x5e; ++ public static final int BC_DOUBLE_MILL = 0x5f; ++ ++ public static final int BC_FALSE = 'F'; // boolean false ++ ++ public static final int BC_INT = 'I'; // 32-bit int ++ ++ public static final int INT_DIRECT_MIN = -0x10; ++ public static final int INT_DIRECT_MAX = 0x2f; ++ public static final int BC_INT_ZERO = 0x90; ++ ++ public static final int INT_BYTE_MIN = -0x800; ++ public static final int INT_BYTE_MAX = 0x7ff; ++ public static final int BC_INT_BYTE_ZERO = 0xc8; ++ ++ public static final int BC_END = 'Z'; ++ ++ public static final int INT_SHORT_MIN = -0x40000; ++ public static final int INT_SHORT_MAX = 0x3ffff; ++ public static final int BC_INT_SHORT_ZERO = 0xd4; ++ ++ public static final int BC_LIST_VARIABLE = 0x55; ++ public static final int BC_LIST_FIXED = 'V'; ++ public static final int BC_LIST_VARIABLE_UNTYPED = 0x57; ++ public static final int BC_LIST_FIXED_UNTYPED = 0x58; ++ ++ public static final int BC_LIST_DIRECT = 0x70; ++ public static final int BC_LIST_DIRECT_UNTYPED = 0x78; ++ public static final int LIST_DIRECT_MAX = 0x7; ++ ++ public static final int BC_LONG = 'L'; // 64-bit signed integer ++ public static final long LONG_DIRECT_MIN = -0x08; ++ public static final long LONG_DIRECT_MAX = 0x0f; ++ public static final int BC_LONG_ZERO = 0xe0; ++ ++ public static final long LONG_BYTE_MIN = -0x800; ++ public static final long LONG_BYTE_MAX = 0x7ff; ++ public static final int BC_LONG_BYTE_ZERO = 0xf8; ++ ++ public static final int LONG_SHORT_MIN = -0x40000; ++ public static final int LONG_SHORT_MAX = 0x3ffff; ++ public static final int BC_LONG_SHORT_ZERO = 0x3c; ++ ++ public static final int BC_LONG_INT = 0x59; ++ ++ public static final int BC_MAP = 'M'; ++ public static final int BC_MAP_UNTYPED = 'H'; ++ ++ public static final int BC_NULL = 'N'; ++ ++ public static final int BC_OBJECT = 'O'; ++ public static final int BC_OBJECT_DEF = 'C'; ++ ++ public static final int BC_OBJECT_DIRECT = 0x60; ++ public static final int OBJECT_DIRECT_MAX = 0x0f; ++ ++ public static final int BC_REF = 0x51; ++ ++ public static final int BC_STRING = 'S'; // final string ++ public static final int BC_STRING_CHUNK = 'R'; // non-final string ++ ++ public static final int BC_STRING_DIRECT = 0x00; ++ public static final int STRING_DIRECT_MAX = 0x1f; ++ public static final int BC_STRING_SHORT = 0x30; ++ public static final int STRING_SHORT_MAX = 0x3ff; ++ ++ public static final int BC_TRUE = 'T'; ++ ++ public static final int P_PACKET_CHUNK = 0x4f; ++ public static final int P_PACKET = 'P'; ++ ++ public static final int P_PACKET_DIRECT = 0x80; ++ public static final int PACKET_DIRECT_MAX = 0x7f; ++ ++ public static final int P_PACKET_SHORT = 0x70; ++ public static final int PACKET_SHORT_MAX = 0xfff; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Input.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Input.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Input.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Input.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,3032 +1,3032 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.*; +-import java.lang.reflect.Field; +-import java.util.ArrayList; +-import java.util.Date; +-import java.util.HashMap; +-import java.util.logging.*; +- +-/** +- * Input stream for Hessian requests. +- * +- *

HessianInput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * InputStream is = ...; // from http connection
+- * HessianInput in = new HessianInput(is);
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-public class Hessian2Input +- extends AbstractHessianInput +- implements Hessian2Constants +-{ +- private static final Logger log +- = Logger.getLogger(Hessian2Input.class.getName()); +- +- private static final int END_OF_DATA = -2; +- +- private static Field _detailMessageField; +- +- private static final int SIZE = 1024; +- private static final int GAP = 16; +- +- // standard, unmodified factory for deserializing objects +- protected SerializerFactory _defaultSerializerFactory; +- // factory for deserializing objects in the input stream +- protected SerializerFactory _serializerFactory; +- +- private static boolean _isCloseStreamOnClose; +- +- protected ArrayList _refs +- = new ArrayList(); +- protected ArrayList _classDefs +- = new ArrayList(); +- protected ArrayList _types +- = new ArrayList(); +- +- // the underlying input stream +- private InputStream _is; +- private final byte []_buffer = new byte[SIZE]; +- +- // a peek character +- private int _offset; +- private int _length; +- +- // the method for a call +- private String _method; +- private Throwable _replyFault; +- +- private StringBuilder _sbuf = new StringBuilder(); +- +- // true if this is the last chunk +- private boolean _isLastChunk; +- // the chunk length +- private int _chunkLength; +- +- private HessianDebugInputStream _dIs; +- +- public Hessian2Input() +- { +- if (log.isLoggable(Level.FINEST)) { +- _dIs = new HessianDebugInputStream(log, Level.FINEST); +- } +- } +- +- /** +- * Creates a new Hessian input stream, initialized with an +- * underlying input stream. +- * +- * @param is the underlying input stream. +- */ +- public Hessian2Input(InputStream is) +- { +- this(); +- +- init(is); +- } +- +- /** +- * Sets the serializer factory. +- */ +- public void setSerializerFactory(SerializerFactory factory) +- { +- _serializerFactory = factory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- public SerializerFactory getSerializerFactory() +- { +- // the default serializer factory cannot be modified by external +- // callers +- if (_serializerFactory == _defaultSerializerFactory) { +- _serializerFactory = new SerializerFactory(); +- } +- +- return _serializerFactory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- protected final SerializerFactory findSerializerFactory() +- { +- SerializerFactory factory = _serializerFactory; +- +- if (factory == null) { +- factory = SerializerFactory.createDefault(); +- _defaultSerializerFactory = factory; +- _serializerFactory = factory; +- } +- +- return factory; +- } +- +- public void allow(String pattern) +- { +- ClassFactory factory = getSerializerFactory().getClassFactory(); +- +- factory.allow(pattern); +- } +- +- public void setCloseStreamOnClose(boolean isClose) +- { +- _isCloseStreamOnClose = isClose; +- } +- +- public boolean isCloseStreamOnClose() +- { +- return _isCloseStreamOnClose; +- } +- +- /** +- * Returns the calls method +- */ +- public String getMethod() +- { +- return _method; +- } +- +- /** +- * Returns any reply fault. +- */ +- public Throwable getReplyFault() +- { +- return _replyFault; +- } +- +- @Override +- public void init(InputStream is) +- { +- if (_dIs != null) { +- _dIs.initPacket(is); +- is = _dIs; +- } +- +- _is = is; +- +- reset(); +- } +- +- public void initPacket(InputStream is) +- { +- if (_dIs != null) { +- _dIs.initPacket(is); +- is = _dIs; +- } +- +- _is = is; +- +- resetReferences(); +- } +- +- /** +- * Starts reading the call +- * +- *
+-   * c major minor
+-   * 
+- */ +- public int readCall() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'C') +- throw error("expected hessian call ('C') at " + codeName(tag)); +- +- return 0; +- } +- +- /** +- * Starts reading the envelope +- * +- *
+-   * E major minor
+-   * 
+- */ +- public int readEnvelope() +- throws IOException +- { +- int tag = read(); +- int version = 0; +- +- if (tag == 'H') { +- int major = read(); +- int minor = read(); +- +- version = (major << 16) + minor; +- +- tag = read(); +- } +- +- if (tag != 'E') +- throw error("expected hessian Envelope ('E') at " + codeName(tag)); +- +- return version; +- } +- +- /** +- * Completes reading the envelope +- * +- *

A successful completion will have a single value: +- * +- *

+-   * Z
+-   * 
+- */ +- public void completeEnvelope() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'Z') +- error("expected end of envelope at " + codeName(tag)); +- } +- +- /** +- * Starts reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * string
+-   * 
+- */ +- public String readMethod() +- throws IOException +- { +- _method = readString(); +- +- return _method; +- } +- +- /** +- * Returns the number of method arguments +- * +- *
+-   * int
+-   * 
+- */ +- @Override +- public int readMethodArgLength() +- throws IOException +- { +- return readInt(); +- } +- +- /** +- * Starts reading the call, including the headers. +- * +- *

The call expects the following protocol data +- * +- *

+-   * c major minor
+-   * m b16 b8 method
+-   * 
+- */ +- public void startCall() +- throws IOException +- { +- readCall(); +- +- readMethod(); +- } +- +- public Object []readArguments() +- throws IOException +- { +- int len = readInt(); +- +- Object []args = new Object[len]; +- +- for (int i = 0; i < len; i++) +- args[i] = readObject(); +- +- return args; +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- } +- +- /** +- * Reads a reply as an object. +- * If the reply has a fault, throws the exception. +- */ +- @Override +- public Object readReply(Class expectedClass) +- throws Throwable +- { +- int tag = read(); +- +- if (tag == 'R') +- return readObject(expectedClass); +- else if (tag == 'F') { +- HashMap map = (HashMap) readObject(HashMap.class); +- +- throw prepareFault(map); +- } +- else { +- StringBuilder sb = new StringBuilder(); +- sb.append((char) tag); +- +- try { +- int ch; +- +- while ((ch = read()) >= 0) { +- sb.append((char) ch); +- } +- } catch (IOException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- throw error("expected hessian reply at " + codeName(tag) + "\n" +- + sb); +- } +- } +- +- /** +- * Starts reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * r
+-   * 
+- */ +- public void startReply() +- throws Throwable +- { +- // XXX: for variable length (?) +- +- readReply(Object.class); +- } +- +- /** +- * Prepares the fault. +- */ +- private Throwable prepareFault(HashMap fault) +- throws IOException +- { +- Object detail = fault.get("detail"); +- String message = (String) fault.get("message"); +- +- if (detail instanceof Throwable) { +- _replyFault = (Throwable) detail; +- +- Field detailMessageField = getDetailMessageField(); +- +- if (message != null && detailMessageField != null) { +- try { +- detailMessageField.set(_replyFault, message); +- } catch (Throwable e) { +- } +- } +- +- return _replyFault; +- } +- +- else { +- String code = (String) fault.get("code"); +- +- _replyFault = new HessianServiceException(message, code, detail); +- +- return _replyFault; +- } +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeReply() +- throws IOException +- { +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeValueReply() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'Z') +- error("expected end of reply at " + codeName(tag)); +- } +- +- /** +- * Reads a header, returning null if there are no headers. +- * +- *
+-   * H b16 b8 value
+-   * 
+- */ +- public String readHeader() +- throws IOException +- { +- return null; +- } +- +- /** +- * Starts reading a packet +- * +- *
+-   * p major minor
+-   * 
+- */ +- public int startMessage() +- throws IOException +- { +- int tag = read(); +- +- if (tag == 'p') { +- } else if (tag == 'P') { +- } else +- throw error("expected Hessian message ('p') at " + codeName(tag)); +- +- int major = read(); +- int minor = read(); +- +- return (major << 16) + minor; +- } +- +- /** +- * Completes reading the message +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeMessage() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'Z') +- error("expected end of message at " + codeName(tag)); +- } +- +- /** +- * Reads a null +- * +- *
+-   * N
+-   * 
+- */ +- public void readNull() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': return; +- +- default: +- throw expect("null", tag); +- } +- } +- +- /** +- * Reads a boolean +- * +- *
+-   * T
+-   * F
+-   * 
+- */ +- public boolean readBoolean() +- throws IOException +- { +- int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- switch (tag) { +- case 'T': return true; +- case 'F': return false; +- +- // direct integer +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- return tag != BC_INT_ZERO; +- +- // INT_BYTE = 0 +- case 0xc8: +- return read() != 0; +- +- // INT_BYTE != 0 +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- read(); +- return true; +- +- // INT_SHORT = 0 +- case 0xd4: +- return (256 * read() + read()) != 0; +- +- // INT_SHORT != 0 +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd5: case 0xd6: case 0xd7: +- read(); +- read(); +- return true; +- +- case 'I': return +- parseInt() != 0; +- +- case 0xd8: case 0xd9: case 0xda: case 0xdb: +- case 0xdc: case 0xdd: case 0xde: case 0xdf: +- +- case 0xe0: case 0xe1: case 0xe2: case 0xe3: +- case 0xe4: case 0xe5: case 0xe6: case 0xe7: +- case 0xe8: case 0xe9: case 0xea: case 0xeb: +- case 0xec: case 0xed: case 0xee: case 0xef: +- return tag != BC_LONG_ZERO; +- +- // LONG_BYTE = 0 +- case 0xf8: +- return read() != 0; +- +- // LONG_BYTE != 0 +- case 0xf0: case 0xf1: case 0xf2: case 0xf3: +- case 0xf4: case 0xf5: case 0xf6: case 0xf7: +- case 0xf9: case 0xfa: case 0xfb: +- case 0xfc: case 0xfd: case 0xfe: case 0xff: +- read(); +- return true; +- +- // INT_SHORT = 0 +- case 0x3c: +- return (256 * read() + read()) != 0; +- +- // INT_SHORT != 0 +- case 0x38: case 0x39: case 0x3a: case 0x3b: +- case 0x3d: case 0x3e: case 0x3f: +- read(); +- read(); +- return true; +- +- case BC_LONG_INT: +- return (0x1000000L * read() +- + 0x10000L * read() +- + 0x100 * read() +- + read()) != 0; +- +- case 'L': +- return parseLong() != 0; +- +- case BC_DOUBLE_ZERO: +- return false; +- +- case BC_DOUBLE_ONE: +- return true; +- +- case BC_DOUBLE_BYTE: +- return read() != 0; +- +- case BC_DOUBLE_SHORT: +- return (0x100 * read() + read()) != 0; +- +- case BC_DOUBLE_MILL: +- { +- int mills = parseInt(); +- +- return mills != 0; +- } +- +- case 'D': +- return parseDouble() != 0.0; +- +- case 'N': +- return false; +- +- default: +- throw expect("boolean", tag); +- } +- } +- +- /** +- * Reads a short +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- */ +- public short readShort() +- throws IOException +- { +- return (short) readInt(); +- } +- +- /** +- * Reads an integer +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- */ +- public final int readInt() +- throws IOException +- { +- //int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return 0; +- +- case 'F': +- return 0; +- +- case 'T': +- return 1; +- +- // direct integer +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- return tag - BC_INT_ZERO; +- +- /* byte int */ +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc8: case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); +- +- /* short int */ +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd4: case 0xd5: case 0xd6: case 0xd7: +- return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); +- +- case 'I': +- case BC_LONG_INT: +- return ((read() << 24) +- + (read() << 16) +- + (read() << 8) +- + read()); +- +- // direct long +- case 0xd8: case 0xd9: case 0xda: case 0xdb: +- case 0xdc: case 0xdd: case 0xde: case 0xdf: +- +- case 0xe0: case 0xe1: case 0xe2: case 0xe3: +- case 0xe4: case 0xe5: case 0xe6: case 0xe7: +- case 0xe8: case 0xe9: case 0xea: case 0xeb: +- case 0xec: case 0xed: case 0xee: case 0xef: +- return tag - BC_LONG_ZERO; +- +- /* byte long */ +- case 0xf0: case 0xf1: case 0xf2: case 0xf3: +- case 0xf4: case 0xf5: case 0xf6: case 0xf7: +- case 0xf8: case 0xf9: case 0xfa: case 0xfb: +- case 0xfc: case 0xfd: case 0xfe: case 0xff: +- return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); +- +- /* short long */ +- case 0x38: case 0x39: case 0x3a: case 0x3b: +- case 0x3c: case 0x3d: case 0x3e: case 0x3f: +- return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); +- +- case 'L': +- return (int) parseLong(); +- +- case BC_DOUBLE_ZERO: +- return 0; +- +- case BC_DOUBLE_ONE: +- return 1; +- +- //case LONG_BYTE: +- case BC_DOUBLE_BYTE: +- return (byte) (_offset < _length ? _buffer[_offset++] : read()); +- +- //case INT_SHORT: +- //case LONG_SHORT: +- case BC_DOUBLE_SHORT: +- return (short) (256 * read() + read()); +- +- case BC_DOUBLE_MILL: +- { +- int mills = parseInt(); +- +- return (int) (0.001 * mills); +- } +- +- case 'D': +- return (int) parseDouble(); +- +- default: +- throw expect("integer", tag); +- } +- } +- +- /** +- * Reads a long +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public long readLong() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return 0; +- +- case 'F': +- return 0; +- +- case 'T': +- return 1; +- +- // direct integer +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- return tag - BC_INT_ZERO; +- +- /* byte int */ +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc8: case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); +- +- /* short int */ +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd4: case 0xd5: case 0xd6: case 0xd7: +- return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); +- +- //case LONG_BYTE: +- case BC_DOUBLE_BYTE: +- return (byte) (_offset < _length ? _buffer[_offset++] : read()); +- +- //case INT_SHORT: +- //case LONG_SHORT: +- case BC_DOUBLE_SHORT: +- return (short) (256 * read() + read()); +- +- case 'I': +- case BC_LONG_INT: +- return parseInt(); +- +- // direct long +- case 0xd8: case 0xd9: case 0xda: case 0xdb: +- case 0xdc: case 0xdd: case 0xde: case 0xdf: +- +- case 0xe0: case 0xe1: case 0xe2: case 0xe3: +- case 0xe4: case 0xe5: case 0xe6: case 0xe7: +- case 0xe8: case 0xe9: case 0xea: case 0xeb: +- case 0xec: case 0xed: case 0xee: case 0xef: +- return tag - BC_LONG_ZERO; +- +- /* byte long */ +- case 0xf0: case 0xf1: case 0xf2: case 0xf3: +- case 0xf4: case 0xf5: case 0xf6: case 0xf7: +- case 0xf8: case 0xf9: case 0xfa: case 0xfb: +- case 0xfc: case 0xfd: case 0xfe: case 0xff: +- return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); +- +- /* short long */ +- case 0x38: case 0x39: case 0x3a: case 0x3b: +- case 0x3c: case 0x3d: case 0x3e: case 0x3f: +- return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); +- +- case 'L': +- return parseLong(); +- +- case BC_DOUBLE_ZERO: +- return 0; +- +- case BC_DOUBLE_ONE: +- return 1; +- +- case BC_DOUBLE_MILL: +- { +- int mills = parseInt(); +- +- return (long) (0.001 * mills); +- } +- +- case 'D': +- return (long) parseDouble(); +- +- default: +- throw expect("long", tag); +- } +- } +- +- /** +- * Reads a float +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public float readFloat() +- throws IOException +- { +- return (float) readDouble(); +- } +- +- /** +- * Reads a double +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public double readDouble() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return 0; +- +- case 'F': +- return 0; +- +- case 'T': +- return 1; +- +- // direct integer +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- return tag - 0x90; +- +- /* byte int */ +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc8: case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); +- +- /* short int */ +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd4: case 0xd5: case 0xd6: case 0xd7: +- return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); +- +- case 'I': +- case BC_LONG_INT: +- return parseInt(); +- +- // direct long +- case 0xd8: case 0xd9: case 0xda: case 0xdb: +- case 0xdc: case 0xdd: case 0xde: case 0xdf: +- +- case 0xe0: case 0xe1: case 0xe2: case 0xe3: +- case 0xe4: case 0xe5: case 0xe6: case 0xe7: +- case 0xe8: case 0xe9: case 0xea: case 0xeb: +- case 0xec: case 0xed: case 0xee: case 0xef: +- return tag - BC_LONG_ZERO; +- +- /* byte long */ +- case 0xf0: case 0xf1: case 0xf2: case 0xf3: +- case 0xf4: case 0xf5: case 0xf6: case 0xf7: +- case 0xf8: case 0xf9: case 0xfa: case 0xfb: +- case 0xfc: case 0xfd: case 0xfe: case 0xff: +- return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); +- +- /* short long */ +- case 0x38: case 0x39: case 0x3a: case 0x3b: +- case 0x3c: case 0x3d: case 0x3e: case 0x3f: +- return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); +- +- case 'L': +- return (double) parseLong(); +- +- case BC_DOUBLE_ZERO: +- return 0; +- +- case BC_DOUBLE_ONE: +- return 1; +- +- case BC_DOUBLE_BYTE: +- return (byte) (_offset < _length ? _buffer[_offset++] : read()); +- +- case BC_DOUBLE_SHORT: +- return (short) (256 * read() + read()); +- +- case BC_DOUBLE_MILL: +- { +- int mills = parseInt(); +- +- return 0.001 * mills; +- } +- +- case 'D': +- return parseDouble(); +- +- default: +- throw expect("double", tag); +- } +- } +- +- /** +- * Reads a date. +- * +- *
+-   * T b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public long readUTCDate() +- throws IOException +- { +- int tag = read(); +- +- if (tag == BC_DATE) { +- return parseLong(); +- } +- else if (tag == BC_DATE_MINUTE) { +- return parseInt() * 60000L; +- } +- else +- throw expect("date", tag); +- } +- +- /** +- * Reads a byte from the stream. +- */ +- public int readChar() +- throws IOException +- { +- if (_chunkLength > 0) { +- _chunkLength--; +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- int ch = parseUTF8Char(); +- return ch; +- } +- else if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'S': +- case BC_STRING_CHUNK: +- _isLastChunk = tag == 'S'; +- _chunkLength = (read() << 8) + read(); +- +- _chunkLength--; +- int value = parseUTF8Char(); +- +- // special code so successive read byte won't +- // be read as a single object. +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- return value; +- +- default: +- throw expect("char", tag); +- } +- } +- +- /** +- * Reads a byte array from the stream. +- */ +- public int readString(char []buffer, int offset, int length) +- throws IOException +- { +- int readLength = 0; +- +- if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- else if (_chunkLength == 0) { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'S': +- case BC_STRING_CHUNK: +- _isLastChunk = tag == 'S'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 0x00: case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- _isLastChunk = true; +- _chunkLength = tag - 0x00; +- break; +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- _isLastChunk = true; +- _chunkLength = (tag - 0x30) * 256 + read(); +- break; +- +- default: +- throw expect("string", tag); +- } +- } +- +- while (length > 0) { +- if (_chunkLength > 0) { +- buffer[offset++] = (char) parseUTF8Char(); +- _chunkLength--; +- length--; +- readLength++; +- } +- else if (_isLastChunk) { +- if (readLength == 0) +- return -1; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- else { +- int tag = read(); +- +- switch (tag) { +- case 'S': +- case BC_STRING_CHUNK: +- _isLastChunk = tag == 'S'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 0x00: case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- _isLastChunk = true; +- _chunkLength = tag - 0x00; +- break; +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- _isLastChunk = true; +- _chunkLength = (tag - 0x30) * 256 + read(); +- break; +- +- default: +- throw expect("string", tag); +- } +- } +- } +- +- if (readLength == 0) +- return -1; +- else if (_chunkLength > 0 || ! _isLastChunk) +- return readLength; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- +- /** +- * Reads a string +- * +- *
+-   * S b16 b8 string value
+-   * 
+- */ +- public String readString() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- case 'T': +- return "true"; +- case 'F': +- return "false"; +- +- // direct integer +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- return String.valueOf((tag - 0x90)); +- +- /* byte int */ +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc8: case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- return String.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); +- +- /* short int */ +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd4: case 0xd5: case 0xd6: case 0xd7: +- return String.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) +- + 256 * read() + read()); +- +- case 'I': +- case BC_LONG_INT: +- return String.valueOf(parseInt()); +- +- // direct long +- case 0xd8: case 0xd9: case 0xda: case 0xdb: +- case 0xdc: case 0xdd: case 0xde: case 0xdf: +- +- case 0xe0: case 0xe1: case 0xe2: case 0xe3: +- case 0xe4: case 0xe5: case 0xe6: case 0xe7: +- case 0xe8: case 0xe9: case 0xea: case 0xeb: +- case 0xec: case 0xed: case 0xee: case 0xef: +- return String.valueOf(tag - BC_LONG_ZERO); +- +- /* byte long */ +- case 0xf0: case 0xf1: case 0xf2: case 0xf3: +- case 0xf4: case 0xf5: case 0xf6: case 0xf7: +- case 0xf8: case 0xf9: case 0xfa: case 0xfb: +- case 0xfc: case 0xfd: case 0xfe: case 0xff: +- return String.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); +- +- /* short long */ +- case 0x38: case 0x39: case 0x3a: case 0x3b: +- case 0x3c: case 0x3d: case 0x3e: case 0x3f: +- return String.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) +- + 256 * read() + read()); +- +- case 'L': +- return String.valueOf(parseLong()); +- +- case BC_DOUBLE_ZERO: +- return "0.0"; +- +- case BC_DOUBLE_ONE: +- return "1.0"; +- +- case BC_DOUBLE_BYTE: +- return String.valueOf((byte) (_offset < _length +- ? _buffer[_offset++] +- : read())); +- +- case BC_DOUBLE_SHORT: +- return String.valueOf(((short) (256 * read() + read()))); +- +- case BC_DOUBLE_MILL: +- { +- int mills = parseInt(); +- +- return String.valueOf(0.001 * mills); +- } +- +- case 'D': +- return String.valueOf(parseDouble()); +- +- case 'S': +- case BC_STRING_CHUNK: +- _isLastChunk = tag == 'S'; +- _chunkLength = (read() << 8) + read(); +- +- _sbuf.setLength(0); +- int ch; +- +- while ((ch = parseChar()) >= 0) +- _sbuf.append((char) ch); +- +- return _sbuf.toString(); +- +- // 0-byte string +- case 0x00: case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- _isLastChunk = true; +- _chunkLength = tag - 0x00; +- +- _sbuf.setLength(0); +- +- while ((ch = parseChar()) >= 0) { +- _sbuf.append((char) ch); +- } +- +- return _sbuf.toString(); +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- _isLastChunk = true; +- _chunkLength = (tag - 0x30) * 256 + read(); +- +- _sbuf.setLength(0); +- +- while ((ch = parseChar()) >= 0) +- _sbuf.append((char) ch); +- +- return _sbuf.toString(); +- +- default: +- throw expect("string", tag); +- } +- } +- +- /** +- * Reads a byte array +- * +- *
+-   * B b16 b8 data value
+-   * 
+- */ +- public byte []readBytes() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case BC_BINARY: +- case BC_BINARY_CHUNK: +- _isLastChunk = tag == BC_BINARY; +- _chunkLength = (read() << 8) + read(); +- +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- int data; +- while ((data = parseByte()) >= 0) +- bos.write(data); +- +- return bos.toByteArray(); +- +- case 0x20: case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- { +- _isLastChunk = true; +- _chunkLength = tag - 0x20; +- +- byte []buffer = new byte[_chunkLength]; +- +- int offset = 0; +- while (offset < _chunkLength) { +- int sublen = read(buffer, 0, _chunkLength - offset); +- +- if (sublen <= 0) +- break; +- +- offset += sublen; +- } +- +- return buffer; +- } +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- { +- _isLastChunk = true; +- _chunkLength = (tag - 0x34) * 256 + read(); +- +- byte []buffer = new byte[_chunkLength]; +- +- int offset = 0; +- while (offset < _chunkLength) { +- int sublen = read(buffer, 0, _chunkLength - offset); +- +- if (sublen <= 0) +- break; +- +- offset += sublen; +- } +- +- return buffer; +- } +- +- default: +- throw expect("bytes", tag); +- } +- } +- +- /** +- * Reads a byte from the stream. +- */ +- public int readByte() +- throws IOException +- { +- if (_chunkLength > 0) { +- _chunkLength--; +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- return read(); +- } +- else if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'B': +- case BC_BINARY_CHUNK: +- { +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- +- int value = parseByte(); +- +- // special code so successive read byte won't +- // be read as a single object. +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- return value; +- } +- +- case 0x20: case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- { +- _isLastChunk = true; +- _chunkLength = tag - 0x20; +- +- int value = parseByte(); +- +- // special code so successive read byte won't +- // be read as a single object. +- if (_chunkLength == 0) +- _chunkLength = END_OF_DATA; +- +- return value; +- } +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- { +- _isLastChunk = true; +- _chunkLength = (tag - 0x34) * 256 + read(); +- +- int value = parseByte(); +- +- // special code so successive read byte won't +- // be read as a single object. +- if (_chunkLength == 0) +- _chunkLength = END_OF_DATA; +- +- return value; +- } +- +- default: +- throw expect("binary", tag); +- } +- } +- +- /** +- * Reads a byte array from the stream. +- */ +- public int readBytes(byte []buffer, int offset, int length) +- throws IOException +- { +- int readLength = 0; +- +- if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- else if (_chunkLength == 0) { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'B': +- case BC_BINARY_CHUNK: +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 0x20: case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- { +- _isLastChunk = true; +- _chunkLength = tag - 0x20; +- break; +- } +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- { +- _isLastChunk = true; +- _chunkLength = (tag - 0x34) * 256 + read(); +- break; +- } +- +- default: +- throw expect("binary", tag); +- } +- } +- +- while (length > 0) { +- if (_chunkLength > 0) { +- buffer[offset++] = (byte) read(); +- _chunkLength--; +- length--; +- readLength++; +- } +- else if (_isLastChunk) { +- if (readLength == 0) +- return -1; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- else { +- int tag = read(); +- +- switch (tag) { +- case 'B': +- case BC_BINARY_CHUNK: +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw expect("binary", tag); +- } +- } +- } +- +- if (readLength == 0) +- return -1; +- else if (_chunkLength > 0 || ! _isLastChunk) +- return readLength; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- +- /** +- * Reads an object from the input stream with an expected type. +- */ +- public Object readObject(Class cl) +- throws IOException +- { +- if (cl == null || cl == Object.class) +- return readObject(); +- +- int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'H': +- { +- Deserializer reader = findSerializerFactory().getDeserializer(cl); +- +- return reader.readMap(this); +- } +- +- case 'M': +- { +- String type = readType(); +- +- // hessian/3bb3 +- if ("".equals(type)) { +- Deserializer reader; +- reader = findSerializerFactory().getDeserializer(cl); +- +- return reader.readMap(this); +- } +- else { +- Deserializer reader; +- reader = findSerializerFactory().getObjectDeserializer(type, cl); +- +- return reader.readMap(this); +- } +- } +- +- case 'C': +- { +- readObjectDefinition(cl); +- +- return readObject(cl); +- } +- +- case 0x60: case 0x61: case 0x62: case 0x63: +- case 0x64: case 0x65: case 0x66: case 0x67: +- case 0x68: case 0x69: case 0x6a: case 0x6b: +- case 0x6c: case 0x6d: case 0x6e: case 0x6f: +- { +- int ref = tag - 0x60; +- int size = _classDefs.size(); +- +- if (ref < 0 || size <= ref) +- throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); +- +- ObjectDefinition def = _classDefs.get(ref); +- +- return readObjectInstance(cl, def); +- } +- +- case 'O': +- { +- int ref = readInt(); +- int size = _classDefs.size(); +- +- if (ref < 0 || size <= ref) +- throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); +- +- ObjectDefinition def = _classDefs.get(ref); +- +- return readObjectInstance(cl, def); +- } +- +- case BC_LIST_VARIABLE: +- { +- String type = readType(); +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(type, cl); +- +- Object v = reader.readList(this, -1); +- +- return v; +- } +- +- case BC_LIST_FIXED: +- { +- String type = readType(); +- int length = readInt(); +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(type, cl); +- +- Object v = reader.readLengthList(this, length); +- +- return v; +- } +- +- case 0x70: case 0x71: case 0x72: case 0x73: +- case 0x74: case 0x75: case 0x76: case 0x77: +- { +- int length = tag - 0x70; +- +- String type = readType(); +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(type, cl); +- +- Object v = reader.readLengthList(this, length); +- +- return v; +- } +- +- case BC_LIST_VARIABLE_UNTYPED: +- { +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(null, cl); +- +- Object v = reader.readList(this, -1); +- +- return v; +- } +- +- case BC_LIST_FIXED_UNTYPED: +- { +- int length = readInt(); +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(null, cl); +- +- Object v = reader.readLengthList(this, length); +- +- return v; +- } +- +- case 0x78: case 0x79: case 0x7a: case 0x7b: +- case 0x7c: case 0x7d: case 0x7e: case 0x7f: +- { +- int length = tag - 0x78; +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(null, cl); +- +- Object v = reader.readLengthList(this, length); +- +- return v; +- } +- +- case BC_REF: +- { +- int ref = readInt(); +- +- return _refs.get(ref); +- } +- } +- +- if (tag >= 0) +- _offset--; +- +- // hessian/3b2i vs hessian/3406 +- // return readObject(); +- Object value = findSerializerFactory().getDeserializer(cl).readObject(this); +- return value; +- } +- +- /** +- * Reads an arbitrary object from the input stream when the type +- * is unknown. +- */ +- public Object readObject() +- throws IOException +- { +- int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'T': +- return Boolean.valueOf(true); +- +- case 'F': +- return Boolean.valueOf(false); +- +- // direct integer +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- return Integer.valueOf(tag - BC_INT_ZERO); +- +- /* byte int */ +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc8: case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- return Integer.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); +- +- /* short int */ +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd4: case 0xd5: case 0xd6: case 0xd7: +- return Integer.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) +- + 256 * read() + read()); +- +- case 'I': +- return Integer.valueOf(parseInt()); +- +- // direct long +- case 0xd8: case 0xd9: case 0xda: case 0xdb: +- case 0xdc: case 0xdd: case 0xde: case 0xdf: +- +- case 0xe0: case 0xe1: case 0xe2: case 0xe3: +- case 0xe4: case 0xe5: case 0xe6: case 0xe7: +- case 0xe8: case 0xe9: case 0xea: case 0xeb: +- case 0xec: case 0xed: case 0xee: case 0xef: +- return Long.valueOf(tag - BC_LONG_ZERO); +- +- /* byte long */ +- case 0xf0: case 0xf1: case 0xf2: case 0xf3: +- case 0xf4: case 0xf5: case 0xf6: case 0xf7: +- case 0xf8: case 0xf9: case 0xfa: case 0xfb: +- case 0xfc: case 0xfd: case 0xfe: case 0xff: +- return Long.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); +- +- /* short long */ +- case 0x38: case 0x39: case 0x3a: case 0x3b: +- case 0x3c: case 0x3d: case 0x3e: case 0x3f: +- return Long.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read()); +- +- case BC_LONG_INT: +- return Long.valueOf(parseInt()); +- +- case 'L': +- return Long.valueOf(parseLong()); +- +- case BC_DOUBLE_ZERO: +- return Double.valueOf(0); +- +- case BC_DOUBLE_ONE: +- return Double.valueOf(1); +- +- case BC_DOUBLE_BYTE: +- return Double.valueOf((byte) read()); +- +- case BC_DOUBLE_SHORT: +- return Double.valueOf((short) (256 * read() + read())); +- +- case BC_DOUBLE_MILL: +- { +- int mills = parseInt(); +- +- return Double.valueOf(0.001 * mills); +- } +- +- case 'D': +- return Double.valueOf(parseDouble()); +- +- case BC_DATE: +- return new Date(parseLong()); +- +- case BC_DATE_MINUTE: +- return new Date(parseInt() * 60000L); +- +- case BC_STRING_CHUNK: +- case 'S': +- { +- _isLastChunk = tag == 'S'; +- _chunkLength = (read() << 8) + read(); +- +- _sbuf.setLength(0); +- +- parseString(_sbuf); +- +- return _sbuf.toString(); +- } +- +- case 0x00: case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- { +- _isLastChunk = true; +- _chunkLength = tag - 0x00; +- +- _sbuf.setLength(0); +- +- parseString(_sbuf); +- +- return _sbuf.toString(); +- } +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- { +- _isLastChunk = true; +- _chunkLength = (tag - 0x30) * 256 + read(); +- +- _sbuf.setLength(0); +- +- parseString(_sbuf); +- +- return _sbuf.toString(); +- } +- +- case BC_BINARY_CHUNK: +- case 'B': +- { +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- +- int data; +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- while ((data = parseByte()) >= 0) +- bos.write(data); +- +- return bos.toByteArray(); +- } +- +- case 0x20: case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- { +- _isLastChunk = true; +- int len = tag - 0x20; +- _chunkLength = 0; +- +- byte []data = new byte[len]; +- +- for (int i = 0; i < len; i++) +- data[i] = (byte) read(); +- +- return data; +- } +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- { +- _isLastChunk = true; +- int len = (tag - 0x34) * 256 + read(); +- _chunkLength = 0; +- +- byte []buffer = new byte[len]; +- +- for (int i = 0; i < len; i++) { +- buffer[i] = (byte) read(); +- } +- +- return buffer; +- } +- +- case BC_LIST_VARIABLE: +- { +- // variable length list +- String type = readType(); +- +- return findSerializerFactory().readList(this, -1, type); +- } +- +- case BC_LIST_VARIABLE_UNTYPED: +- { +- return findSerializerFactory().readList(this, -1, null); +- } +- +- case BC_LIST_FIXED: +- { +- // fixed length lists +- String type = readType(); +- int length = readInt(); +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(type, null); +- +- return reader.readLengthList(this, length); +- } +- +- case BC_LIST_FIXED_UNTYPED: +- { +- // fixed length lists +- int length = readInt(); +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(null, null); +- +- return reader.readLengthList(this, length); +- } +- +- // compact fixed list +- case 0x70: case 0x71: case 0x72: case 0x73: +- case 0x74: case 0x75: case 0x76: case 0x77: +- { +- // fixed length lists +- String type = readType(); +- int length = tag - 0x70; +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(type, null); +- +- return reader.readLengthList(this, length); +- } +- +- // compact fixed untyped list +- case 0x78: case 0x79: case 0x7a: case 0x7b: +- case 0x7c: case 0x7d: case 0x7e: case 0x7f: +- { +- // fixed length lists +- int length = tag - 0x78; +- +- Deserializer reader; +- reader = findSerializerFactory().getListDeserializer(null, null); +- +- return reader.readLengthList(this, length); +- } +- +- case 'H': +- { +- return findSerializerFactory().readMap(this, null); +- } +- +- case 'M': +- { +- String type = readType(); +- +- return findSerializerFactory().readMap(this, type); +- } +- +- case 'C': +- { +- readObjectDefinition(null); +- +- return readObject(); +- } +- +- case 0x60: case 0x61: case 0x62: case 0x63: +- case 0x64: case 0x65: case 0x66: case 0x67: +- case 0x68: case 0x69: case 0x6a: case 0x6b: +- case 0x6c: case 0x6d: case 0x6e: case 0x6f: +- { +- int ref = tag - 0x60; +- +- if (_classDefs.size() <= ref) +- throw error("No classes defined at reference '" +- + Integer.toHexString(tag) + "'"); +- +- ObjectDefinition def = _classDefs.get(ref); +- +- return readObjectInstance(null, def); +- } +- +- case 'O': +- { +- int ref = readInt(); +- +- if (_classDefs.size() <= ref) +- throw error("Illegal object reference #" + ref); +- +- ObjectDefinition def = _classDefs.get(ref); +- +- return readObjectInstance(null, def); +- } +- +- case BC_REF: +- { +- int ref = readInt(); +- +- return _refs.get(ref); +- } +- +- default: +- if (tag < 0) +- throw new EOFException("readObject: unexpected end of file"); +- else +- throw error("readObject: unknown code " + codeName(tag)); +- } +- } +- +- /** +- * Reads an object definition: +- * +- *
+-   * O string  (string)* *
+-   * 
+- */ +- private void readObjectDefinition(Class cl) +- throws IOException +- { +- String type = readString(); +- int len = readInt(); +- +- SerializerFactory factory = findSerializerFactory(); +- +- Deserializer reader = factory.getObjectDeserializer(type, null); +- +- Object []fields = reader.createFields(len); +- String []fieldNames = new String[len]; +- +- for (int i = 0; i < len; i++) { +- String name = readString(); +- +- fields[i] = reader.createField(name); +- fieldNames[i] = name; +- } +- +- ObjectDefinition def +- = new ObjectDefinition(type, reader, fields, fieldNames); +- +- _classDefs.add(def); +- } +- +- private Object readObjectInstance(Class cl, +- ObjectDefinition def) +- throws IOException +- { +- String type = def.getType(); +- Deserializer reader = def.getReader(); +- Object []fields = def.getFields(); +- +- SerializerFactory factory = findSerializerFactory(); +- +- if (cl != reader.getType() && cl != null) { +- reader = factory.getObjectDeserializer(type, cl); +- +- return reader.readObject(this, def.getFieldNames()); +- } +- else { +- return reader.readObject(this, fields); +- } +- } +- +- /** +- * Reads a remote object. +- */ +- public Object readRemote() +- throws IOException +- { +- String type = readType(); +- String url = readString(); +- +- return resolveRemote(type, url); +- } +- +- /** +- * Reads a reference. +- */ +- public Object readRef() +- throws IOException +- { +- int value = parseInt(); +- +- return _refs.get(value); +- } +- +- /** +- * Reads the start of a list. +- */ +- public int readListStart() +- throws IOException +- { +- return read(); +- } +- +- /** +- * Reads the start of a list. +- */ +- public int readMapStart() +- throws IOException +- { +- return read(); +- } +- +- /** +- * Returns true if this is the end of a list or a map. +- */ +- public boolean isEnd() +- throws IOException +- { +- int code; +- +- if (_offset < _length) +- code = (_buffer[_offset] & 0xff); +- else { +- code = read(); +- +- if (code >= 0) +- _offset--; +- } +- +- return (code < 0 || code == 'Z'); +- } +- +- /** +- * Reads the end byte. +- */ +- public void readEnd() +- throws IOException +- { +- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- if (code == 'Z') +- return; +- else if (code < 0) +- throw error("unexpected end of file"); +- else +- throw error("unknown code:" + codeName(code)); +- } +- +- /** +- * Reads the end byte. +- */ +- public void readMapEnd() +- throws IOException +- { +- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- if (code != 'Z') +- throw error("expected end of map ('Z') at '" + codeName(code) + "'"); +- } +- +- /** +- * Reads the end byte. +- */ +- public void readListEnd() +- throws IOException +- { +- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- if (code != 'Z') +- throw error("expected end of list ('Z') at '" + codeName(code) + "'"); +- } +- +- /** +- * Adds a list/map reference. +- */ +- @Override +- public int addRef(Object ref) +- { +- if (_refs == null) +- _refs = new ArrayList(); +- +- _refs.add(ref); +- +- return _refs.size() - 1; +- } +- +- /** +- * Adds a list/map reference. +- */ +- public void setRef(int i, Object ref) +- { +- _refs.set(i, ref); +- } +- +- /** +- * Resets the references for streaming. +- */ +- @Override +- public void resetReferences() +- { +- _refs.clear(); +- } +- +- public void reset() +- { +- resetReferences(); +- +- _classDefs.clear(); +- _types.clear(); +- } +- +- public void resetBuffer() +- { +- int offset = _offset; +- _offset = 0; +- +- int length = _length; +- _length = 0; +- +- if (length > 0 && offset != length) +- throw new IllegalStateException("offset=" + offset + " length=" + length); +- } +- +- public Object readStreamingObject() +- throws IOException +- { +- if (_refs != null) +- _refs.clear(); +- +- return readObject(); +- } +- +- /** +- * Resolves a remote object. +- */ +- public Object resolveRemote(String type, String url) +- throws IOException +- { +- HessianRemoteResolver resolver = getRemoteResolver(); +- +- if (resolver != null) +- return resolver.lookup(type, url); +- else +- return new HessianRemote(type, url); +- } +- +- /** +- * Parses a type from the stream. +- * +- *
+-   * type ::= string
+-   * type ::= int
+-   * 
+- */ +- public String readType() +- throws IOException +- { +- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- _offset--; +- +- switch (code) { +- case 0x00: case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- case BC_STRING_CHUNK: case 'S': +- { +- String type = readString(); +- +- if (_types == null) +- _types = new ArrayList(); +- +- _types.add(type); +- +- return type; +- } +- +- default: +- { +- int ref = readInt(); +- +- if (_types.size() <= ref) +- throw new IndexOutOfBoundsException("type ref #" + ref + " is greater than the number of valid types (" + _types.size() + ")"); +- +- return (String) _types.get(ref); +- } +- } +- } +- +- /** +- * Parses the length for an array +- * +- *
+-   * l b32 b24 b16 b8
+-   * 
+- */ +- public int readLength() +- throws IOException +- { +- throw new UnsupportedOperationException(); +- } +- +- /** +- * Parses a 32-bit integer value from the stream. +- * +- *
+-   * b32 b24 b16 b8
+-   * 
+- */ +- private int parseInt() +- throws IOException +- { +- int offset = _offset; +- +- if (offset + 3 < _length) { +- byte []buffer = _buffer; +- +- int b32 = buffer[offset + 0] & 0xff; +- int b24 = buffer[offset + 1] & 0xff; +- int b16 = buffer[offset + 2] & 0xff; +- int b8 = buffer[offset + 3] & 0xff; +- +- _offset = offset + 4; +- +- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; +- } +- else { +- int b32 = read(); +- int b24 = read(); +- int b16 = read(); +- int b8 = read(); +- +- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; +- } +- } +- +- /** +- * Parses a 64-bit long value from the stream. +- * +- *
+-   * b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- private long parseLong() +- throws IOException +- { +- long b64 = read(); +- long b56 = read(); +- long b48 = read(); +- long b40 = read(); +- long b32 = read(); +- long b24 = read(); +- long b16 = read(); +- long b8 = read(); +- +- return ((b64 << 56) +- + (b56 << 48) +- + (b48 << 40) +- + (b40 << 32) +- + (b32 << 24) +- + (b24 << 16) +- + (b16 << 8) +- + b8); +- } +- +- /** +- * Parses a 64-bit double value from the stream. +- * +- *
+-   * b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- private double parseDouble() +- throws IOException +- { +- long bits = parseLong(); +- +- return Double.longBitsToDouble(bits); +- } +- +- org.w3c.dom.Node parseXML() +- throws IOException +- { +- throw new UnsupportedOperationException(); +- } +- +- private void parseString(StringBuilder sbuf) +- throws IOException +- { +- while (true) { +- if (_chunkLength <= 0) { +- if (! parseChunkLength()) +- return; +- } +- +- int length = _chunkLength; +- _chunkLength = 0; +- +- while (length-- > 0) { +- sbuf.append((char) parseUTF8Char()); +- } +- } +- } +- +- /** +- * Reads a character from the underlying stream. +- */ +- private int parseChar() +- throws IOException +- { +- while (_chunkLength <= 0) { +- if (! parseChunkLength()) +- return -1; +- } +- +- _chunkLength--; +- +- return parseUTF8Char(); +- } +- +- private boolean parseChunkLength() +- throws IOException +- { +- if (_isLastChunk) +- return false; +- +- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- switch (code) { +- case BC_STRING_CHUNK: +- _isLastChunk = false; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 'S': +- _isLastChunk = true; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 0x00: case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- _isLastChunk = true; +- _chunkLength = code - 0x00; +- break; +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- _isLastChunk = true; +- _chunkLength = (code - 0x30) * 256 + read(); +- break; +- +- default: +- throw expect("string", code); +- } +- +- return true; +- } +- +- /** +- * Parses a single UTF8 character. +- */ +- private int parseUTF8Char() +- throws IOException +- { +- int ch = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); +- +- if (ch < 0x80) +- return ch; +- else if ((ch & 0xe0) == 0xc0) { +- int ch1 = read(); +- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); +- +- return v; +- } +- else if ((ch & 0xf0) == 0xe0) { +- int ch1 = read(); +- int ch2 = read(); +- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); +- +- return v; +- } +- else +- throw error("bad utf-8 encoding at " + codeName(ch)); +- } +- +- /** +- * Reads a byte from the underlying stream. +- */ +- private int parseByte() +- throws IOException +- { +- while (_chunkLength <= 0) { +- if (_isLastChunk) { +- return -1; +- } +- +- int code = read(); +- +- switch (code) { +- case BC_BINARY_CHUNK: +- _isLastChunk = false; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 'B': +- _isLastChunk = true; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 0x20: case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- _isLastChunk = true; +- +- _chunkLength = code - 0x20; +- break; +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- _isLastChunk = true; +- _chunkLength = (code - 0x34) * 256 + read(); +- break; +- +- default: +- throw expect("byte[]", code); +- } +- } +- +- _chunkLength--; +- +- return read(); +- } +- +- /** +- * Reads bytes based on an input stream. +- */ +- public InputStream readInputStream() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case BC_BINARY: +- case BC_BINARY_CHUNK: +- _isLastChunk = tag == BC_BINARY; +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 0x20: case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- _isLastChunk = true; +- _chunkLength = tag - 0x20; +- break; +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- _isLastChunk = true; +- _chunkLength = (tag - 0x34) * 256 + read(); +- break; +- +- default: +- throw expect("binary", tag); +- } +- +- return new ReadInputStream(); +- } +- +- /** +- * Reads bytes from the underlying stream. +- */ +- int read(byte []buffer, int offset, int length) +- throws IOException +- { +- int readLength = 0; +- +- while (length > 0) { +- while (_chunkLength <= 0) { +- if (_isLastChunk) +- return readLength == 0 ? -1 : readLength; +- +- int code = read(); +- +- switch (code) { +- case BC_BINARY_CHUNK: +- _isLastChunk = false; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case BC_BINARY: +- _isLastChunk = true; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 0x20: case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- _isLastChunk = true; +- _chunkLength = code - 0x20; +- break; +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- _isLastChunk = true; +- _chunkLength = (code - 0x34) * 256 + read(); +- break; +- +- default: +- throw expect("byte[]", code); +- } +- } +- +- int sublen = _chunkLength; +- if (length < sublen) +- sublen = length; +- +- if (_length <= _offset && ! readBuffer()) +- return -1; +- +- if (_length - _offset < sublen) +- sublen = _length - _offset; +- +- System.arraycopy(_buffer, _offset, buffer, offset, sublen); +- +- _offset += sublen; +- +- offset += sublen; +- readLength += sublen; +- length -= sublen; +- _chunkLength -= sublen; +- } +- +- return readLength; +- } +- +- /** +- * Normally, shouldn't be called externally, but needed for QA, e.g. +- * ejb/3b01. +- */ +- public final int read() +- throws IOException +- { +- if (_length <= _offset && ! readBuffer()) +- return -1; +- +- return _buffer[_offset++] & 0xff; +- } +- +- protected void unread() +- { +- if (_offset <= 0) +- throw new IllegalStateException(); +- +- _offset--; +- } +- +- private final boolean readBuffer() +- throws IOException +- { +- byte []buffer = _buffer; +- int offset = _offset; +- int length = _length; +- +- if (offset < length) { +- System.arraycopy(buffer, offset, buffer, 0, length - offset); +- offset = length - offset; +- } +- else +- offset = 0; +- +- int len = _is.read(buffer, offset, SIZE - offset); +- +- if (len <= 0) { +- _length = offset; +- _offset = 0; +- +- return offset > 0; +- } +- +- _length = offset + len; +- _offset = 0; +- +- return true; +- } +- +- public Reader getReader() +- { +- return null; +- } +- +- protected IOException expect(String expect, int ch) +- throws IOException +- { +- if (ch < 0) +- return error("expected " + expect + " at end of file"); +- else { +- _offset--; +- +- try { +- int offset = _offset; +- String context +- = buildDebugContext(_buffer, 0, _length, offset); +- +- Object obj = readObject(); +- +- if (obj != null) { +- return error("expected " + expect +- + " at 0x" + Integer.toHexString(ch & 0xff) +- + " " + obj.getClass().getName() + " (" + obj + ")" +- + "\n " + context + ""); +- } +- else +- return error("expected " + expect +- + " at 0x" + Integer.toHexString(ch & 0xff) + " null"); +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- +- return error("expected " + expect +- + " at 0x" + Integer.toHexString(ch & 0xff)); +- } +- } +- } +- +- private String buildDebugContext(byte []buffer, int offset, int length, +- int errorOffset) +- { +- StringBuilder sb = new StringBuilder(); +- +- sb.append("["); +- for (int i = 0; i < errorOffset; i++) { +- int ch = buffer[offset + i]; +- addDebugChar(sb, ch); +- } +- sb.append("] "); +- addDebugChar(sb, buffer[offset + errorOffset]); +- sb.append(" ["); +- for (int i = errorOffset + 1; i < length; i++) { +- int ch = buffer[offset + i]; +- addDebugChar(sb, ch); +- } +- sb.append("]"); +- +- return sb.toString(); +- } +- +- private void addDebugChar(StringBuilder sb, int ch) +- { +- if (ch >= 0x20 && ch < 0x7f) { +- sb.append((char) ch); +- } +- else if (ch == '\n') +- sb.append((char) ch); +- else +- sb.append(String.format("\\x%02x", ch & 0xff)); +- } +- +- protected String codeName(int ch) +- { +- if (ch < 0) +- return "end of file"; +- else +- return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; +- } +- +- protected IOException error(String message) +- { +- if (_method != null) +- return new HessianProtocolException(_method + ": " + message); +- else +- return new HessianProtocolException(message); +- } +- +- public void free() +- { +- reset(); +- } +- +- @Override +- public void close() +- throws IOException +- { +- InputStream is = _is; +- _is = null; +- +- if (_isCloseStreamOnClose && is != null) +- is.close(); +- } +- +- class ReadInputStream extends InputStream { +- boolean _isClosed = false; +- +- public int read() +- throws IOException +- { +- if (_isClosed) +- return -1; +- +- int ch = parseByte(); +- if (ch < 0) +- _isClosed = true; +- +- return ch; +- } +- +- public int read(byte []buffer, int offset, int length) +- throws IOException +- { +- if (_isClosed) +- return -1; +- +- int len = Hessian2Input.this.read(buffer, offset, length); +- if (len < 0) +- _isClosed = true; +- +- return len; +- } +- +- public void close() +- throws IOException +- { +- while (read() >= 0) { +- } +- } +- }; +- +- final static class ObjectDefinition { +- private final String _type; +- private final Deserializer _reader; +- private final Object []_fields; +- private final String []_fieldNames; +- +- ObjectDefinition(String type, +- Deserializer reader, +- Object []fields, +- String []fieldNames) +- { +- _type = type; +- _reader = reader; +- _fields = fields; +- _fieldNames = fieldNames; +- } +- +- String getType() +- { +- return _type; +- } +- +- Deserializer getReader() +- { +- return _reader; +- } +- +- Object []getFields() +- { +- return _fields; +- } +- +- String []getFieldNames() +- { +- return _fieldNames; +- } +- } +- +- private static Field getDetailMessageField() +- { +- if (_detailMessageField == null) { +- try { +- _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); +- _detailMessageField.setAccessible(true); +- } catch (Throwable e) { +- } +- } +- +- return _detailMessageField; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.*; ++import java.lang.reflect.Field; ++import java.util.ArrayList; ++import java.util.Date; ++import java.util.HashMap; ++import java.util.logging.*; ++ ++/** ++ * Input stream for Hessian requests. ++ * ++ *

HessianInput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * InputStream is = ...; // from http connection
++ * HessianInput in = new HessianInput(is);
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++public class Hessian2Input ++ extends AbstractHessianInput ++ implements Hessian2Constants ++{ ++ private static final Logger log ++ = Logger.getLogger(Hessian2Input.class.getName()); ++ ++ private static final int END_OF_DATA = -2; ++ ++ private static Field _detailMessageField; ++ ++ private static final int SIZE = 1024; ++ private static final int GAP = 16; ++ ++ // standard, unmodified factory for deserializing objects ++ protected SerializerFactory _defaultSerializerFactory; ++ // factory for deserializing objects in the input stream ++ protected SerializerFactory _serializerFactory; ++ ++ private static boolean _isCloseStreamOnClose; ++ ++ protected ArrayList _refs ++ = new ArrayList(); ++ protected ArrayList _classDefs ++ = new ArrayList(); ++ protected ArrayList _types ++ = new ArrayList(); ++ ++ // the underlying input stream ++ private InputStream _is; ++ private final byte []_buffer = new byte[SIZE]; ++ ++ // a peek character ++ private int _offset; ++ private int _length; ++ ++ // the method for a call ++ private String _method; ++ private Throwable _replyFault; ++ ++ private StringBuilder _sbuf = new StringBuilder(); ++ ++ // true if this is the last chunk ++ private boolean _isLastChunk; ++ // the chunk length ++ private int _chunkLength; ++ ++ private HessianDebugInputStream _dIs; ++ ++ public Hessian2Input() ++ { ++ if (log.isLoggable(Level.FINEST)) { ++ _dIs = new HessianDebugInputStream(log, Level.FINEST); ++ } ++ } ++ ++ /** ++ * Creates a new Hessian input stream, initialized with an ++ * underlying input stream. ++ * ++ * @param is the underlying input stream. ++ */ ++ public Hessian2Input(InputStream is) ++ { ++ this(); ++ ++ init(is); ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ // the default serializer factory cannot be modified by external ++ // callers ++ if (_serializerFactory == _defaultSerializerFactory) { ++ _serializerFactory = new SerializerFactory(); ++ } ++ ++ return _serializerFactory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ protected final SerializerFactory findSerializerFactory() ++ { ++ SerializerFactory factory = _serializerFactory; ++ ++ if (factory == null) { ++ factory = SerializerFactory.createDefault(); ++ _defaultSerializerFactory = factory; ++ _serializerFactory = factory; ++ } ++ ++ return factory; ++ } ++ ++ public void allow(String pattern) ++ { ++ ClassFactory factory = getSerializerFactory().getClassFactory(); ++ ++ factory.allow(pattern); ++ } ++ ++ public void setCloseStreamOnClose(boolean isClose) ++ { ++ _isCloseStreamOnClose = isClose; ++ } ++ ++ public boolean isCloseStreamOnClose() ++ { ++ return _isCloseStreamOnClose; ++ } ++ ++ /** ++ * Returns the calls method ++ */ ++ public String getMethod() ++ { ++ return _method; ++ } ++ ++ /** ++ * Returns any reply fault. ++ */ ++ public Throwable getReplyFault() ++ { ++ return _replyFault; ++ } ++ ++ @Override ++ public void init(InputStream is) ++ { ++ if (_dIs != null) { ++ _dIs.initPacket(is); ++ is = _dIs; ++ } ++ ++ _is = is; ++ ++ reset(); ++ } ++ ++ public void initPacket(InputStream is) ++ { ++ if (_dIs != null) { ++ _dIs.initPacket(is); ++ is = _dIs; ++ } ++ ++ _is = is; ++ ++ resetReferences(); ++ } ++ ++ /** ++ * Starts reading the call ++ * ++ *
++   * c major minor
++   * 
++ */ ++ public int readCall() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'C') ++ throw error("expected hessian call ('C') at " + codeName(tag)); ++ ++ return 0; ++ } ++ ++ /** ++ * Starts reading the envelope ++ * ++ *
++   * E major minor
++   * 
++ */ ++ public int readEnvelope() ++ throws IOException ++ { ++ int tag = read(); ++ int version = 0; ++ ++ if (tag == 'H') { ++ int major = read(); ++ int minor = read(); ++ ++ version = (major << 16) + minor; ++ ++ tag = read(); ++ } ++ ++ if (tag != 'E') ++ throw error("expected hessian Envelope ('E') at " + codeName(tag)); ++ ++ return version; ++ } ++ ++ /** ++ * Completes reading the envelope ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * Z
++   * 
++ */ ++ public void completeEnvelope() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'Z') ++ error("expected end of envelope at " + codeName(tag)); ++ } ++ ++ /** ++ * Starts reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * string
++   * 
++ */ ++ public String readMethod() ++ throws IOException ++ { ++ _method = readString(); ++ ++ return _method; ++ } ++ ++ /** ++ * Returns the number of method arguments ++ * ++ *
++   * int
++   * 
++ */ ++ @Override ++ public int readMethodArgLength() ++ throws IOException ++ { ++ return readInt(); ++ } ++ ++ /** ++ * Starts reading the call, including the headers. ++ * ++ *

The call expects the following protocol data ++ * ++ *

++   * c major minor
++   * m b16 b8 method
++   * 
++ */ ++ public void startCall() ++ throws IOException ++ { ++ readCall(); ++ ++ readMethod(); ++ } ++ ++ public Object []readArguments() ++ throws IOException ++ { ++ int len = readInt(); ++ ++ Object []args = new Object[len]; ++ ++ for (int i = 0; i < len; i++) ++ args[i] = readObject(); ++ ++ return args; ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ } ++ ++ /** ++ * Reads a reply as an object. ++ * If the reply has a fault, throws the exception. ++ */ ++ @Override ++ public Object readReply(Class expectedClass) ++ throws Throwable ++ { ++ int tag = read(); ++ ++ if (tag == 'R') ++ return readObject(expectedClass); ++ else if (tag == 'F') { ++ HashMap map = (HashMap) readObject(HashMap.class); ++ ++ throw prepareFault(map); ++ } ++ else { ++ StringBuilder sb = new StringBuilder(); ++ sb.append((char) tag); ++ ++ try { ++ int ch; ++ ++ while ((ch = read()) >= 0) { ++ sb.append((char) ch); ++ } ++ } catch (IOException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ throw error("expected hessian reply at " + codeName(tag) + "\n" ++ + sb); ++ } ++ } ++ ++ /** ++ * Starts reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * r
++   * 
++ */ ++ public void startReply() ++ throws Throwable ++ { ++ // XXX: for variable length (?) ++ ++ readReply(Object.class); ++ } ++ ++ /** ++ * Prepares the fault. ++ */ ++ private Throwable prepareFault(HashMap fault) ++ throws IOException ++ { ++ Object detail = fault.get("detail"); ++ String message = (String) fault.get("message"); ++ ++ if (detail instanceof Throwable) { ++ _replyFault = (Throwable) detail; ++ ++ Field detailMessageField = getDetailMessageField(); ++ ++ if (message != null && detailMessageField != null) { ++ try { ++ detailMessageField.set(_replyFault, message); ++ } catch (Throwable e) { ++ } ++ } ++ ++ return _replyFault; ++ } ++ ++ else { ++ String code = (String) fault.get("code"); ++ ++ _replyFault = new HessianServiceException(message, code, detail); ++ ++ return _replyFault; ++ } ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeReply() ++ throws IOException ++ { ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeValueReply() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'Z') ++ error("expected end of reply at " + codeName(tag)); ++ } ++ ++ /** ++ * Reads a header, returning null if there are no headers. ++ * ++ *
++   * H b16 b8 value
++   * 
++ */ ++ public String readHeader() ++ throws IOException ++ { ++ return null; ++ } ++ ++ /** ++ * Starts reading a packet ++ * ++ *
++   * p major minor
++   * 
++ */ ++ public int startMessage() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag == 'p') { ++ } else if (tag == 'P') { ++ } else ++ throw error("expected Hessian message ('p') at " + codeName(tag)); ++ ++ int major = read(); ++ int minor = read(); ++ ++ return (major << 16) + minor; ++ } ++ ++ /** ++ * Completes reading the message ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeMessage() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'Z') ++ error("expected end of message at " + codeName(tag)); ++ } ++ ++ /** ++ * Reads a null ++ * ++ *
++   * N
++   * 
++ */ ++ public void readNull() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': return; ++ ++ default: ++ throw expect("null", tag); ++ } ++ } ++ ++ /** ++ * Reads a boolean ++ * ++ *
++   * T
++   * F
++   * 
++ */ ++ public boolean readBoolean() ++ throws IOException ++ { ++ int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ switch (tag) { ++ case 'T': return true; ++ case 'F': return false; ++ ++ // direct integer ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ return tag != BC_INT_ZERO; ++ ++ // INT_BYTE = 0 ++ case 0xc8: ++ return read() != 0; ++ ++ // INT_BYTE != 0 ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ read(); ++ return true; ++ ++ // INT_SHORT = 0 ++ case 0xd4: ++ return (256 * read() + read()) != 0; ++ ++ // INT_SHORT != 0 ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd5: case 0xd6: case 0xd7: ++ read(); ++ read(); ++ return true; ++ ++ case 'I': return ++ parseInt() != 0; ++ ++ case 0xd8: case 0xd9: case 0xda: case 0xdb: ++ case 0xdc: case 0xdd: case 0xde: case 0xdf: ++ ++ case 0xe0: case 0xe1: case 0xe2: case 0xe3: ++ case 0xe4: case 0xe5: case 0xe6: case 0xe7: ++ case 0xe8: case 0xe9: case 0xea: case 0xeb: ++ case 0xec: case 0xed: case 0xee: case 0xef: ++ return tag != BC_LONG_ZERO; ++ ++ // LONG_BYTE = 0 ++ case 0xf8: ++ return read() != 0; ++ ++ // LONG_BYTE != 0 ++ case 0xf0: case 0xf1: case 0xf2: case 0xf3: ++ case 0xf4: case 0xf5: case 0xf6: case 0xf7: ++ case 0xf9: case 0xfa: case 0xfb: ++ case 0xfc: case 0xfd: case 0xfe: case 0xff: ++ read(); ++ return true; ++ ++ // INT_SHORT = 0 ++ case 0x3c: ++ return (256 * read() + read()) != 0; ++ ++ // INT_SHORT != 0 ++ case 0x38: case 0x39: case 0x3a: case 0x3b: ++ case 0x3d: case 0x3e: case 0x3f: ++ read(); ++ read(); ++ return true; ++ ++ case BC_LONG_INT: ++ return (0x1000000L * read() ++ + 0x10000L * read() ++ + 0x100 * read() ++ + read()) != 0; ++ ++ case 'L': ++ return parseLong() != 0; ++ ++ case BC_DOUBLE_ZERO: ++ return false; ++ ++ case BC_DOUBLE_ONE: ++ return true; ++ ++ case BC_DOUBLE_BYTE: ++ return read() != 0; ++ ++ case BC_DOUBLE_SHORT: ++ return (0x100 * read() + read()) != 0; ++ ++ case BC_DOUBLE_MILL: ++ { ++ int mills = parseInt(); ++ ++ return mills != 0; ++ } ++ ++ case 'D': ++ return parseDouble() != 0.0; ++ ++ case 'N': ++ return false; ++ ++ default: ++ throw expect("boolean", tag); ++ } ++ } ++ ++ /** ++ * Reads a short ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ */ ++ public short readShort() ++ throws IOException ++ { ++ return (short) readInt(); ++ } ++ ++ /** ++ * Reads an integer ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ */ ++ public final int readInt() ++ throws IOException ++ { ++ //int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return 0; ++ ++ case 'F': ++ return 0; ++ ++ case 'T': ++ return 1; ++ ++ // direct integer ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ return tag - BC_INT_ZERO; ++ ++ /* byte int */ ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc8: case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); ++ ++ /* short int */ ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd4: case 0xd5: case 0xd6: case 0xd7: ++ return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); ++ ++ case 'I': ++ case BC_LONG_INT: ++ return ((read() << 24) ++ + (read() << 16) ++ + (read() << 8) ++ + read()); ++ ++ // direct long ++ case 0xd8: case 0xd9: case 0xda: case 0xdb: ++ case 0xdc: case 0xdd: case 0xde: case 0xdf: ++ ++ case 0xe0: case 0xe1: case 0xe2: case 0xe3: ++ case 0xe4: case 0xe5: case 0xe6: case 0xe7: ++ case 0xe8: case 0xe9: case 0xea: case 0xeb: ++ case 0xec: case 0xed: case 0xee: case 0xef: ++ return tag - BC_LONG_ZERO; ++ ++ /* byte long */ ++ case 0xf0: case 0xf1: case 0xf2: case 0xf3: ++ case 0xf4: case 0xf5: case 0xf6: case 0xf7: ++ case 0xf8: case 0xf9: case 0xfa: case 0xfb: ++ case 0xfc: case 0xfd: case 0xfe: case 0xff: ++ return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); ++ ++ /* short long */ ++ case 0x38: case 0x39: case 0x3a: case 0x3b: ++ case 0x3c: case 0x3d: case 0x3e: case 0x3f: ++ return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); ++ ++ case 'L': ++ return (int) parseLong(); ++ ++ case BC_DOUBLE_ZERO: ++ return 0; ++ ++ case BC_DOUBLE_ONE: ++ return 1; ++ ++ //case LONG_BYTE: ++ case BC_DOUBLE_BYTE: ++ return (byte) (_offset < _length ? _buffer[_offset++] : read()); ++ ++ //case INT_SHORT: ++ //case LONG_SHORT: ++ case BC_DOUBLE_SHORT: ++ return (short) (256 * read() + read()); ++ ++ case BC_DOUBLE_MILL: ++ { ++ int mills = parseInt(); ++ ++ return (int) (0.001 * mills); ++ } ++ ++ case 'D': ++ return (int) parseDouble(); ++ ++ default: ++ throw expect("integer", tag); ++ } ++ } ++ ++ /** ++ * Reads a long ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public long readLong() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return 0; ++ ++ case 'F': ++ return 0; ++ ++ case 'T': ++ return 1; ++ ++ // direct integer ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ return tag - BC_INT_ZERO; ++ ++ /* byte int */ ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc8: case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); ++ ++ /* short int */ ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd4: case 0xd5: case 0xd6: case 0xd7: ++ return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); ++ ++ //case LONG_BYTE: ++ case BC_DOUBLE_BYTE: ++ return (byte) (_offset < _length ? _buffer[_offset++] : read()); ++ ++ //case INT_SHORT: ++ //case LONG_SHORT: ++ case BC_DOUBLE_SHORT: ++ return (short) (256 * read() + read()); ++ ++ case 'I': ++ case BC_LONG_INT: ++ return parseInt(); ++ ++ // direct long ++ case 0xd8: case 0xd9: case 0xda: case 0xdb: ++ case 0xdc: case 0xdd: case 0xde: case 0xdf: ++ ++ case 0xe0: case 0xe1: case 0xe2: case 0xe3: ++ case 0xe4: case 0xe5: case 0xe6: case 0xe7: ++ case 0xe8: case 0xe9: case 0xea: case 0xeb: ++ case 0xec: case 0xed: case 0xee: case 0xef: ++ return tag - BC_LONG_ZERO; ++ ++ /* byte long */ ++ case 0xf0: case 0xf1: case 0xf2: case 0xf3: ++ case 0xf4: case 0xf5: case 0xf6: case 0xf7: ++ case 0xf8: case 0xf9: case 0xfa: case 0xfb: ++ case 0xfc: case 0xfd: case 0xfe: case 0xff: ++ return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); ++ ++ /* short long */ ++ case 0x38: case 0x39: case 0x3a: case 0x3b: ++ case 0x3c: case 0x3d: case 0x3e: case 0x3f: ++ return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); ++ ++ case 'L': ++ return parseLong(); ++ ++ case BC_DOUBLE_ZERO: ++ return 0; ++ ++ case BC_DOUBLE_ONE: ++ return 1; ++ ++ case BC_DOUBLE_MILL: ++ { ++ int mills = parseInt(); ++ ++ return (long) (0.001 * mills); ++ } ++ ++ case 'D': ++ return (long) parseDouble(); ++ ++ default: ++ throw expect("long", tag); ++ } ++ } ++ ++ /** ++ * Reads a float ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public float readFloat() ++ throws IOException ++ { ++ return (float) readDouble(); ++ } ++ ++ /** ++ * Reads a double ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public double readDouble() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return 0; ++ ++ case 'F': ++ return 0; ++ ++ case 'T': ++ return 1; ++ ++ // direct integer ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ return tag - 0x90; ++ ++ /* byte int */ ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc8: case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); ++ ++ /* short int */ ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd4: case 0xd5: case 0xd6: case 0xd7: ++ return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); ++ ++ case 'I': ++ case BC_LONG_INT: ++ return parseInt(); ++ ++ // direct long ++ case 0xd8: case 0xd9: case 0xda: case 0xdb: ++ case 0xdc: case 0xdd: case 0xde: case 0xdf: ++ ++ case 0xe0: case 0xe1: case 0xe2: case 0xe3: ++ case 0xe4: case 0xe5: case 0xe6: case 0xe7: ++ case 0xe8: case 0xe9: case 0xea: case 0xeb: ++ case 0xec: case 0xed: case 0xee: case 0xef: ++ return tag - BC_LONG_ZERO; ++ ++ /* byte long */ ++ case 0xf0: case 0xf1: case 0xf2: case 0xf3: ++ case 0xf4: case 0xf5: case 0xf6: case 0xf7: ++ case 0xf8: case 0xf9: case 0xfa: case 0xfb: ++ case 0xfc: case 0xfd: case 0xfe: case 0xff: ++ return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); ++ ++ /* short long */ ++ case 0x38: case 0x39: case 0x3a: case 0x3b: ++ case 0x3c: case 0x3d: case 0x3e: case 0x3f: ++ return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); ++ ++ case 'L': ++ return (double) parseLong(); ++ ++ case BC_DOUBLE_ZERO: ++ return 0; ++ ++ case BC_DOUBLE_ONE: ++ return 1; ++ ++ case BC_DOUBLE_BYTE: ++ return (byte) (_offset < _length ? _buffer[_offset++] : read()); ++ ++ case BC_DOUBLE_SHORT: ++ return (short) (256 * read() + read()); ++ ++ case BC_DOUBLE_MILL: ++ { ++ int mills = parseInt(); ++ ++ return 0.001 * mills; ++ } ++ ++ case 'D': ++ return parseDouble(); ++ ++ default: ++ throw expect("double", tag); ++ } ++ } ++ ++ /** ++ * Reads a date. ++ * ++ *
++   * T b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public long readUTCDate() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag == BC_DATE) { ++ return parseLong(); ++ } ++ else if (tag == BC_DATE_MINUTE) { ++ return parseInt() * 60000L; ++ } ++ else ++ throw expect("date", tag); ++ } ++ ++ /** ++ * Reads a byte from the stream. ++ */ ++ public int readChar() ++ throws IOException ++ { ++ if (_chunkLength > 0) { ++ _chunkLength--; ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ int ch = parseUTF8Char(); ++ return ch; ++ } ++ else if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'S': ++ case BC_STRING_CHUNK: ++ _isLastChunk = tag == 'S'; ++ _chunkLength = (read() << 8) + read(); ++ ++ _chunkLength--; ++ int value = parseUTF8Char(); ++ ++ // special code so successive read byte won't ++ // be read as a single object. ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ return value; ++ ++ default: ++ throw expect("char", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte array from the stream. ++ */ ++ public int readString(char []buffer, int offset, int length) ++ throws IOException ++ { ++ int readLength = 0; ++ ++ if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ else if (_chunkLength == 0) { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'S': ++ case BC_STRING_CHUNK: ++ _isLastChunk = tag == 'S'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 0x00: case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ _isLastChunk = true; ++ _chunkLength = tag - 0x00; ++ break; ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x30) * 256 + read(); ++ break; ++ ++ default: ++ throw expect("string", tag); ++ } ++ } ++ ++ while (length > 0) { ++ if (_chunkLength > 0) { ++ buffer[offset++] = (char) parseUTF8Char(); ++ _chunkLength--; ++ length--; ++ readLength++; ++ } ++ else if (_isLastChunk) { ++ if (readLength == 0) ++ return -1; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ else { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'S': ++ case BC_STRING_CHUNK: ++ _isLastChunk = tag == 'S'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 0x00: case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ _isLastChunk = true; ++ _chunkLength = tag - 0x00; ++ break; ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x30) * 256 + read(); ++ break; ++ ++ default: ++ throw expect("string", tag); ++ } ++ } ++ } ++ ++ if (readLength == 0) ++ return -1; ++ else if (_chunkLength > 0 || ! _isLastChunk) ++ return readLength; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ ++ /** ++ * Reads a string ++ * ++ *
++   * S b16 b8 string value
++   * 
++ */ ++ public String readString() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ case 'T': ++ return "true"; ++ case 'F': ++ return "false"; ++ ++ // direct integer ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ return String.valueOf((tag - 0x90)); ++ ++ /* byte int */ ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc8: case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ return String.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); ++ ++ /* short int */ ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd4: case 0xd5: case 0xd6: case 0xd7: ++ return String.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) ++ + 256 * read() + read()); ++ ++ case 'I': ++ case BC_LONG_INT: ++ return String.valueOf(parseInt()); ++ ++ // direct long ++ case 0xd8: case 0xd9: case 0xda: case 0xdb: ++ case 0xdc: case 0xdd: case 0xde: case 0xdf: ++ ++ case 0xe0: case 0xe1: case 0xe2: case 0xe3: ++ case 0xe4: case 0xe5: case 0xe6: case 0xe7: ++ case 0xe8: case 0xe9: case 0xea: case 0xeb: ++ case 0xec: case 0xed: case 0xee: case 0xef: ++ return String.valueOf(tag - BC_LONG_ZERO); ++ ++ /* byte long */ ++ case 0xf0: case 0xf1: case 0xf2: case 0xf3: ++ case 0xf4: case 0xf5: case 0xf6: case 0xf7: ++ case 0xf8: case 0xf9: case 0xfa: case 0xfb: ++ case 0xfc: case 0xfd: case 0xfe: case 0xff: ++ return String.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); ++ ++ /* short long */ ++ case 0x38: case 0x39: case 0x3a: case 0x3b: ++ case 0x3c: case 0x3d: case 0x3e: case 0x3f: ++ return String.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) ++ + 256 * read() + read()); ++ ++ case 'L': ++ return String.valueOf(parseLong()); ++ ++ case BC_DOUBLE_ZERO: ++ return "0.0"; ++ ++ case BC_DOUBLE_ONE: ++ return "1.0"; ++ ++ case BC_DOUBLE_BYTE: ++ return String.valueOf((byte) (_offset < _length ++ ? _buffer[_offset++] ++ : read())); ++ ++ case BC_DOUBLE_SHORT: ++ return String.valueOf(((short) (256 * read() + read()))); ++ ++ case BC_DOUBLE_MILL: ++ { ++ int mills = parseInt(); ++ ++ return String.valueOf(0.001 * mills); ++ } ++ ++ case 'D': ++ return String.valueOf(parseDouble()); ++ ++ case 'S': ++ case BC_STRING_CHUNK: ++ _isLastChunk = tag == 'S'; ++ _chunkLength = (read() << 8) + read(); ++ ++ _sbuf.setLength(0); ++ int ch; ++ ++ while ((ch = parseChar()) >= 0) ++ _sbuf.append((char) ch); ++ ++ return _sbuf.toString(); ++ ++ // 0-byte string ++ case 0x00: case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ _isLastChunk = true; ++ _chunkLength = tag - 0x00; ++ ++ _sbuf.setLength(0); ++ ++ while ((ch = parseChar()) >= 0) { ++ _sbuf.append((char) ch); ++ } ++ ++ return _sbuf.toString(); ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x30) * 256 + read(); ++ ++ _sbuf.setLength(0); ++ ++ while ((ch = parseChar()) >= 0) ++ _sbuf.append((char) ch); ++ ++ return _sbuf.toString(); ++ ++ default: ++ throw expect("string", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte array ++ * ++ *
++   * B b16 b8 data value
++   * 
++ */ ++ public byte []readBytes() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case BC_BINARY: ++ case BC_BINARY_CHUNK: ++ _isLastChunk = tag == BC_BINARY; ++ _chunkLength = (read() << 8) + read(); ++ ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ int data; ++ while ((data = parseByte()) >= 0) ++ bos.write(data); ++ ++ return bos.toByteArray(); ++ ++ case 0x20: case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ { ++ _isLastChunk = true; ++ _chunkLength = tag - 0x20; ++ ++ byte []buffer = new byte[_chunkLength]; ++ ++ int offset = 0; ++ while (offset < _chunkLength) { ++ int sublen = read(buffer, 0, _chunkLength - offset); ++ ++ if (sublen <= 0) ++ break; ++ ++ offset += sublen; ++ } ++ ++ return buffer; ++ } ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ { ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x34) * 256 + read(); ++ ++ byte []buffer = new byte[_chunkLength]; ++ ++ int offset = 0; ++ while (offset < _chunkLength) { ++ int sublen = read(buffer, 0, _chunkLength - offset); ++ ++ if (sublen <= 0) ++ break; ++ ++ offset += sublen; ++ } ++ ++ return buffer; ++ } ++ ++ default: ++ throw expect("bytes", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte from the stream. ++ */ ++ public int readByte() ++ throws IOException ++ { ++ if (_chunkLength > 0) { ++ _chunkLength--; ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ return read(); ++ } ++ else if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'B': ++ case BC_BINARY_CHUNK: ++ { ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ ++ int value = parseByte(); ++ ++ // special code so successive read byte won't ++ // be read as a single object. ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ return value; ++ } ++ ++ case 0x20: case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ { ++ _isLastChunk = true; ++ _chunkLength = tag - 0x20; ++ ++ int value = parseByte(); ++ ++ // special code so successive read byte won't ++ // be read as a single object. ++ if (_chunkLength == 0) ++ _chunkLength = END_OF_DATA; ++ ++ return value; ++ } ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ { ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x34) * 256 + read(); ++ ++ int value = parseByte(); ++ ++ // special code so successive read byte won't ++ // be read as a single object. ++ if (_chunkLength == 0) ++ _chunkLength = END_OF_DATA; ++ ++ return value; ++ } ++ ++ default: ++ throw expect("binary", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte array from the stream. ++ */ ++ public int readBytes(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ int readLength = 0; ++ ++ if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ else if (_chunkLength == 0) { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'B': ++ case BC_BINARY_CHUNK: ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 0x20: case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ { ++ _isLastChunk = true; ++ _chunkLength = tag - 0x20; ++ break; ++ } ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ { ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x34) * 256 + read(); ++ break; ++ } ++ ++ default: ++ throw expect("binary", tag); ++ } ++ } ++ ++ while (length > 0) { ++ if (_chunkLength > 0) { ++ buffer[offset++] = (byte) read(); ++ _chunkLength--; ++ length--; ++ readLength++; ++ } ++ else if (_isLastChunk) { ++ if (readLength == 0) ++ return -1; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ else { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'B': ++ case BC_BINARY_CHUNK: ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw expect("binary", tag); ++ } ++ } ++ } ++ ++ if (readLength == 0) ++ return -1; ++ else if (_chunkLength > 0 || ! _isLastChunk) ++ return readLength; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ ++ /** ++ * Reads an object from the input stream with an expected type. ++ */ ++ public Object readObject(Class cl) ++ throws IOException ++ { ++ if (cl == null || cl == Object.class) ++ return readObject(); ++ ++ int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'H': ++ { ++ Deserializer reader = findSerializerFactory().getDeserializer(cl); ++ ++ return reader.readMap(this); ++ } ++ ++ case 'M': ++ { ++ String type = readType(); ++ ++ // hessian/3bb3 ++ if ("".equals(type)) { ++ Deserializer reader; ++ reader = findSerializerFactory().getDeserializer(cl); ++ ++ return reader.readMap(this); ++ } ++ else { ++ Deserializer reader; ++ reader = findSerializerFactory().getObjectDeserializer(type, cl); ++ ++ return reader.readMap(this); ++ } ++ } ++ ++ case 'C': ++ { ++ readObjectDefinition(cl); ++ ++ return readObject(cl); ++ } ++ ++ case 0x60: case 0x61: case 0x62: case 0x63: ++ case 0x64: case 0x65: case 0x66: case 0x67: ++ case 0x68: case 0x69: case 0x6a: case 0x6b: ++ case 0x6c: case 0x6d: case 0x6e: case 0x6f: ++ { ++ int ref = tag - 0x60; ++ int size = _classDefs.size(); ++ ++ if (ref < 0 || size <= ref) ++ throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); ++ ++ ObjectDefinition def = _classDefs.get(ref); ++ ++ return readObjectInstance(cl, def); ++ } ++ ++ case 'O': ++ { ++ int ref = readInt(); ++ int size = _classDefs.size(); ++ ++ if (ref < 0 || size <= ref) ++ throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); ++ ++ ObjectDefinition def = _classDefs.get(ref); ++ ++ return readObjectInstance(cl, def); ++ } ++ ++ case BC_LIST_VARIABLE: ++ { ++ String type = readType(); ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(type, cl); ++ ++ Object v = reader.readList(this, -1); ++ ++ return v; ++ } ++ ++ case BC_LIST_FIXED: ++ { ++ String type = readType(); ++ int length = readInt(); ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(type, cl); ++ ++ Object v = reader.readLengthList(this, length); ++ ++ return v; ++ } ++ ++ case 0x70: case 0x71: case 0x72: case 0x73: ++ case 0x74: case 0x75: case 0x76: case 0x77: ++ { ++ int length = tag - 0x70; ++ ++ String type = readType(); ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(type, cl); ++ ++ Object v = reader.readLengthList(this, length); ++ ++ return v; ++ } ++ ++ case BC_LIST_VARIABLE_UNTYPED: ++ { ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(null, cl); ++ ++ Object v = reader.readList(this, -1); ++ ++ return v; ++ } ++ ++ case BC_LIST_FIXED_UNTYPED: ++ { ++ int length = readInt(); ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(null, cl); ++ ++ Object v = reader.readLengthList(this, length); ++ ++ return v; ++ } ++ ++ case 0x78: case 0x79: case 0x7a: case 0x7b: ++ case 0x7c: case 0x7d: case 0x7e: case 0x7f: ++ { ++ int length = tag - 0x78; ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(null, cl); ++ ++ Object v = reader.readLengthList(this, length); ++ ++ return v; ++ } ++ ++ case BC_REF: ++ { ++ int ref = readInt(); ++ ++ return _refs.get(ref); ++ } ++ } ++ ++ if (tag >= 0) ++ _offset--; ++ ++ // hessian/3b2i vs hessian/3406 ++ // return readObject(); ++ Object value = findSerializerFactory().getDeserializer(cl).readObject(this); ++ return value; ++ } ++ ++ /** ++ * Reads an arbitrary object from the input stream when the type ++ * is unknown. ++ */ ++ public Object readObject() ++ throws IOException ++ { ++ int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'T': ++ return Boolean.valueOf(true); ++ ++ case 'F': ++ return Boolean.valueOf(false); ++ ++ // direct integer ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ return Integer.valueOf(tag - BC_INT_ZERO); ++ ++ /* byte int */ ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc8: case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ return Integer.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); ++ ++ /* short int */ ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd4: case 0xd5: case 0xd6: case 0xd7: ++ return Integer.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) ++ + 256 * read() + read()); ++ ++ case 'I': ++ return Integer.valueOf(parseInt()); ++ ++ // direct long ++ case 0xd8: case 0xd9: case 0xda: case 0xdb: ++ case 0xdc: case 0xdd: case 0xde: case 0xdf: ++ ++ case 0xe0: case 0xe1: case 0xe2: case 0xe3: ++ case 0xe4: case 0xe5: case 0xe6: case 0xe7: ++ case 0xe8: case 0xe9: case 0xea: case 0xeb: ++ case 0xec: case 0xed: case 0xee: case 0xef: ++ return Long.valueOf(tag - BC_LONG_ZERO); ++ ++ /* byte long */ ++ case 0xf0: case 0xf1: case 0xf2: case 0xf3: ++ case 0xf4: case 0xf5: case 0xf6: case 0xf7: ++ case 0xf8: case 0xf9: case 0xfa: case 0xfb: ++ case 0xfc: case 0xfd: case 0xfe: case 0xff: ++ return Long.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); ++ ++ /* short long */ ++ case 0x38: case 0x39: case 0x3a: case 0x3b: ++ case 0x3c: case 0x3d: case 0x3e: case 0x3f: ++ return Long.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read()); ++ ++ case BC_LONG_INT: ++ return Long.valueOf(parseInt()); ++ ++ case 'L': ++ return Long.valueOf(parseLong()); ++ ++ case BC_DOUBLE_ZERO: ++ return Double.valueOf(0); ++ ++ case BC_DOUBLE_ONE: ++ return Double.valueOf(1); ++ ++ case BC_DOUBLE_BYTE: ++ return Double.valueOf((byte) read()); ++ ++ case BC_DOUBLE_SHORT: ++ return Double.valueOf((short) (256 * read() + read())); ++ ++ case BC_DOUBLE_MILL: ++ { ++ int mills = parseInt(); ++ ++ return Double.valueOf(0.001 * mills); ++ } ++ ++ case 'D': ++ return Double.valueOf(parseDouble()); ++ ++ case BC_DATE: ++ return new Date(parseLong()); ++ ++ case BC_DATE_MINUTE: ++ return new Date(parseInt() * 60000L); ++ ++ case BC_STRING_CHUNK: ++ case 'S': ++ { ++ _isLastChunk = tag == 'S'; ++ _chunkLength = (read() << 8) + read(); ++ ++ _sbuf.setLength(0); ++ ++ parseString(_sbuf); ++ ++ return _sbuf.toString(); ++ } ++ ++ case 0x00: case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ { ++ _isLastChunk = true; ++ _chunkLength = tag - 0x00; ++ ++ _sbuf.setLength(0); ++ ++ parseString(_sbuf); ++ ++ return _sbuf.toString(); ++ } ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ { ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x30) * 256 + read(); ++ ++ _sbuf.setLength(0); ++ ++ parseString(_sbuf); ++ ++ return _sbuf.toString(); ++ } ++ ++ case BC_BINARY_CHUNK: ++ case 'B': ++ { ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ ++ int data; ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ while ((data = parseByte()) >= 0) ++ bos.write(data); ++ ++ return bos.toByteArray(); ++ } ++ ++ case 0x20: case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ { ++ _isLastChunk = true; ++ int len = tag - 0x20; ++ _chunkLength = 0; ++ ++ byte []data = new byte[len]; ++ ++ for (int i = 0; i < len; i++) ++ data[i] = (byte) read(); ++ ++ return data; ++ } ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ { ++ _isLastChunk = true; ++ int len = (tag - 0x34) * 256 + read(); ++ _chunkLength = 0; ++ ++ byte []buffer = new byte[len]; ++ ++ for (int i = 0; i < len; i++) { ++ buffer[i] = (byte) read(); ++ } ++ ++ return buffer; ++ } ++ ++ case BC_LIST_VARIABLE: ++ { ++ // variable length list ++ String type = readType(); ++ ++ return findSerializerFactory().readList(this, -1, type); ++ } ++ ++ case BC_LIST_VARIABLE_UNTYPED: ++ { ++ return findSerializerFactory().readList(this, -1, null); ++ } ++ ++ case BC_LIST_FIXED: ++ { ++ // fixed length lists ++ String type = readType(); ++ int length = readInt(); ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(type, null); ++ ++ return reader.readLengthList(this, length); ++ } ++ ++ case BC_LIST_FIXED_UNTYPED: ++ { ++ // fixed length lists ++ int length = readInt(); ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(null, null); ++ ++ return reader.readLengthList(this, length); ++ } ++ ++ // compact fixed list ++ case 0x70: case 0x71: case 0x72: case 0x73: ++ case 0x74: case 0x75: case 0x76: case 0x77: ++ { ++ // fixed length lists ++ String type = readType(); ++ int length = tag - 0x70; ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(type, null); ++ ++ return reader.readLengthList(this, length); ++ } ++ ++ // compact fixed untyped list ++ case 0x78: case 0x79: case 0x7a: case 0x7b: ++ case 0x7c: case 0x7d: case 0x7e: case 0x7f: ++ { ++ // fixed length lists ++ int length = tag - 0x78; ++ ++ Deserializer reader; ++ reader = findSerializerFactory().getListDeserializer(null, null); ++ ++ return reader.readLengthList(this, length); ++ } ++ ++ case 'H': ++ { ++ return findSerializerFactory().readMap(this, null); ++ } ++ ++ case 'M': ++ { ++ String type = readType(); ++ ++ return findSerializerFactory().readMap(this, type); ++ } ++ ++ case 'C': ++ { ++ readObjectDefinition(null); ++ ++ return readObject(); ++ } ++ ++ case 0x60: case 0x61: case 0x62: case 0x63: ++ case 0x64: case 0x65: case 0x66: case 0x67: ++ case 0x68: case 0x69: case 0x6a: case 0x6b: ++ case 0x6c: case 0x6d: case 0x6e: case 0x6f: ++ { ++ int ref = tag - 0x60; ++ ++ if (_classDefs.size() <= ref) ++ throw error("No classes defined at reference '" ++ + Integer.toHexString(tag) + "'"); ++ ++ ObjectDefinition def = _classDefs.get(ref); ++ ++ return readObjectInstance(null, def); ++ } ++ ++ case 'O': ++ { ++ int ref = readInt(); ++ ++ if (_classDefs.size() <= ref) ++ throw error("Illegal object reference #" + ref); ++ ++ ObjectDefinition def = _classDefs.get(ref); ++ ++ return readObjectInstance(null, def); ++ } ++ ++ case BC_REF: ++ { ++ int ref = readInt(); ++ ++ return _refs.get(ref); ++ } ++ ++ default: ++ if (tag < 0) ++ throw new EOFException("readObject: unexpected end of file"); ++ else ++ throw error("readObject: unknown code " + codeName(tag)); ++ } ++ } ++ ++ /** ++ * Reads an object definition: ++ * ++ *
++   * O string  (string)* *
++   * 
++ */ ++ private void readObjectDefinition(Class cl) ++ throws IOException ++ { ++ String type = readString(); ++ int len = readInt(); ++ ++ SerializerFactory factory = findSerializerFactory(); ++ ++ Deserializer reader = factory.getObjectDeserializer(type, null); ++ ++ Object []fields = reader.createFields(len); ++ String []fieldNames = new String[len]; ++ ++ for (int i = 0; i < len; i++) { ++ String name = readString(); ++ ++ fields[i] = reader.createField(name); ++ fieldNames[i] = name; ++ } ++ ++ ObjectDefinition def ++ = new ObjectDefinition(type, reader, fields, fieldNames); ++ ++ _classDefs.add(def); ++ } ++ ++ private Object readObjectInstance(Class cl, ++ ObjectDefinition def) ++ throws IOException ++ { ++ String type = def.getType(); ++ Deserializer reader = def.getReader(); ++ Object []fields = def.getFields(); ++ ++ SerializerFactory factory = findSerializerFactory(); ++ ++ if (cl != reader.getType() && cl != null) { ++ reader = factory.getObjectDeserializer(type, cl); ++ ++ return reader.readObject(this, def.getFieldNames()); ++ } ++ else { ++ return reader.readObject(this, fields); ++ } ++ } ++ ++ /** ++ * Reads a remote object. ++ */ ++ public Object readRemote() ++ throws IOException ++ { ++ String type = readType(); ++ String url = readString(); ++ ++ return resolveRemote(type, url); ++ } ++ ++ /** ++ * Reads a reference. ++ */ ++ public Object readRef() ++ throws IOException ++ { ++ int value = parseInt(); ++ ++ return _refs.get(value); ++ } ++ ++ /** ++ * Reads the start of a list. ++ */ ++ public int readListStart() ++ throws IOException ++ { ++ return read(); ++ } ++ ++ /** ++ * Reads the start of a list. ++ */ ++ public int readMapStart() ++ throws IOException ++ { ++ return read(); ++ } ++ ++ /** ++ * Returns true if this is the end of a list or a map. ++ */ ++ public boolean isEnd() ++ throws IOException ++ { ++ int code; ++ ++ if (_offset < _length) ++ code = (_buffer[_offset] & 0xff); ++ else { ++ code = read(); ++ ++ if (code >= 0) ++ _offset--; ++ } ++ ++ return (code < 0 || code == 'Z'); ++ } ++ ++ /** ++ * Reads the end byte. ++ */ ++ public void readEnd() ++ throws IOException ++ { ++ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ if (code == 'Z') ++ return; ++ else if (code < 0) ++ throw error("unexpected end of file"); ++ else ++ throw error("unknown code:" + codeName(code)); ++ } ++ ++ /** ++ * Reads the end byte. ++ */ ++ public void readMapEnd() ++ throws IOException ++ { ++ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ if (code != 'Z') ++ throw error("expected end of map ('Z') at '" + codeName(code) + "'"); ++ } ++ ++ /** ++ * Reads the end byte. ++ */ ++ public void readListEnd() ++ throws IOException ++ { ++ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ if (code != 'Z') ++ throw error("expected end of list ('Z') at '" + codeName(code) + "'"); ++ } ++ ++ /** ++ * Adds a list/map reference. ++ */ ++ @Override ++ public int addRef(Object ref) ++ { ++ if (_refs == null) ++ _refs = new ArrayList(); ++ ++ _refs.add(ref); ++ ++ return _refs.size() - 1; ++ } ++ ++ /** ++ * Adds a list/map reference. ++ */ ++ public void setRef(int i, Object ref) ++ { ++ _refs.set(i, ref); ++ } ++ ++ /** ++ * Resets the references for streaming. ++ */ ++ @Override ++ public void resetReferences() ++ { ++ _refs.clear(); ++ } ++ ++ public void reset() ++ { ++ resetReferences(); ++ ++ _classDefs.clear(); ++ _types.clear(); ++ } ++ ++ public void resetBuffer() ++ { ++ int offset = _offset; ++ _offset = 0; ++ ++ int length = _length; ++ _length = 0; ++ ++ if (length > 0 && offset != length) ++ throw new IllegalStateException("offset=" + offset + " length=" + length); ++ } ++ ++ public Object readStreamingObject() ++ throws IOException ++ { ++ if (_refs != null) ++ _refs.clear(); ++ ++ return readObject(); ++ } ++ ++ /** ++ * Resolves a remote object. ++ */ ++ public Object resolveRemote(String type, String url) ++ throws IOException ++ { ++ HessianRemoteResolver resolver = getRemoteResolver(); ++ ++ if (resolver != null) ++ return resolver.lookup(type, url); ++ else ++ return new HessianRemote(type, url); ++ } ++ ++ /** ++ * Parses a type from the stream. ++ * ++ *
++   * type ::= string
++   * type ::= int
++   * 
++ */ ++ public String readType() ++ throws IOException ++ { ++ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ _offset--; ++ ++ switch (code) { ++ case 0x00: case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ case BC_STRING_CHUNK: case 'S': ++ { ++ String type = readString(); ++ ++ if (_types == null) ++ _types = new ArrayList(); ++ ++ _types.add(type); ++ ++ return type; ++ } ++ ++ default: ++ { ++ int ref = readInt(); ++ ++ if (_types.size() <= ref) ++ throw new IndexOutOfBoundsException("type ref #" + ref + " is greater than the number of valid types (" + _types.size() + ")"); ++ ++ return (String) _types.get(ref); ++ } ++ } ++ } ++ ++ /** ++ * Parses the length for an array ++ * ++ *
++   * l b32 b24 b16 b8
++   * 
++ */ ++ public int readLength() ++ throws IOException ++ { ++ throw new UnsupportedOperationException(); ++ } ++ ++ /** ++ * Parses a 32-bit integer value from the stream. ++ * ++ *
++   * b32 b24 b16 b8
++   * 
++ */ ++ private int parseInt() ++ throws IOException ++ { ++ int offset = _offset; ++ ++ if (offset + 3 < _length) { ++ byte []buffer = _buffer; ++ ++ int b32 = buffer[offset + 0] & 0xff; ++ int b24 = buffer[offset + 1] & 0xff; ++ int b16 = buffer[offset + 2] & 0xff; ++ int b8 = buffer[offset + 3] & 0xff; ++ ++ _offset = offset + 4; ++ ++ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; ++ } ++ else { ++ int b32 = read(); ++ int b24 = read(); ++ int b16 = read(); ++ int b8 = read(); ++ ++ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; ++ } ++ } ++ ++ /** ++ * Parses a 64-bit long value from the stream. ++ * ++ *
++   * b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ private long parseLong() ++ throws IOException ++ { ++ long b64 = read(); ++ long b56 = read(); ++ long b48 = read(); ++ long b40 = read(); ++ long b32 = read(); ++ long b24 = read(); ++ long b16 = read(); ++ long b8 = read(); ++ ++ return ((b64 << 56) ++ + (b56 << 48) ++ + (b48 << 40) ++ + (b40 << 32) ++ + (b32 << 24) ++ + (b24 << 16) ++ + (b16 << 8) ++ + b8); ++ } ++ ++ /** ++ * Parses a 64-bit double value from the stream. ++ * ++ *
++   * b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ private double parseDouble() ++ throws IOException ++ { ++ long bits = parseLong(); ++ ++ return Double.longBitsToDouble(bits); ++ } ++ ++ org.w3c.dom.Node parseXML() ++ throws IOException ++ { ++ throw new UnsupportedOperationException(); ++ } ++ ++ private void parseString(StringBuilder sbuf) ++ throws IOException ++ { ++ while (true) { ++ if (_chunkLength <= 0) { ++ if (! parseChunkLength()) ++ return; ++ } ++ ++ int length = _chunkLength; ++ _chunkLength = 0; ++ ++ while (length-- > 0) { ++ sbuf.append((char) parseUTF8Char()); ++ } ++ } ++ } ++ ++ /** ++ * Reads a character from the underlying stream. ++ */ ++ private int parseChar() ++ throws IOException ++ { ++ while (_chunkLength <= 0) { ++ if (! parseChunkLength()) ++ return -1; ++ } ++ ++ _chunkLength--; ++ ++ return parseUTF8Char(); ++ } ++ ++ private boolean parseChunkLength() ++ throws IOException ++ { ++ if (_isLastChunk) ++ return false; ++ ++ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ switch (code) { ++ case BC_STRING_CHUNK: ++ _isLastChunk = false; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 'S': ++ _isLastChunk = true; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 0x00: case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ _isLastChunk = true; ++ _chunkLength = code - 0x00; ++ break; ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ _isLastChunk = true; ++ _chunkLength = (code - 0x30) * 256 + read(); ++ break; ++ ++ default: ++ throw expect("string", code); ++ } ++ ++ return true; ++ } ++ ++ /** ++ * Parses a single UTF8 character. ++ */ ++ private int parseUTF8Char() ++ throws IOException ++ { ++ int ch = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); ++ ++ if (ch < 0x80) ++ return ch; ++ else if ((ch & 0xe0) == 0xc0) { ++ int ch1 = read(); ++ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); ++ ++ return v; ++ } ++ else if ((ch & 0xf0) == 0xe0) { ++ int ch1 = read(); ++ int ch2 = read(); ++ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); ++ ++ return v; ++ } ++ else ++ throw error("bad utf-8 encoding at " + codeName(ch)); ++ } ++ ++ /** ++ * Reads a byte from the underlying stream. ++ */ ++ private int parseByte() ++ throws IOException ++ { ++ while (_chunkLength <= 0) { ++ if (_isLastChunk) { ++ return -1; ++ } ++ ++ int code = read(); ++ ++ switch (code) { ++ case BC_BINARY_CHUNK: ++ _isLastChunk = false; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 'B': ++ _isLastChunk = true; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 0x20: case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ _isLastChunk = true; ++ ++ _chunkLength = code - 0x20; ++ break; ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ _isLastChunk = true; ++ _chunkLength = (code - 0x34) * 256 + read(); ++ break; ++ ++ default: ++ throw expect("byte[]", code); ++ } ++ } ++ ++ _chunkLength--; ++ ++ return read(); ++ } ++ ++ /** ++ * Reads bytes based on an input stream. ++ */ ++ public InputStream readInputStream() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case BC_BINARY: ++ case BC_BINARY_CHUNK: ++ _isLastChunk = tag == BC_BINARY; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 0x20: case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ _isLastChunk = true; ++ _chunkLength = tag - 0x20; ++ break; ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ _isLastChunk = true; ++ _chunkLength = (tag - 0x34) * 256 + read(); ++ break; ++ ++ default: ++ throw expect("binary", tag); ++ } ++ ++ return new ReadInputStream(); ++ } ++ ++ /** ++ * Reads bytes from the underlying stream. ++ */ ++ int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ int readLength = 0; ++ ++ while (length > 0) { ++ while (_chunkLength <= 0) { ++ if (_isLastChunk) ++ return readLength == 0 ? -1 : readLength; ++ ++ int code = read(); ++ ++ switch (code) { ++ case BC_BINARY_CHUNK: ++ _isLastChunk = false; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case BC_BINARY: ++ _isLastChunk = true; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 0x20: case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ _isLastChunk = true; ++ _chunkLength = code - 0x20; ++ break; ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ _isLastChunk = true; ++ _chunkLength = (code - 0x34) * 256 + read(); ++ break; ++ ++ default: ++ throw expect("byte[]", code); ++ } ++ } ++ ++ int sublen = _chunkLength; ++ if (length < sublen) ++ sublen = length; ++ ++ if (_length <= _offset && ! readBuffer()) ++ return -1; ++ ++ if (_length - _offset < sublen) ++ sublen = _length - _offset; ++ ++ System.arraycopy(_buffer, _offset, buffer, offset, sublen); ++ ++ _offset += sublen; ++ ++ offset += sublen; ++ readLength += sublen; ++ length -= sublen; ++ _chunkLength -= sublen; ++ } ++ ++ return readLength; ++ } ++ ++ /** ++ * Normally, shouldn't be called externally, but needed for QA, e.g. ++ * ejb/3b01. ++ */ ++ public final int read() ++ throws IOException ++ { ++ if (_length <= _offset && ! readBuffer()) ++ return -1; ++ ++ return _buffer[_offset++] & 0xff; ++ } ++ ++ protected void unread() ++ { ++ if (_offset <= 0) ++ throw new IllegalStateException(); ++ ++ _offset--; ++ } ++ ++ private final boolean readBuffer() ++ throws IOException ++ { ++ byte []buffer = _buffer; ++ int offset = _offset; ++ int length = _length; ++ ++ if (offset < length) { ++ System.arraycopy(buffer, offset, buffer, 0, length - offset); ++ offset = length - offset; ++ } ++ else ++ offset = 0; ++ ++ int len = _is.read(buffer, offset, SIZE - offset); ++ ++ if (len <= 0) { ++ _length = offset; ++ _offset = 0; ++ ++ return offset > 0; ++ } ++ ++ _length = offset + len; ++ _offset = 0; ++ ++ return true; ++ } ++ ++ public Reader getReader() ++ { ++ return null; ++ } ++ ++ protected IOException expect(String expect, int ch) ++ throws IOException ++ { ++ if (ch < 0) ++ return error("expected " + expect + " at end of file"); ++ else { ++ _offset--; ++ ++ try { ++ int offset = _offset; ++ String context ++ = buildDebugContext(_buffer, 0, _length, offset); ++ ++ Object obj = readObject(); ++ ++ if (obj != null) { ++ return error("expected " + expect ++ + " at 0x" + Integer.toHexString(ch & 0xff) ++ + " " + obj.getClass().getName() + " (" + obj + ")" ++ + "\n " + context + ""); ++ } ++ else ++ return error("expected " + expect ++ + " at 0x" + Integer.toHexString(ch & 0xff) + " null"); ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ ++ return error("expected " + expect ++ + " at 0x" + Integer.toHexString(ch & 0xff)); ++ } ++ } ++ } ++ ++ private String buildDebugContext(byte []buffer, int offset, int length, ++ int errorOffset) ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ sb.append("["); ++ for (int i = 0; i < errorOffset; i++) { ++ int ch = buffer[offset + i]; ++ addDebugChar(sb, ch); ++ } ++ sb.append("] "); ++ addDebugChar(sb, buffer[offset + errorOffset]); ++ sb.append(" ["); ++ for (int i = errorOffset + 1; i < length; i++) { ++ int ch = buffer[offset + i]; ++ addDebugChar(sb, ch); ++ } ++ sb.append("]"); ++ ++ return sb.toString(); ++ } ++ ++ private void addDebugChar(StringBuilder sb, int ch) ++ { ++ if (ch >= 0x20 && ch < 0x7f) { ++ sb.append((char) ch); ++ } ++ else if (ch == '\n') ++ sb.append((char) ch); ++ else ++ sb.append(String.format("\\x%02x", ch & 0xff)); ++ } ++ ++ protected String codeName(int ch) ++ { ++ if (ch < 0) ++ return "end of file"; ++ else ++ return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; ++ } ++ ++ protected IOException error(String message) ++ { ++ if (_method != null) ++ return new HessianProtocolException(_method + ": " + message); ++ else ++ return new HessianProtocolException(message); ++ } ++ ++ public void free() ++ { ++ reset(); ++ } ++ ++ @Override ++ public void close() ++ throws IOException ++ { ++ InputStream is = _is; ++ _is = null; ++ ++ if (_isCloseStreamOnClose && is != null) ++ is.close(); ++ } ++ ++ class ReadInputStream extends InputStream { ++ boolean _isClosed = false; ++ ++ public int read() ++ throws IOException ++ { ++ if (_isClosed) ++ return -1; ++ ++ int ch = parseByte(); ++ if (ch < 0) ++ _isClosed = true; ++ ++ return ch; ++ } ++ ++ public int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (_isClosed) ++ return -1; ++ ++ int len = Hessian2Input.this.read(buffer, offset, length); ++ if (len < 0) ++ _isClosed = true; ++ ++ return len; ++ } ++ ++ public void close() ++ throws IOException ++ { ++ while (read() >= 0) { ++ } ++ } ++ }; ++ ++ final static class ObjectDefinition { ++ private final String _type; ++ private final Deserializer _reader; ++ private final Object []_fields; ++ private final String []_fieldNames; ++ ++ ObjectDefinition(String type, ++ Deserializer reader, ++ Object []fields, ++ String []fieldNames) ++ { ++ _type = type; ++ _reader = reader; ++ _fields = fields; ++ _fieldNames = fieldNames; ++ } ++ ++ String getType() ++ { ++ return _type; ++ } ++ ++ Deserializer getReader() ++ { ++ return _reader; ++ } ++ ++ Object []getFields() ++ { ++ return _fields; ++ } ++ ++ String []getFieldNames() ++ { ++ return _fieldNames; ++ } ++ } ++ ++ private static Field getDetailMessageField() ++ { ++ if (_detailMessageField == null) { ++ try { ++ _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); ++ _detailMessageField.setAccessible(true); ++ } catch (Throwable e) { ++ } ++ } ++ ++ return _detailMessageField; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Output.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Output.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Output.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Output.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,1788 +1,1788 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import com.caucho.hessian.util.IdentityIntMap; +- +-import java.io.InputStream; +-import java.io.IOException; +-import java.io.OutputStream; +-import java.util.HashMap; +- +-/** +- * Output stream for Hessian 2 requests. +- * +- *

Since HessianOutput does not depend on any classes other than +- * in the JDK, it can be extracted independently into a smaller package. +- * +- *

HessianOutput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * OutputStream os = ...; // from http connection
+- * Hessian2Output out = new Hessian2Output(os);
+- * String value;
+- *
+- * out.startCall("hello", 1); // start hello call
+- * out.writeString("arg1");   // write a string argument
+- * out.completeCall();        // complete the call
+- * 
+- */ +-public class Hessian2Output +- extends AbstractHessianOutput +- implements Hessian2Constants +-{ +- // should match Resin buffer size for perf +- public final static int SIZE = 8 * 1024; +- +- // the output stream/ +- protected OutputStream _os; +- +- // map of references +- private final IdentityIntMap _refs +- = new IdentityIntMap(256); +- +- private int _refCount = 0; +- +- private boolean _isCloseStreamOnClose; +- +- // map of classes +- private final IdentityIntMap _classRefs +- = new IdentityIntMap(256); +- +- // map of types +- private HashMap _typeRefs; +- +- private final byte []_buffer = new byte[SIZE]; +- private int _offset; +- +- private boolean _isPacket; +- +- private boolean _isUnshared; +- +- /** +- * Creates a new Hessian output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public Hessian2Output() +- { +- } +- +- /** +- * Creates a new Hessian output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public Hessian2Output(OutputStream os) +- { +- init(os); +- } +- +- @Override +- public void init(OutputStream os) +- { +- reset(); +- +- _os = os; +- } +- +- public void initPacket(OutputStream os) +- { +- resetReferences(); +- +- _os = os; +- } +- +- public void setCloseStreamOnClose(boolean isClose) +- { +- _isCloseStreamOnClose = isClose; +- } +- +- public boolean isCloseStreamOnClose() +- { +- return _isCloseStreamOnClose; +- } +- +- /** +- * Sets hessian to be "unshared", meaning it will not detect +- * duplicate or circular references. +- */ +- @Override +- public boolean setUnshared(boolean isUnshared) +- { +- boolean oldIsUnshared = _isUnshared; +- +- _isUnshared = isUnshared; +- +- return oldIsUnshared; +- } +- +- /** +- * Writes a complete method call. +- */ +- @Override +- public void call(String method, Object []args) +- throws IOException +- { +- writeVersion(); +- +- int length = args != null ? args.length : 0; +- +- startCall(method, length); +- +- for (int i = 0; i < length; i++) { +- writeObject(args[i]); +- } +- +- completeCall(); +- +- flush(); +- } +- +- /** +- * Starts the method call. Clients would use startCall +- * instead of call if they wanted finer control over +- * writing the arguments, or needed to write headers. +- * +- *
+-   * C
+-   * string # method name
+-   * int    # arg count
+-   * 
+- * +- * @param method the method name to call. +- */ +- @Override +- public void startCall(String method, int length) +- throws IOException +- { +- int offset = _offset; +- +- if (SIZE < offset + 32) { +- flushBuffer(); +- offset = _offset; +- } +- +- byte []buffer = _buffer; +- +- buffer[_offset++] = (byte) 'C'; +- +- writeString(method); +- writeInt(length); +- } +- +- /** +- * Writes the call tag. This would be followed by the +- * method and the arguments +- * +- *
+-   * C
+-   * 
+- * +- * @param method the method name to call. +- */ +- @Override +- public void startCall() +- throws IOException +- { +- flushIfFull(); +- +- _buffer[_offset++] = (byte) 'C'; +- } +- +- /** +- * Starts an envelope. +- * +- *
+-   * E major minor
+-   * m b16 b8 method-name
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void startEnvelope(String method) +- throws IOException +- { +- int offset = _offset; +- +- if (SIZE < offset + 32) { +- flushBuffer(); +- offset = _offset; +- } +- +- _buffer[_offset++] = (byte) 'E'; +- +- writeString(method); +- } +- +- /** +- * Completes an envelope. +- * +- *

A successful completion will have a single value: +- * +- *

+-   * Z
+-   * 
+- */ +- public void completeEnvelope() +- throws IOException +- { +- flushIfFull(); +- +- _buffer[_offset++] = (byte) 'Z'; +- } +- +- /** +- * Writes the method tag. +- * +- *
+-   * string
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void writeMethod(String method) +- throws IOException +- { +- writeString(method); +- } +- +- /** +- * Completes. +- * +- *
+-   * z
+-   * 
+- */ +- @Override +- public void completeCall() +- throws IOException +- { +- /* +- flushIfFull(); +- +- _buffer[_offset++] = (byte) 'Z'; +- */ +- } +- +- /** +- * Starts the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * R
+-   * 
+- */ +- @Override +- public void startReply() +- throws IOException +- { +- writeVersion(); +- +- flushIfFull(); +- +- _buffer[_offset++] = (byte) 'R'; +- } +- +- public void writeVersion() +- throws IOException +- { +- flushIfFull(); +- +- _buffer[_offset++] = (byte) 'H'; +- _buffer[_offset++] = (byte) 2; +- _buffer[_offset++] = (byte) 0; +- } +- +- /** +- * Completes reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- @Override +- public void completeReply() +- throws IOException +- { +- } +- +- /** +- * Starts a packet +- * +- *

A message contains several objects encapsulated by a length

+- * +- *
+-   * p x02 x00
+-   * 
+- */ +- public void startMessage() +- throws IOException +- { +- flushIfFull(); +- +- _buffer[_offset++] = (byte) 'p'; +- _buffer[_offset++] = (byte) 2; +- _buffer[_offset++] = (byte) 0; +- } +- +- /** +- * Completes reading the message +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeMessage() +- throws IOException +- { +- flushIfFull(); +- +- _buffer[_offset++] = (byte) 'z'; +- } +- +- /** +- * Writes a fault. The fault will be written +- * as a descriptive string followed by an object: +- * +- *
+-   * F map
+-   * 
+- * +- *
+-   * F H
+-   * \x04code
+-   * \x10the fault code
+-   *
+-   * \x07message
+-   * \x11the fault message
+-   *
+-   * \x06detail
+-   * M\xnnjavax.ejb.FinderException
+-   *     ...
+-   * Z
+-   * Z
+-   * 
+- * +- * @param code the fault code, a three digit +- */ +- public void writeFault(String code, String message, Object detail) +- throws IOException +- { +- flushIfFull(); +- +- writeVersion(); +- +- _buffer[_offset++] = (byte) 'F'; +- _buffer[_offset++] = (byte) 'H'; +- +- addRef(new Object(), _refCount++, false); +- +- writeString("code"); +- writeString(code); +- +- writeString("message"); +- writeString(message); +- +- if (detail != null) { +- writeString("detail"); +- writeObject(detail); +- } +- +- flushIfFull(); +- _buffer[_offset++] = (byte) 'Z'; +- } +- +- /** +- * Writes any object to the output stream. +- */ +- @Override +- public void writeObject(Object object) +- throws IOException +- { +- if (object == null) { +- writeNull(); +- return; +- } +- +- Serializer serializer +- = findSerializerFactory().getObjectSerializer(object.getClass()); +- +- serializer.writeObject(object, this); +- } +- +- /** +- * Writes the list header to the stream. List writers will call +- * writeListBegin followed by the list contents and then +- * call writeListEnd. +- * +- *
+-   * list ::= V type value* Z
+-   *      ::= v type int value*
+-   * 
+- * +- * @return true for variable lists, false for fixed lists +- */ +- public boolean writeListBegin(int length, String type) +- throws IOException +- { +- flushIfFull(); +- +- if (length < 0) { +- if (type != null) { +- _buffer[_offset++] = (byte) BC_LIST_VARIABLE; +- writeType(type); +- } +- else +- _buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED; +- +- return true; +- } +- else if (length <= LIST_DIRECT_MAX) { +- if (type != null) { +- _buffer[_offset++] = (byte) (BC_LIST_DIRECT + length); +- writeType(type); +- } +- else { +- _buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length); +- } +- +- return false; +- } +- else { +- if (type != null) { +- _buffer[_offset++] = (byte) BC_LIST_FIXED; +- writeType(type); +- } +- else { +- _buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED; +- } +- +- writeInt(length); +- +- return false; +- } +- } +- +- /** +- * Writes the tail of the list to the stream for a variable-length list. +- */ +- public void writeListEnd() +- throws IOException +- { +- flushIfFull(); +- +- _buffer[_offset++] = (byte) BC_END; +- } +- +- /** +- * Writes the map header to the stream. Map writers will call +- * writeMapBegin followed by the map contents and then +- * call writeMapEnd. +- * +- *
+-   * map ::= M type ( )* Z
+-   *     ::= H ( )* Z
+-   * 
+- */ +- public void writeMapBegin(String type) +- throws IOException +- { +- if (SIZE < _offset + 32) +- flushBuffer(); +- +- if (type != null) { +- _buffer[_offset++] = BC_MAP; +- +- writeType(type); +- } +- else +- _buffer[_offset++] = BC_MAP_UNTYPED; +- } +- +- /** +- * Writes the tail of the map to the stream. +- */ +- public void writeMapEnd() +- throws IOException +- { +- if (SIZE < _offset + 32) +- flushBuffer(); +- +- _buffer[_offset++] = (byte) BC_END; +- } +- +- /** +- * Writes the object definition +- * +- *
+-   * C <string> <int> <string>*
+-   * 
+- */ +- @Override +- public int writeObjectBegin(String type) +- throws IOException +- { +- int newRef = _classRefs.size(); +- int ref = _classRefs.put(type, newRef, false); +- +- if (newRef != ref) { +- if (SIZE < _offset + 32) +- flushBuffer(); +- +- if (ref <= OBJECT_DIRECT_MAX) { +- _buffer[_offset++] = (byte) (BC_OBJECT_DIRECT + ref); +- } +- else { +- _buffer[_offset++] = (byte) 'O'; +- writeInt(ref); +- } +- +- return ref; +- } +- else { +- if (SIZE < _offset + 32) +- flushBuffer(); +- +- _buffer[_offset++] = (byte) 'C'; +- +- writeString(type); +- +- return -1; +- } +- } +- +- /** +- * Writes the tail of the class definition to the stream. +- */ +- @Override +- public void writeClassFieldLength(int len) +- throws IOException +- { +- writeInt(len); +- } +- +- /** +- * Writes the tail of the object definition to the stream. +- */ +- @Override +- public void writeObjectEnd() +- throws IOException +- { +- } +- +- /** +- *
+-   * type ::= string
+-   *      ::= int
+-   * 
+- */ +- private void writeType(String type) +- throws IOException +- { +- flushIfFull(); +- +- int len = type.length(); +- if (len == 0) { +- throw new IllegalArgumentException("empty type is not allowed"); +- } +- +- if (_typeRefs == null) +- _typeRefs = new HashMap(); +- +- Integer typeRefV = (Integer) _typeRefs.get(type); +- +- if (typeRefV != null) { +- int typeRef = typeRefV.intValue(); +- +- writeInt(typeRef); +- } +- else { +- _typeRefs.put(type, Integer.valueOf(_typeRefs.size())); +- +- writeString(type); +- } +- } +- +- /** +- * Writes a boolean value to the stream. The boolean will be written +- * with the following syntax: +- * +- *
+-   * T
+-   * F
+-   * 
+- * +- * @param value the boolean value to write. +- */ +- @Override +- public void writeBoolean(boolean value) +- throws IOException +- { +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- if (value) +- _buffer[_offset++] = (byte) 'T'; +- else +- _buffer[_offset++] = (byte) 'F'; +- } +- +- /** +- * Writes an integer value to the stream. The integer will be written +- * with the following syntax: +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- * +- * @param value the integer value to write. +- */ +- @Override +- public void writeInt(int value) +- throws IOException +- { +- int offset = _offset; +- byte []buffer = _buffer; +- +- if (SIZE <= offset + 16) { +- flushBuffer(); +- offset = _offset; +- } +- +- if (INT_DIRECT_MIN <= value && value <= INT_DIRECT_MAX) +- buffer[offset++] = (byte) (value + BC_INT_ZERO); +- else if (INT_BYTE_MIN <= value && value <= INT_BYTE_MAX) { +- buffer[offset++] = (byte) (BC_INT_BYTE_ZERO + (value >> 8)); +- buffer[offset++] = (byte) (value); +- } +- else if (INT_SHORT_MIN <= value && value <= INT_SHORT_MAX) { +- buffer[offset++] = (byte) (BC_INT_SHORT_ZERO + (value >> 16)); +- buffer[offset++] = (byte) (value >> 8); +- buffer[offset++] = (byte) (value); +- } +- else { +- buffer[offset++] = (byte) ('I'); +- buffer[offset++] = (byte) (value >> 24); +- buffer[offset++] = (byte) (value >> 16); +- buffer[offset++] = (byte) (value >> 8); +- buffer[offset++] = (byte) (value); +- } +- +- _offset = offset; +- } +- +- /** +- * Writes a long value to the stream. The long will be written +- * with the following syntax: +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param value the long value to write. +- */ +- public void writeLong(long value) +- throws IOException +- { +- int offset = _offset; +- byte []buffer = _buffer; +- +- if (SIZE <= offset + 16) { +- flushBuffer(); +- offset = _offset; +- } +- +- if (LONG_DIRECT_MIN <= value && value <= LONG_DIRECT_MAX) { +- buffer[offset++] = (byte) (value + BC_LONG_ZERO); +- } +- else if (LONG_BYTE_MIN <= value && value <= LONG_BYTE_MAX) { +- buffer[offset++] = (byte) (BC_LONG_BYTE_ZERO + (value >> 8)); +- buffer[offset++] = (byte) (value); +- } +- else if (LONG_SHORT_MIN <= value && value <= LONG_SHORT_MAX) { +- buffer[offset++] = (byte) (BC_LONG_SHORT_ZERO + (value >> 16)); +- buffer[offset++] = (byte) (value >> 8); +- buffer[offset++] = (byte) (value); +- } +- else if (-0x80000000L <= value && value <= 0x7fffffffL) { +- buffer[offset + 0] = (byte) BC_LONG_INT; +- buffer[offset + 1] = (byte) (value >> 24); +- buffer[offset + 2] = (byte) (value >> 16); +- buffer[offset + 3] = (byte) (value >> 8); +- buffer[offset + 4] = (byte) (value); +- +- offset += 5; +- } +- else { +- buffer[offset + 0] = (byte) 'L'; +- buffer[offset + 1] = (byte) (value >> 56); +- buffer[offset + 2] = (byte) (value >> 48); +- buffer[offset + 3] = (byte) (value >> 40); +- buffer[offset + 4] = (byte) (value >> 32); +- buffer[offset + 5] = (byte) (value >> 24); +- buffer[offset + 6] = (byte) (value >> 16); +- buffer[offset + 7] = (byte) (value >> 8); +- buffer[offset + 8] = (byte) (value); +- +- offset += 9; +- } +- +- _offset = offset; +- } +- +- /** +- * Writes a double value to the stream. The double will be written +- * with the following syntax: +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param value the double value to write. +- */ +- public void writeDouble(double value) +- throws IOException +- { +- int offset = _offset; +- byte []buffer = _buffer; +- +- if (SIZE <= offset + 16) { +- flushBuffer(); +- offset = _offset; +- } +- +- int intValue = (int) value; +- +- if (intValue == value) { +- if (intValue == 0) { +- buffer[offset++] = (byte) BC_DOUBLE_ZERO; +- +- _offset = offset; +- +- return; +- } +- else if (intValue == 1) { +- buffer[offset++] = (byte) BC_DOUBLE_ONE; +- +- _offset = offset; +- +- return; +- } +- else if (-0x80 <= intValue && intValue < 0x80) { +- buffer[offset++] = (byte) BC_DOUBLE_BYTE; +- buffer[offset++] = (byte) intValue; +- +- _offset = offset; +- +- return; +- } +- else if (-0x8000 <= intValue && intValue < 0x8000) { +- buffer[offset + 0] = (byte) BC_DOUBLE_SHORT; +- buffer[offset + 1] = (byte) (intValue >> 8); +- buffer[offset + 2] = (byte) intValue; +- +- _offset = offset + 3; +- +- return; +- } +- } +- +- int mills = (int) (value * 1000); +- +- if (0.001 * mills == value) { +- buffer[offset + 0] = (byte) (BC_DOUBLE_MILL); +- buffer[offset + 1] = (byte) (mills >> 24); +- buffer[offset + 2] = (byte) (mills >> 16); +- buffer[offset + 3] = (byte) (mills >> 8); +- buffer[offset + 4] = (byte) (mills); +- +- _offset = offset + 5; +- +- return; +- } +- +- long bits = Double.doubleToLongBits(value); +- +- buffer[offset + 0] = (byte) 'D'; +- buffer[offset + 1] = (byte) (bits >> 56); +- buffer[offset + 2] = (byte) (bits >> 48); +- buffer[offset + 3] = (byte) (bits >> 40); +- buffer[offset + 4] = (byte) (bits >> 32); +- buffer[offset + 5] = (byte) (bits >> 24); +- buffer[offset + 6] = (byte) (bits >> 16); +- buffer[offset + 7] = (byte) (bits >> 8); +- buffer[offset + 8] = (byte) (bits); +- +- _offset = offset + 9; +- } +- +- /** +- * Writes a date to the stream. +- * +- *
+-   * date ::= d   b7 b6 b5 b4 b3 b2 b1 b0
+-   *      ::= x65 b3 b2 b1 b0
+-   * 
+- * +- * @param time the date in milliseconds from the epoch in UTC +- */ +- public void writeUTCDate(long time) +- throws IOException +- { +- if (SIZE < _offset + 32) +- flushBuffer(); +- +- int offset = _offset; +- byte []buffer = _buffer; +- +- if (time % 60000L == 0) { +- // compact date ::= x65 b3 b2 b1 b0 +- +- long minutes = time / 60000L; +- +- if ((minutes >> 31) == 0 || (minutes >> 31) == -1) { +- buffer[offset++] = (byte) BC_DATE_MINUTE; +- buffer[offset++] = ((byte) (minutes >> 24)); +- buffer[offset++] = ((byte) (minutes >> 16)); +- buffer[offset++] = ((byte) (minutes >> 8)); +- buffer[offset++] = ((byte) (minutes >> 0)); +- +- _offset = offset; +- return; +- } +- } +- +- buffer[offset++] = (byte) BC_DATE; +- buffer[offset++] = ((byte) (time >> 56)); +- buffer[offset++] = ((byte) (time >> 48)); +- buffer[offset++] = ((byte) (time >> 40)); +- buffer[offset++] = ((byte) (time >> 32)); +- buffer[offset++] = ((byte) (time >> 24)); +- buffer[offset++] = ((byte) (time >> 16)); +- buffer[offset++] = ((byte) (time >> 8)); +- buffer[offset++] = ((byte) (time)); +- +- _offset = offset; +- } +- +- /** +- * Writes a null value to the stream. +- * The null will be written with the following syntax +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeNull() +- throws IOException +- { +- int offset = _offset; +- byte []buffer = _buffer; +- +- if (SIZE <= offset + 16) { +- flushBuffer(); +- offset = _offset; +- } +- +- buffer[offset++] = 'N'; +- +- _offset = offset; +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(String value) +- throws IOException +- { +- int offset = _offset; +- byte []buffer = _buffer; +- +- if (SIZE <= offset + 16) { +- flushBuffer(); +- offset = _offset; +- } +- +- if (value == null) { +- buffer[offset++] = (byte) 'N'; +- +- _offset = offset; +- } +- else { +- int length = value.length(); +- int strOffset = 0; +- +- while (length > 0x8000) { +- int sublen = 0x8000; +- +- offset = _offset; +- +- if (SIZE <= offset + 16) { +- flushBuffer(); +- offset = _offset; +- } +- +- // chunk can't end in high surrogate +- char tail = value.charAt(strOffset + sublen - 1); +- +- if (0xd800 <= tail && tail <= 0xdbff) +- sublen--; +- +- buffer[offset + 0] = (byte) BC_STRING_CHUNK; +- buffer[offset + 1] = (byte) (sublen >> 8); +- buffer[offset + 2] = (byte) (sublen); +- +- _offset = offset + 3; +- +- printString(value, strOffset, sublen); +- +- length -= sublen; +- strOffset += sublen; +- } +- +- offset = _offset; +- +- if (SIZE <= offset + 16) { +- flushBuffer(); +- offset = _offset; +- } +- +- if (length <= STRING_DIRECT_MAX) { +- buffer[offset++] = (byte) (BC_STRING_DIRECT + length); +- } +- else if (length <= STRING_SHORT_MAX) { +- buffer[offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); +- buffer[offset++] = (byte) (length); +- } +- else { +- buffer[offset++] = (byte) ('S'); +- buffer[offset++] = (byte) (length >> 8); +- buffer[offset++] = (byte) (length); +- } +- +- _offset = offset; +- +- printString(value, strOffset, length); +- } +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(char []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- _buffer[_offset++] = (byte) ('N'); +- } +- else { +- while (length > 0x8000) { +- int sublen = 0x8000; +- +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- // chunk can't end in high surrogate +- char tail = buffer[offset + sublen - 1]; +- +- if (0xd800 <= tail && tail <= 0xdbff) +- sublen--; +- +- _buffer[_offset++] = (byte) BC_STRING_CHUNK; +- _buffer[_offset++] = (byte) (sublen >> 8); +- _buffer[_offset++] = (byte) (sublen); +- +- printString(buffer, offset, sublen); +- +- length -= sublen; +- offset += sublen; +- } +- +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- if (length <= STRING_DIRECT_MAX) { +- _buffer[_offset++] = (byte) (BC_STRING_DIRECT + length); +- } +- else if (length <= STRING_SHORT_MAX) { +- _buffer[_offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); +- _buffer[_offset++] = (byte) length; +- } +- else { +- _buffer[_offset++] = (byte) ('S'); +- _buffer[_offset++] = (byte) (length >> 8); +- _buffer[_offset++] = (byte) (length); +- } +- +- printString(buffer, offset, length); +- } +- } +- +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer) +- throws IOException +- { +- if (buffer == null) { +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- _buffer[_offset++] = 'N'; +- } +- else +- writeBytes(buffer, 0, buffer.length); +- } +- +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- _buffer[_offset++] = (byte) 'N'; +- } +- else { +- while (SIZE - _offset - 3 < length) { +- int sublen = SIZE - _offset - 3; +- +- if (sublen < 16) { +- flushBuffer(); +- +- sublen = SIZE - _offset - 3; +- +- if (length < sublen) +- sublen = length; +- } +- +- _buffer[_offset++] = (byte) BC_BINARY_CHUNK; +- _buffer[_offset++] = (byte) (sublen >> 8); +- _buffer[_offset++] = (byte) sublen; +- +- System.arraycopy(buffer, offset, _buffer, _offset, sublen); +- _offset += sublen; +- +- length -= sublen; +- offset += sublen; +- +- flushBuffer(); +- } +- +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- if (length <= BINARY_DIRECT_MAX) { +- _buffer[_offset++] = (byte) (BC_BINARY_DIRECT + length); +- } +- else if (length <= BINARY_SHORT_MAX) { +- _buffer[_offset++] = (byte) (BC_BINARY_SHORT + (length >> 8)); +- _buffer[_offset++] = (byte) (length); +- } +- else { +- _buffer[_offset++] = (byte) 'B'; +- _buffer[_offset++] = (byte) (length >> 8); +- _buffer[_offset++] = (byte) (length); +- } +- +- System.arraycopy(buffer, offset, _buffer, _offset, length); +- +- _offset += length; +- } +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * 
+- */ +- public void writeByteBufferStart() +- throws IOException +- { +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- */ +- public void writeByteBufferPart(byte []buffer, int offset, int length) +- throws IOException +- { +- while (length > 0) { +- flushIfFull(); +- +- int sublen = _buffer.length - _offset; +- +- if (length < sublen) +- sublen = length; +- +- _buffer[_offset++] = BC_BINARY_CHUNK; +- _buffer[_offset++] = (byte) (sublen >> 8); +- _buffer[_offset++] = (byte) sublen; +- +- System.arraycopy(buffer, offset, _buffer, _offset, sublen); +- +- _offset += sublen; +- length -= sublen; +- offset += sublen; +- } +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- */ +- public void writeByteBufferEnd(byte []buffer, int offset, int length) +- throws IOException +- { +- writeBytes(buffer, offset, length); +- } +- +- /** +- * Returns an output stream to write binary data. +- */ +- public OutputStream getBytesOutputStream() +- throws IOException +- { +- return new BytesOutputStream(); +- } +- +- /** +- * Writes a full output stream. +- */ +- @Override +- public void writeByteStream(InputStream is) +- throws IOException +- { +- while (true) { +- int len = SIZE - _offset - 3; +- +- if (len < 16) { +- flushBuffer(); +- len = SIZE - _offset - 3; +- } +- +- len = is.read(_buffer, _offset + 3, len); +- +- if (len <= 0) { +- _buffer[_offset++] = BC_BINARY_DIRECT; +- return; +- } +- +- _buffer[_offset + 0] = (byte) BC_BINARY_CHUNK; +- _buffer[_offset + 1] = (byte) (len >> 8); +- _buffer[_offset + 2] = (byte) (len); +- +- _offset += len + 3; +- } +- } +- +- /** +- * Writes a reference. +- * +- *
+-   * x51 <int>
+-   * 
+- * +- * @param value the integer value to write. +- */ +- @Override +- protected void writeRef(int value) +- throws IOException +- { +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- _buffer[_offset++] = (byte) BC_REF; +- +- writeInt(value); +- } +- +- /** +- * If the object has already been written, just write its ref. +- * +- * @return true if we're writing a ref. +- */ +- @Override +- public boolean addRef(Object object) +- throws IOException +- { +- if (_isUnshared) { +- _refCount++; +- return false; +- } +- +- int newRef = _refCount; +- +- int ref = addRef(object, newRef, false); +- +- if (ref != newRef) { +- writeRef(ref); +- +- return true; +- } +- else { +- _refCount++; +- +- return false; +- } +- } +- +- @Override +- public int getRef(Object obj) +- { +- if (_isUnshared) +- return -1; +- +- return _refs.get(obj); +- } +- +- /** +- * Removes a reference. +- */ +- @Override +- public boolean removeRef(Object obj) +- throws IOException +- { +- if (_isUnshared) { +- return false; +- } +- else if (_refs != null) { +- _refs.remove(obj); +- +- return true; +- } +- else +- return false; +- } +- +- /** +- * Replaces a reference from one object to another. +- */ +- @Override +- public boolean replaceRef(Object oldRef, Object newRef) +- throws IOException +- { +- if (_isUnshared) { +- return false; +- } +- +- int value = _refs.get(oldRef); +- +- if (value >= 0) { +- addRef(newRef, value, true); +- +- _refs.remove(oldRef); +- +- return true; +- } +- else +- return false; +- } +- +- private int addRef(Object value, int newRef, boolean isReplace) +- { +- int prevRef = _refs.put(value, newRef, isReplace); +- +- return prevRef; +- } +- +- /** +- * Starts the streaming message +- * +- *

A streaming message starts with 'P'

+- * +- *
+-   * P x02 x00
+-   * 
+- */ +- public void writeStreamingObject(Object obj) +- throws IOException +- { +- startPacket(); +- +- writeObject(obj); +- +- endPacket(); +- } +- +- /** +- * Starts a streaming packet +- * +- *

A streaming contains a set of chunks, ending with a zero chunk. +- * Each chunk is a length followed by data where the length is +- * encoded by (b1xxxxxxxx)* b0xxxxxxxx

+- */ +- public void startPacket() +- throws IOException +- { +- if (_refs != null) { +- _refs.clear(); +- _refCount = 0; +- } +- +- flushBuffer(); +- +- _isPacket = true; +- _offset = 4; +- _buffer[0] = (byte) 0x05; // 0x05 = binary +- _buffer[1] = (byte) 0x55; +- _buffer[2] = (byte) 0x55; +- _buffer[3] = (byte) 0x55; +- } +- +- public void endPacket() +- throws IOException +- { +- int offset = _offset; +- +- OutputStream os = _os; +- +- if (os == null) { +- _offset = 0; +- return; +- } +- +- int len = offset - 4; +- +- if (len < 0x7e) { +- _buffer[2] = _buffer[0]; +- _buffer[3] = (byte) (len); +- } else { +- _buffer[1] = (byte) (0x7e); +- _buffer[2] = (byte) (len >> 8); +- _buffer[3] = (byte) (len); +- } +- +- _isPacket = false; +- _offset = 0; +- +- if (os == null) { +- } +- else if (len < 0x7e) { +- os.write(_buffer, 2, offset - 2); +- } +- else { +- os.write(_buffer, 0, offset); +- } +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 with preceeding length +- * +- * @param v the string to print. +- */ +- public void printLenString(String v) +- throws IOException +- { +- if (SIZE < _offset + 16) +- flushBuffer(); +- +- if (v == null) { +- _buffer[_offset++] = (byte) (0); +- _buffer[_offset++] = (byte) (0); +- } +- else { +- int len = v.length(); +- _buffer[_offset++] = (byte) (len >> 8); +- _buffer[_offset++] = (byte) (len); +- +- printString(v, 0, len); +- } +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v) +- throws IOException +- { +- printString(v, 0, v.length()); +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v, int strOffset, int length) +- throws IOException +- { +- int offset = _offset; +- byte []buffer = _buffer; +- +- for (int i = 0; i < length; i++) { +- if (SIZE <= offset + 16) { +- _offset = offset; +- flushBuffer(); +- offset = _offset; +- } +- +- char ch = v.charAt(i + strOffset); +- +- if (ch < 0x80) +- buffer[offset++] = (byte) (ch); +- else if (ch < 0x800) { +- buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); +- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); +- } +- else { +- buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); +- buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); +- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); +- } +- } +- +- _offset = offset; +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(char []v, int strOffset, int length) +- throws IOException +- { +- int offset = _offset; +- byte []buffer = _buffer; +- +- for (int i = 0; i < length; i++) { +- if (SIZE <= offset + 16) { +- _offset = offset; +- flushBuffer(); +- offset = _offset; +- } +- +- char ch = v[i + strOffset]; +- +- if (ch < 0x80) +- buffer[offset++] = (byte) (ch); +- else if (ch < 0x800) { +- buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); +- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); +- } +- else { +- buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); +- buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); +- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); +- } +- } +- +- _offset = offset; +- } +- +- private final void flushIfFull() +- throws IOException +- { +- int offset = _offset; +- +- if (SIZE < offset + 32) { +- flushBuffer(); +- } +- } +- +- public final void flush() +- throws IOException +- { +- flushBuffer(); +- +- if (_os != null) +- _os.flush(); +- } +- +- public final void flushBuffer() +- throws IOException +- { +- int offset = _offset; +- +- OutputStream os = _os; +- +- if (! _isPacket && offset > 0) { +- _offset = 0; +- if (os != null) +- os.write(_buffer, 0, offset); +- } +- else if (_isPacket && offset > 4) { +- int len = offset - 4; +- +- _buffer[0] |= (byte) 0x80; +- _buffer[1] = (byte) (0x7e); +- _buffer[2] = (byte) (len >> 8); +- _buffer[3] = (byte) (len); +- _offset = 4; +- +- if (os != null) +- os.write(_buffer, 0, offset); +- +- _buffer[0] = (byte) 0x00; +- _buffer[1] = (byte) 0x56; +- _buffer[2] = (byte) 0x56; +- _buffer[3] = (byte) 0x56; +- } +- } +- +- @Override +- public void close() +- throws IOException +- { +- // hessian/3a8c +- flush(); +- +- OutputStream os = _os; +- _os = null; +- +- if (os != null) { +- if (_isCloseStreamOnClose) +- os.close(); +- } +- } +- +- public void free() +- { +- reset(); +- +- _os = null; +- _isCloseStreamOnClose = false; +- } +- +- /** +- * Resets the references for streaming. +- */ +- @Override +- public void resetReferences() +- { +- if (_refs != null) { +- _refs.clear(); +- _refCount = 0; +- } +- } +- +- /** +- * Resets all counters and references +- */ +- public void reset() +- { +- if (_refs != null) { +- _refs.clear(); +- _refCount = 0; +- } +- +- _classRefs.clear(); +- _typeRefs = null; +- _offset = 0; +- _isPacket = false; +- _isUnshared = false; +- } +- +- class BytesOutputStream extends OutputStream { +- private int _startOffset; +- +- BytesOutputStream() +- throws IOException +- { +- if (SIZE < _offset + 16) { +- Hessian2Output.this.flushBuffer(); +- } +- +- _startOffset = _offset; +- _offset += 3; // skip 'b' xNN xNN +- } +- +- @Override +- public void write(int ch) +- throws IOException +- { +- if (SIZE <= _offset) { +- int length = (_offset - _startOffset) - 3; +- +- _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; +- _buffer[_startOffset + 1] = (byte) (length >> 8); +- _buffer[_startOffset + 2] = (byte) (length); +- +- Hessian2Output.this.flushBuffer(); +- +- _startOffset = _offset; +- _offset += 3; +- } +- +- _buffer[_offset++] = (byte) ch; +- } +- +- @Override +- public void write(byte []buffer, int offset, int length) +- throws IOException +- { +- while (length > 0) { +- int sublen = SIZE - _offset; +- +- if (length < sublen) +- sublen = length; +- +- if (sublen > 0) { +- System.arraycopy(buffer, offset, _buffer, _offset, sublen); +- _offset += sublen; +- } +- +- length -= sublen; +- offset += sublen; +- +- if (SIZE <= _offset) { +- int chunkLength = (_offset - _startOffset) - 3; +- +- _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; +- _buffer[_startOffset + 1] = (byte) (chunkLength >> 8); +- _buffer[_startOffset + 2] = (byte) (chunkLength); +- +- Hessian2Output.this.flushBuffer(); +- +- _startOffset = _offset; +- _offset += 3; +- } +- } +- } +- +- @Override +- public void close() +- throws IOException +- { +- int startOffset = _startOffset; +- _startOffset = -1; +- +- if (startOffset < 0) +- return; +- +- int length = (_offset - startOffset) - 3; +- +- _buffer[startOffset] = (byte) 'B'; +- _buffer[startOffset + 1] = (byte) (length >> 8); +- _buffer[startOffset + 2] = (byte) (length); +- +- Hessian2Output.this.flushBuffer(); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import com.caucho.hessian.util.IdentityIntMap; ++ ++import java.io.InputStream; ++import java.io.IOException; ++import java.io.OutputStream; ++import java.util.HashMap; ++ ++/** ++ * Output stream for Hessian 2 requests. ++ * ++ *

Since HessianOutput does not depend on any classes other than ++ * in the JDK, it can be extracted independently into a smaller package. ++ * ++ *

HessianOutput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * OutputStream os = ...; // from http connection
++ * Hessian2Output out = new Hessian2Output(os);
++ * String value;
++ *
++ * out.startCall("hello", 1); // start hello call
++ * out.writeString("arg1");   // write a string argument
++ * out.completeCall();        // complete the call
++ * 
++ */ ++public class Hessian2Output ++ extends AbstractHessianOutput ++ implements Hessian2Constants ++{ ++ // should match Resin buffer size for perf ++ public final static int SIZE = 8 * 1024; ++ ++ // the output stream/ ++ protected OutputStream _os; ++ ++ // map of references ++ private final IdentityIntMap _refs ++ = new IdentityIntMap(256); ++ ++ private int _refCount = 0; ++ ++ private boolean _isCloseStreamOnClose; ++ ++ // map of classes ++ private final IdentityIntMap _classRefs ++ = new IdentityIntMap(256); ++ ++ // map of types ++ private HashMap _typeRefs; ++ ++ private final byte []_buffer = new byte[SIZE]; ++ private int _offset; ++ ++ private boolean _isPacket; ++ ++ private boolean _isUnshared; ++ ++ /** ++ * Creates a new Hessian output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public Hessian2Output() ++ { ++ } ++ ++ /** ++ * Creates a new Hessian output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public Hessian2Output(OutputStream os) ++ { ++ init(os); ++ } ++ ++ @Override ++ public void init(OutputStream os) ++ { ++ reset(); ++ ++ _os = os; ++ } ++ ++ public void initPacket(OutputStream os) ++ { ++ resetReferences(); ++ ++ _os = os; ++ } ++ ++ public void setCloseStreamOnClose(boolean isClose) ++ { ++ _isCloseStreamOnClose = isClose; ++ } ++ ++ public boolean isCloseStreamOnClose() ++ { ++ return _isCloseStreamOnClose; ++ } ++ ++ /** ++ * Sets hessian to be "unshared", meaning it will not detect ++ * duplicate or circular references. ++ */ ++ @Override ++ public boolean setUnshared(boolean isUnshared) ++ { ++ boolean oldIsUnshared = _isUnshared; ++ ++ _isUnshared = isUnshared; ++ ++ return oldIsUnshared; ++ } ++ ++ /** ++ * Writes a complete method call. ++ */ ++ @Override ++ public void call(String method, Object []args) ++ throws IOException ++ { ++ writeVersion(); ++ ++ int length = args != null ? args.length : 0; ++ ++ startCall(method, length); ++ ++ for (int i = 0; i < length; i++) { ++ writeObject(args[i]); ++ } ++ ++ completeCall(); ++ ++ flush(); ++ } ++ ++ /** ++ * Starts the method call. Clients would use startCall ++ * instead of call if they wanted finer control over ++ * writing the arguments, or needed to write headers. ++ * ++ *
++   * C
++   * string # method name
++   * int    # arg count
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ @Override ++ public void startCall(String method, int length) ++ throws IOException ++ { ++ int offset = _offset; ++ ++ if (SIZE < offset + 32) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ byte []buffer = _buffer; ++ ++ buffer[_offset++] = (byte) 'C'; ++ ++ writeString(method); ++ writeInt(length); ++ } ++ ++ /** ++ * Writes the call tag. This would be followed by the ++ * method and the arguments ++ * ++ *
++   * C
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ @Override ++ public void startCall() ++ throws IOException ++ { ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) 'C'; ++ } ++ ++ /** ++ * Starts an envelope. ++ * ++ *
++   * E major minor
++   * m b16 b8 method-name
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void startEnvelope(String method) ++ throws IOException ++ { ++ int offset = _offset; ++ ++ if (SIZE < offset + 32) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ _buffer[_offset++] = (byte) 'E'; ++ ++ writeString(method); ++ } ++ ++ /** ++ * Completes an envelope. ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * Z
++   * 
++ */ ++ public void completeEnvelope() ++ throws IOException ++ { ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) 'Z'; ++ } ++ ++ /** ++ * Writes the method tag. ++ * ++ *
++   * string
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void writeMethod(String method) ++ throws IOException ++ { ++ writeString(method); ++ } ++ ++ /** ++ * Completes. ++ * ++ *
++   * z
++   * 
++ */ ++ @Override ++ public void completeCall() ++ throws IOException ++ { ++ /* ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) 'Z'; ++ */ ++ } ++ ++ /** ++ * Starts the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * R
++   * 
++ */ ++ @Override ++ public void startReply() ++ throws IOException ++ { ++ writeVersion(); ++ ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) 'R'; ++ } ++ ++ public void writeVersion() ++ throws IOException ++ { ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) 'H'; ++ _buffer[_offset++] = (byte) 2; ++ _buffer[_offset++] = (byte) 0; ++ } ++ ++ /** ++ * Completes reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ @Override ++ public void completeReply() ++ throws IOException ++ { ++ } ++ ++ /** ++ * Starts a packet ++ * ++ *

A message contains several objects encapsulated by a length

++ * ++ *
++   * p x02 x00
++   * 
++ */ ++ public void startMessage() ++ throws IOException ++ { ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) 'p'; ++ _buffer[_offset++] = (byte) 2; ++ _buffer[_offset++] = (byte) 0; ++ } ++ ++ /** ++ * Completes reading the message ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeMessage() ++ throws IOException ++ { ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) 'z'; ++ } ++ ++ /** ++ * Writes a fault. The fault will be written ++ * as a descriptive string followed by an object: ++ * ++ *
++   * F map
++   * 
++ * ++ *
++   * F H
++   * \x04code
++   * \x10the fault code
++   *
++   * \x07message
++   * \x11the fault message
++   *
++   * \x06detail
++   * M\xnnjavax.ejb.FinderException
++   *     ...
++   * Z
++   * Z
++   * 
++ * ++ * @param code the fault code, a three digit ++ */ ++ public void writeFault(String code, String message, Object detail) ++ throws IOException ++ { ++ flushIfFull(); ++ ++ writeVersion(); ++ ++ _buffer[_offset++] = (byte) 'F'; ++ _buffer[_offset++] = (byte) 'H'; ++ ++ addRef(new Object(), _refCount++, false); ++ ++ writeString("code"); ++ writeString(code); ++ ++ writeString("message"); ++ writeString(message); ++ ++ if (detail != null) { ++ writeString("detail"); ++ writeObject(detail); ++ } ++ ++ flushIfFull(); ++ _buffer[_offset++] = (byte) 'Z'; ++ } ++ ++ /** ++ * Writes any object to the output stream. ++ */ ++ @Override ++ public void writeObject(Object object) ++ throws IOException ++ { ++ if (object == null) { ++ writeNull(); ++ return; ++ } ++ ++ Serializer serializer ++ = findSerializerFactory().getObjectSerializer(object.getClass()); ++ ++ serializer.writeObject(object, this); ++ } ++ ++ /** ++ * Writes the list header to the stream. List writers will call ++ * writeListBegin followed by the list contents and then ++ * call writeListEnd. ++ * ++ *
++   * list ::= V type value* Z
++   *      ::= v type int value*
++   * 
++ * ++ * @return true for variable lists, false for fixed lists ++ */ ++ public boolean writeListBegin(int length, String type) ++ throws IOException ++ { ++ flushIfFull(); ++ ++ if (length < 0) { ++ if (type != null) { ++ _buffer[_offset++] = (byte) BC_LIST_VARIABLE; ++ writeType(type); ++ } ++ else ++ _buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED; ++ ++ return true; ++ } ++ else if (length <= LIST_DIRECT_MAX) { ++ if (type != null) { ++ _buffer[_offset++] = (byte) (BC_LIST_DIRECT + length); ++ writeType(type); ++ } ++ else { ++ _buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length); ++ } ++ ++ return false; ++ } ++ else { ++ if (type != null) { ++ _buffer[_offset++] = (byte) BC_LIST_FIXED; ++ writeType(type); ++ } ++ else { ++ _buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED; ++ } ++ ++ writeInt(length); ++ ++ return false; ++ } ++ } ++ ++ /** ++ * Writes the tail of the list to the stream for a variable-length list. ++ */ ++ public void writeListEnd() ++ throws IOException ++ { ++ flushIfFull(); ++ ++ _buffer[_offset++] = (byte) BC_END; ++ } ++ ++ /** ++ * Writes the map header to the stream. Map writers will call ++ * writeMapBegin followed by the map contents and then ++ * call writeMapEnd. ++ * ++ *
++   * map ::= M type ( )* Z
++   *     ::= H ( )* Z
++   * 
++ */ ++ public void writeMapBegin(String type) ++ throws IOException ++ { ++ if (SIZE < _offset + 32) ++ flushBuffer(); ++ ++ if (type != null) { ++ _buffer[_offset++] = BC_MAP; ++ ++ writeType(type); ++ } ++ else ++ _buffer[_offset++] = BC_MAP_UNTYPED; ++ } ++ ++ /** ++ * Writes the tail of the map to the stream. ++ */ ++ public void writeMapEnd() ++ throws IOException ++ { ++ if (SIZE < _offset + 32) ++ flushBuffer(); ++ ++ _buffer[_offset++] = (byte) BC_END; ++ } ++ ++ /** ++ * Writes the object definition ++ * ++ *
++   * C <string> <int> <string>*
++   * 
++ */ ++ @Override ++ public int writeObjectBegin(String type) ++ throws IOException ++ { ++ int newRef = _classRefs.size(); ++ int ref = _classRefs.put(type, newRef, false); ++ ++ if (newRef != ref) { ++ if (SIZE < _offset + 32) ++ flushBuffer(); ++ ++ if (ref <= OBJECT_DIRECT_MAX) { ++ _buffer[_offset++] = (byte) (BC_OBJECT_DIRECT + ref); ++ } ++ else { ++ _buffer[_offset++] = (byte) 'O'; ++ writeInt(ref); ++ } ++ ++ return ref; ++ } ++ else { ++ if (SIZE < _offset + 32) ++ flushBuffer(); ++ ++ _buffer[_offset++] = (byte) 'C'; ++ ++ writeString(type); ++ ++ return -1; ++ } ++ } ++ ++ /** ++ * Writes the tail of the class definition to the stream. ++ */ ++ @Override ++ public void writeClassFieldLength(int len) ++ throws IOException ++ { ++ writeInt(len); ++ } ++ ++ /** ++ * Writes the tail of the object definition to the stream. ++ */ ++ @Override ++ public void writeObjectEnd() ++ throws IOException ++ { ++ } ++ ++ /** ++ *
++   * type ::= string
++   *      ::= int
++   * 
++ */ ++ private void writeType(String type) ++ throws IOException ++ { ++ flushIfFull(); ++ ++ int len = type.length(); ++ if (len == 0) { ++ throw new IllegalArgumentException("empty type is not allowed"); ++ } ++ ++ if (_typeRefs == null) ++ _typeRefs = new HashMap(); ++ ++ Integer typeRefV = (Integer) _typeRefs.get(type); ++ ++ if (typeRefV != null) { ++ int typeRef = typeRefV.intValue(); ++ ++ writeInt(typeRef); ++ } ++ else { ++ _typeRefs.put(type, Integer.valueOf(_typeRefs.size())); ++ ++ writeString(type); ++ } ++ } ++ ++ /** ++ * Writes a boolean value to the stream. The boolean will be written ++ * with the following syntax: ++ * ++ *
++   * T
++   * F
++   * 
++ * ++ * @param value the boolean value to write. ++ */ ++ @Override ++ public void writeBoolean(boolean value) ++ throws IOException ++ { ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ if (value) ++ _buffer[_offset++] = (byte) 'T'; ++ else ++ _buffer[_offset++] = (byte) 'F'; ++ } ++ ++ /** ++ * Writes an integer value to the stream. The integer will be written ++ * with the following syntax: ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ @Override ++ public void writeInt(int value) ++ throws IOException ++ { ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ if (SIZE <= offset + 16) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ if (INT_DIRECT_MIN <= value && value <= INT_DIRECT_MAX) ++ buffer[offset++] = (byte) (value + BC_INT_ZERO); ++ else if (INT_BYTE_MIN <= value && value <= INT_BYTE_MAX) { ++ buffer[offset++] = (byte) (BC_INT_BYTE_ZERO + (value >> 8)); ++ buffer[offset++] = (byte) (value); ++ } ++ else if (INT_SHORT_MIN <= value && value <= INT_SHORT_MAX) { ++ buffer[offset++] = (byte) (BC_INT_SHORT_ZERO + (value >> 16)); ++ buffer[offset++] = (byte) (value >> 8); ++ buffer[offset++] = (byte) (value); ++ } ++ else { ++ buffer[offset++] = (byte) ('I'); ++ buffer[offset++] = (byte) (value >> 24); ++ buffer[offset++] = (byte) (value >> 16); ++ buffer[offset++] = (byte) (value >> 8); ++ buffer[offset++] = (byte) (value); ++ } ++ ++ _offset = offset; ++ } ++ ++ /** ++ * Writes a long value to the stream. The long will be written ++ * with the following syntax: ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param value the long value to write. ++ */ ++ public void writeLong(long value) ++ throws IOException ++ { ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ if (SIZE <= offset + 16) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ if (LONG_DIRECT_MIN <= value && value <= LONG_DIRECT_MAX) { ++ buffer[offset++] = (byte) (value + BC_LONG_ZERO); ++ } ++ else if (LONG_BYTE_MIN <= value && value <= LONG_BYTE_MAX) { ++ buffer[offset++] = (byte) (BC_LONG_BYTE_ZERO + (value >> 8)); ++ buffer[offset++] = (byte) (value); ++ } ++ else if (LONG_SHORT_MIN <= value && value <= LONG_SHORT_MAX) { ++ buffer[offset++] = (byte) (BC_LONG_SHORT_ZERO + (value >> 16)); ++ buffer[offset++] = (byte) (value >> 8); ++ buffer[offset++] = (byte) (value); ++ } ++ else if (-0x80000000L <= value && value <= 0x7fffffffL) { ++ buffer[offset + 0] = (byte) BC_LONG_INT; ++ buffer[offset + 1] = (byte) (value >> 24); ++ buffer[offset + 2] = (byte) (value >> 16); ++ buffer[offset + 3] = (byte) (value >> 8); ++ buffer[offset + 4] = (byte) (value); ++ ++ offset += 5; ++ } ++ else { ++ buffer[offset + 0] = (byte) 'L'; ++ buffer[offset + 1] = (byte) (value >> 56); ++ buffer[offset + 2] = (byte) (value >> 48); ++ buffer[offset + 3] = (byte) (value >> 40); ++ buffer[offset + 4] = (byte) (value >> 32); ++ buffer[offset + 5] = (byte) (value >> 24); ++ buffer[offset + 6] = (byte) (value >> 16); ++ buffer[offset + 7] = (byte) (value >> 8); ++ buffer[offset + 8] = (byte) (value); ++ ++ offset += 9; ++ } ++ ++ _offset = offset; ++ } ++ ++ /** ++ * Writes a double value to the stream. The double will be written ++ * with the following syntax: ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param value the double value to write. ++ */ ++ public void writeDouble(double value) ++ throws IOException ++ { ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ if (SIZE <= offset + 16) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ int intValue = (int) value; ++ ++ if (intValue == value) { ++ if (intValue == 0) { ++ buffer[offset++] = (byte) BC_DOUBLE_ZERO; ++ ++ _offset = offset; ++ ++ return; ++ } ++ else if (intValue == 1) { ++ buffer[offset++] = (byte) BC_DOUBLE_ONE; ++ ++ _offset = offset; ++ ++ return; ++ } ++ else if (-0x80 <= intValue && intValue < 0x80) { ++ buffer[offset++] = (byte) BC_DOUBLE_BYTE; ++ buffer[offset++] = (byte) intValue; ++ ++ _offset = offset; ++ ++ return; ++ } ++ else if (-0x8000 <= intValue && intValue < 0x8000) { ++ buffer[offset + 0] = (byte) BC_DOUBLE_SHORT; ++ buffer[offset + 1] = (byte) (intValue >> 8); ++ buffer[offset + 2] = (byte) intValue; ++ ++ _offset = offset + 3; ++ ++ return; ++ } ++ } ++ ++ int mills = (int) (value * 1000); ++ ++ if (0.001 * mills == value) { ++ buffer[offset + 0] = (byte) (BC_DOUBLE_MILL); ++ buffer[offset + 1] = (byte) (mills >> 24); ++ buffer[offset + 2] = (byte) (mills >> 16); ++ buffer[offset + 3] = (byte) (mills >> 8); ++ buffer[offset + 4] = (byte) (mills); ++ ++ _offset = offset + 5; ++ ++ return; ++ } ++ ++ long bits = Double.doubleToLongBits(value); ++ ++ buffer[offset + 0] = (byte) 'D'; ++ buffer[offset + 1] = (byte) (bits >> 56); ++ buffer[offset + 2] = (byte) (bits >> 48); ++ buffer[offset + 3] = (byte) (bits >> 40); ++ buffer[offset + 4] = (byte) (bits >> 32); ++ buffer[offset + 5] = (byte) (bits >> 24); ++ buffer[offset + 6] = (byte) (bits >> 16); ++ buffer[offset + 7] = (byte) (bits >> 8); ++ buffer[offset + 8] = (byte) (bits); ++ ++ _offset = offset + 9; ++ } ++ ++ /** ++ * Writes a date to the stream. ++ * ++ *
++   * date ::= d   b7 b6 b5 b4 b3 b2 b1 b0
++   *      ::= x65 b3 b2 b1 b0
++   * 
++ * ++ * @param time the date in milliseconds from the epoch in UTC ++ */ ++ public void writeUTCDate(long time) ++ throws IOException ++ { ++ if (SIZE < _offset + 32) ++ flushBuffer(); ++ ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ if (time % 60000L == 0) { ++ // compact date ::= x65 b3 b2 b1 b0 ++ ++ long minutes = time / 60000L; ++ ++ if ((minutes >> 31) == 0 || (minutes >> 31) == -1) { ++ buffer[offset++] = (byte) BC_DATE_MINUTE; ++ buffer[offset++] = ((byte) (minutes >> 24)); ++ buffer[offset++] = ((byte) (minutes >> 16)); ++ buffer[offset++] = ((byte) (minutes >> 8)); ++ buffer[offset++] = ((byte) (minutes >> 0)); ++ ++ _offset = offset; ++ return; ++ } ++ } ++ ++ buffer[offset++] = (byte) BC_DATE; ++ buffer[offset++] = ((byte) (time >> 56)); ++ buffer[offset++] = ((byte) (time >> 48)); ++ buffer[offset++] = ((byte) (time >> 40)); ++ buffer[offset++] = ((byte) (time >> 32)); ++ buffer[offset++] = ((byte) (time >> 24)); ++ buffer[offset++] = ((byte) (time >> 16)); ++ buffer[offset++] = ((byte) (time >> 8)); ++ buffer[offset++] = ((byte) (time)); ++ ++ _offset = offset; ++ } ++ ++ /** ++ * Writes a null value to the stream. ++ * The null will be written with the following syntax ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeNull() ++ throws IOException ++ { ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ if (SIZE <= offset + 16) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ buffer[offset++] = 'N'; ++ ++ _offset = offset; ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(String value) ++ throws IOException ++ { ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ if (SIZE <= offset + 16) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ if (value == null) { ++ buffer[offset++] = (byte) 'N'; ++ ++ _offset = offset; ++ } ++ else { ++ int length = value.length(); ++ int strOffset = 0; ++ ++ while (length > 0x8000) { ++ int sublen = 0x8000; ++ ++ offset = _offset; ++ ++ if (SIZE <= offset + 16) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ // chunk can't end in high surrogate ++ char tail = value.charAt(strOffset + sublen - 1); ++ ++ if (0xd800 <= tail && tail <= 0xdbff) ++ sublen--; ++ ++ buffer[offset + 0] = (byte) BC_STRING_CHUNK; ++ buffer[offset + 1] = (byte) (sublen >> 8); ++ buffer[offset + 2] = (byte) (sublen); ++ ++ _offset = offset + 3; ++ ++ printString(value, strOffset, sublen); ++ ++ length -= sublen; ++ strOffset += sublen; ++ } ++ ++ offset = _offset; ++ ++ if (SIZE <= offset + 16) { ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ if (length <= STRING_DIRECT_MAX) { ++ buffer[offset++] = (byte) (BC_STRING_DIRECT + length); ++ } ++ else if (length <= STRING_SHORT_MAX) { ++ buffer[offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); ++ buffer[offset++] = (byte) (length); ++ } ++ else { ++ buffer[offset++] = (byte) ('S'); ++ buffer[offset++] = (byte) (length >> 8); ++ buffer[offset++] = (byte) (length); ++ } ++ ++ _offset = offset; ++ ++ printString(value, strOffset, length); ++ } ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(char []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ _buffer[_offset++] = (byte) ('N'); ++ } ++ else { ++ while (length > 0x8000) { ++ int sublen = 0x8000; ++ ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ // chunk can't end in high surrogate ++ char tail = buffer[offset + sublen - 1]; ++ ++ if (0xd800 <= tail && tail <= 0xdbff) ++ sublen--; ++ ++ _buffer[_offset++] = (byte) BC_STRING_CHUNK; ++ _buffer[_offset++] = (byte) (sublen >> 8); ++ _buffer[_offset++] = (byte) (sublen); ++ ++ printString(buffer, offset, sublen); ++ ++ length -= sublen; ++ offset += sublen; ++ } ++ ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ if (length <= STRING_DIRECT_MAX) { ++ _buffer[_offset++] = (byte) (BC_STRING_DIRECT + length); ++ } ++ else if (length <= STRING_SHORT_MAX) { ++ _buffer[_offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); ++ _buffer[_offset++] = (byte) length; ++ } ++ else { ++ _buffer[_offset++] = (byte) ('S'); ++ _buffer[_offset++] = (byte) (length >> 8); ++ _buffer[_offset++] = (byte) (length); ++ } ++ ++ printString(buffer, offset, length); ++ } ++ } ++ ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer) ++ throws IOException ++ { ++ if (buffer == null) { ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ _buffer[_offset++] = 'N'; ++ } ++ else ++ writeBytes(buffer, 0, buffer.length); ++ } ++ ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ _buffer[_offset++] = (byte) 'N'; ++ } ++ else { ++ while (SIZE - _offset - 3 < length) { ++ int sublen = SIZE - _offset - 3; ++ ++ if (sublen < 16) { ++ flushBuffer(); ++ ++ sublen = SIZE - _offset - 3; ++ ++ if (length < sublen) ++ sublen = length; ++ } ++ ++ _buffer[_offset++] = (byte) BC_BINARY_CHUNK; ++ _buffer[_offset++] = (byte) (sublen >> 8); ++ _buffer[_offset++] = (byte) sublen; ++ ++ System.arraycopy(buffer, offset, _buffer, _offset, sublen); ++ _offset += sublen; ++ ++ length -= sublen; ++ offset += sublen; ++ ++ flushBuffer(); ++ } ++ ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ if (length <= BINARY_DIRECT_MAX) { ++ _buffer[_offset++] = (byte) (BC_BINARY_DIRECT + length); ++ } ++ else if (length <= BINARY_SHORT_MAX) { ++ _buffer[_offset++] = (byte) (BC_BINARY_SHORT + (length >> 8)); ++ _buffer[_offset++] = (byte) (length); ++ } ++ else { ++ _buffer[_offset++] = (byte) 'B'; ++ _buffer[_offset++] = (byte) (length >> 8); ++ _buffer[_offset++] = (byte) (length); ++ } ++ ++ System.arraycopy(buffer, offset, _buffer, _offset, length); ++ ++ _offset += length; ++ } ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * 
++ */ ++ public void writeByteBufferStart() ++ throws IOException ++ { ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ */ ++ public void writeByteBufferPart(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ while (length > 0) { ++ flushIfFull(); ++ ++ int sublen = _buffer.length - _offset; ++ ++ if (length < sublen) ++ sublen = length; ++ ++ _buffer[_offset++] = BC_BINARY_CHUNK; ++ _buffer[_offset++] = (byte) (sublen >> 8); ++ _buffer[_offset++] = (byte) sublen; ++ ++ System.arraycopy(buffer, offset, _buffer, _offset, sublen); ++ ++ _offset += sublen; ++ length -= sublen; ++ offset += sublen; ++ } ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ */ ++ public void writeByteBufferEnd(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ writeBytes(buffer, offset, length); ++ } ++ ++ /** ++ * Returns an output stream to write binary data. ++ */ ++ public OutputStream getBytesOutputStream() ++ throws IOException ++ { ++ return new BytesOutputStream(); ++ } ++ ++ /** ++ * Writes a full output stream. ++ */ ++ @Override ++ public void writeByteStream(InputStream is) ++ throws IOException ++ { ++ while (true) { ++ int len = SIZE - _offset - 3; ++ ++ if (len < 16) { ++ flushBuffer(); ++ len = SIZE - _offset - 3; ++ } ++ ++ len = is.read(_buffer, _offset + 3, len); ++ ++ if (len <= 0) { ++ _buffer[_offset++] = BC_BINARY_DIRECT; ++ return; ++ } ++ ++ _buffer[_offset + 0] = (byte) BC_BINARY_CHUNK; ++ _buffer[_offset + 1] = (byte) (len >> 8); ++ _buffer[_offset + 2] = (byte) (len); ++ ++ _offset += len + 3; ++ } ++ } ++ ++ /** ++ * Writes a reference. ++ * ++ *
++   * x51 <int>
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ @Override ++ protected void writeRef(int value) ++ throws IOException ++ { ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ _buffer[_offset++] = (byte) BC_REF; ++ ++ writeInt(value); ++ } ++ ++ /** ++ * If the object has already been written, just write its ref. ++ * ++ * @return true if we're writing a ref. ++ */ ++ @Override ++ public boolean addRef(Object object) ++ throws IOException ++ { ++ if (_isUnshared) { ++ _refCount++; ++ return false; ++ } ++ ++ int newRef = _refCount; ++ ++ int ref = addRef(object, newRef, false); ++ ++ if (ref != newRef) { ++ writeRef(ref); ++ ++ return true; ++ } ++ else { ++ _refCount++; ++ ++ return false; ++ } ++ } ++ ++ @Override ++ public int getRef(Object obj) ++ { ++ if (_isUnshared) ++ return -1; ++ ++ return _refs.get(obj); ++ } ++ ++ /** ++ * Removes a reference. ++ */ ++ @Override ++ public boolean removeRef(Object obj) ++ throws IOException ++ { ++ if (_isUnshared) { ++ return false; ++ } ++ else if (_refs != null) { ++ _refs.remove(obj); ++ ++ return true; ++ } ++ else ++ return false; ++ } ++ ++ /** ++ * Replaces a reference from one object to another. ++ */ ++ @Override ++ public boolean replaceRef(Object oldRef, Object newRef) ++ throws IOException ++ { ++ if (_isUnshared) { ++ return false; ++ } ++ ++ int value = _refs.get(oldRef); ++ ++ if (value >= 0) { ++ addRef(newRef, value, true); ++ ++ _refs.remove(oldRef); ++ ++ return true; ++ } ++ else ++ return false; ++ } ++ ++ private int addRef(Object value, int newRef, boolean isReplace) ++ { ++ int prevRef = _refs.put(value, newRef, isReplace); ++ ++ return prevRef; ++ } ++ ++ /** ++ * Starts the streaming message ++ * ++ *

A streaming message starts with 'P'

++ * ++ *
++   * P x02 x00
++   * 
++ */ ++ public void writeStreamingObject(Object obj) ++ throws IOException ++ { ++ startPacket(); ++ ++ writeObject(obj); ++ ++ endPacket(); ++ } ++ ++ /** ++ * Starts a streaming packet ++ * ++ *

A streaming contains a set of chunks, ending with a zero chunk. ++ * Each chunk is a length followed by data where the length is ++ * encoded by (b1xxxxxxxx)* b0xxxxxxxx

++ */ ++ public void startPacket() ++ throws IOException ++ { ++ if (_refs != null) { ++ _refs.clear(); ++ _refCount = 0; ++ } ++ ++ flushBuffer(); ++ ++ _isPacket = true; ++ _offset = 4; ++ _buffer[0] = (byte) 0x05; // 0x05 = binary ++ _buffer[1] = (byte) 0x55; ++ _buffer[2] = (byte) 0x55; ++ _buffer[3] = (byte) 0x55; ++ } ++ ++ public void endPacket() ++ throws IOException ++ { ++ int offset = _offset; ++ ++ OutputStream os = _os; ++ ++ if (os == null) { ++ _offset = 0; ++ return; ++ } ++ ++ int len = offset - 4; ++ ++ if (len < 0x7e) { ++ _buffer[2] = _buffer[0]; ++ _buffer[3] = (byte) (len); ++ } else { ++ _buffer[1] = (byte) (0x7e); ++ _buffer[2] = (byte) (len >> 8); ++ _buffer[3] = (byte) (len); ++ } ++ ++ _isPacket = false; ++ _offset = 0; ++ ++ if (os == null) { ++ } ++ else if (len < 0x7e) { ++ os.write(_buffer, 2, offset - 2); ++ } ++ else { ++ os.write(_buffer, 0, offset); ++ } ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 with preceeding length ++ * ++ * @param v the string to print. ++ */ ++ public void printLenString(String v) ++ throws IOException ++ { ++ if (SIZE < _offset + 16) ++ flushBuffer(); ++ ++ if (v == null) { ++ _buffer[_offset++] = (byte) (0); ++ _buffer[_offset++] = (byte) (0); ++ } ++ else { ++ int len = v.length(); ++ _buffer[_offset++] = (byte) (len >> 8); ++ _buffer[_offset++] = (byte) (len); ++ ++ printString(v, 0, len); ++ } ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v) ++ throws IOException ++ { ++ printString(v, 0, v.length()); ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v, int strOffset, int length) ++ throws IOException ++ { ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ for (int i = 0; i < length; i++) { ++ if (SIZE <= offset + 16) { ++ _offset = offset; ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ char ch = v.charAt(i + strOffset); ++ ++ if (ch < 0x80) ++ buffer[offset++] = (byte) (ch); ++ else if (ch < 0x800) { ++ buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); ++ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); ++ } ++ else { ++ buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); ++ buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); ++ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); ++ } ++ } ++ ++ _offset = offset; ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(char []v, int strOffset, int length) ++ throws IOException ++ { ++ int offset = _offset; ++ byte []buffer = _buffer; ++ ++ for (int i = 0; i < length; i++) { ++ if (SIZE <= offset + 16) { ++ _offset = offset; ++ flushBuffer(); ++ offset = _offset; ++ } ++ ++ char ch = v[i + strOffset]; ++ ++ if (ch < 0x80) ++ buffer[offset++] = (byte) (ch); ++ else if (ch < 0x800) { ++ buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); ++ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); ++ } ++ else { ++ buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); ++ buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); ++ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); ++ } ++ } ++ ++ _offset = offset; ++ } ++ ++ private final void flushIfFull() ++ throws IOException ++ { ++ int offset = _offset; ++ ++ if (SIZE < offset + 32) { ++ flushBuffer(); ++ } ++ } ++ ++ public final void flush() ++ throws IOException ++ { ++ flushBuffer(); ++ ++ if (_os != null) ++ _os.flush(); ++ } ++ ++ public final void flushBuffer() ++ throws IOException ++ { ++ int offset = _offset; ++ ++ OutputStream os = _os; ++ ++ if (! _isPacket && offset > 0) { ++ _offset = 0; ++ if (os != null) ++ os.write(_buffer, 0, offset); ++ } ++ else if (_isPacket && offset > 4) { ++ int len = offset - 4; ++ ++ _buffer[0] |= (byte) 0x80; ++ _buffer[1] = (byte) (0x7e); ++ _buffer[2] = (byte) (len >> 8); ++ _buffer[3] = (byte) (len); ++ _offset = 4; ++ ++ if (os != null) ++ os.write(_buffer, 0, offset); ++ ++ _buffer[0] = (byte) 0x00; ++ _buffer[1] = (byte) 0x56; ++ _buffer[2] = (byte) 0x56; ++ _buffer[3] = (byte) 0x56; ++ } ++ } ++ ++ @Override ++ public void close() ++ throws IOException ++ { ++ // hessian/3a8c ++ flush(); ++ ++ OutputStream os = _os; ++ _os = null; ++ ++ if (os != null) { ++ if (_isCloseStreamOnClose) ++ os.close(); ++ } ++ } ++ ++ public void free() ++ { ++ reset(); ++ ++ _os = null; ++ _isCloseStreamOnClose = false; ++ } ++ ++ /** ++ * Resets the references for streaming. ++ */ ++ @Override ++ public void resetReferences() ++ { ++ if (_refs != null) { ++ _refs.clear(); ++ _refCount = 0; ++ } ++ } ++ ++ /** ++ * Resets all counters and references ++ */ ++ public void reset() ++ { ++ if (_refs != null) { ++ _refs.clear(); ++ _refCount = 0; ++ } ++ ++ _classRefs.clear(); ++ _typeRefs = null; ++ _offset = 0; ++ _isPacket = false; ++ _isUnshared = false; ++ } ++ ++ class BytesOutputStream extends OutputStream { ++ private int _startOffset; ++ ++ BytesOutputStream() ++ throws IOException ++ { ++ if (SIZE < _offset + 16) { ++ Hessian2Output.this.flushBuffer(); ++ } ++ ++ _startOffset = _offset; ++ _offset += 3; // skip 'b' xNN xNN ++ } ++ ++ @Override ++ public void write(int ch) ++ throws IOException ++ { ++ if (SIZE <= _offset) { ++ int length = (_offset - _startOffset) - 3; ++ ++ _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; ++ _buffer[_startOffset + 1] = (byte) (length >> 8); ++ _buffer[_startOffset + 2] = (byte) (length); ++ ++ Hessian2Output.this.flushBuffer(); ++ ++ _startOffset = _offset; ++ _offset += 3; ++ } ++ ++ _buffer[_offset++] = (byte) ch; ++ } ++ ++ @Override ++ public void write(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ while (length > 0) { ++ int sublen = SIZE - _offset; ++ ++ if (length < sublen) ++ sublen = length; ++ ++ if (sublen > 0) { ++ System.arraycopy(buffer, offset, _buffer, _offset, sublen); ++ _offset += sublen; ++ } ++ ++ length -= sublen; ++ offset += sublen; ++ ++ if (SIZE <= _offset) { ++ int chunkLength = (_offset - _startOffset) - 3; ++ ++ _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; ++ _buffer[_startOffset + 1] = (byte) (chunkLength >> 8); ++ _buffer[_startOffset + 2] = (byte) (chunkLength); ++ ++ Hessian2Output.this.flushBuffer(); ++ ++ _startOffset = _offset; ++ _offset += 3; ++ } ++ } ++ } ++ ++ @Override ++ public void close() ++ throws IOException ++ { ++ int startOffset = _startOffset; ++ _startOffset = -1; ++ ++ if (startOffset < 0) ++ return; ++ ++ int length = (_offset - startOffset) - 3; ++ ++ _buffer[startOffset] = (byte) 'B'; ++ _buffer[startOffset + 1] = (byte) (length >> 8); ++ _buffer[startOffset + 2] = (byte) (length); ++ ++ Hessian2Output.this.flushBuffer(); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingInput.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingInput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,288 +1,288 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +- +-import java.util.logging.*; +- +-/** +- * Input stream for Hessian 2 streaming requests using WebSocket. +- * +- * For best performance, use HessianFactory: +- * +- *
+- * HessianFactory factory = new HessianFactory();
+- * Hessian2StreamingInput hIn = factory.createHessian2StreamingInput(is);
+- * 
+- */ +-public class Hessian2StreamingInput +-{ +- private static final Logger log +- = Logger.getLogger(Hessian2StreamingInput.class.getName()); +- +- private StreamingInputStream _is; +- private Hessian2Input _in; +- +- /** +- * Creates a new Hessian input stream, initialized with an +- * underlying input stream. +- * +- * @param is the underlying output stream. +- */ +- public Hessian2StreamingInput(InputStream is) +- { +- _is = new StreamingInputStream(is); +- _in = new Hessian2Input(_is); +- } +- +- public void setSerializerFactory(SerializerFactory factory) +- { +- _in.setSerializerFactory(factory); +- } +- +- public boolean isDataAvailable() +- { +- StreamingInputStream is = _is; +- +- return is != null && is.isDataAvailable(); +- } +- +- public Hessian2Input startPacket() +- throws IOException +- { +- if (_is.startPacket()) { +- _in.resetReferences(); +- _in.resetBuffer(); // XXX: +- return _in; +- } +- else +- return null; +- } +- +- public void endPacket() +- throws IOException +- { +- _is.endPacket(); +- _in.resetBuffer(); // XXX: +- } +- +- public Hessian2Input getHessianInput() +- { +- return _in; +- } +- +- /** +- * Read the next object +- */ +- public Object readObject() +- throws IOException +- { +- _is.startPacket(); +- +- Object obj = _in.readStreamingObject(); +- +- _is.endPacket(); +- +- return obj; +- } +- +- /** +- * Close the output. +- */ +- public void close() +- throws IOException +- { +- _in.close(); +- } +- +- static class StreamingInputStream extends InputStream { +- private InputStream _is; +- +- private int _length; +- private boolean _isPacketEnd; +- +- StreamingInputStream(InputStream is) +- { +- _is = is; +- } +- +- public boolean isDataAvailable() +- { +- try { +- return _is != null && _is.available() > 0; +- } catch (IOException e) { +- log.log(Level.FINER, e.toString(), e); +- +- return true; +- } +- } +- +- public boolean startPacket() +- throws IOException +- { +- // skip zero-length packets +- do { +- _isPacketEnd = false; +- } while ((_length = readChunkLength(_is)) == 0); +- +- return _length > 0; +- } +- +- public void endPacket() +- throws IOException +- { +- while (! _isPacketEnd) { +- if (_length <= 0) +- _length = readChunkLength(_is); +- +- if (_length > 0) { +- _is.skip(_length); +- _length = 0; +- } +- } +- +- if (_length > 0) { +- _is.skip(_length); +- _length = 0; +- } +- } +- +- public int read() +- throws IOException +- { +- InputStream is = _is; +- +- if (_length == 0) { +- if (_isPacketEnd) +- return -1; +- +- _length = readChunkLength(is); +- +- if (_length <= 0) +- return -1; +- } +- +- _length--; +- +- return is.read(); +- } +- +- @Override +- public int read(byte []buffer, int offset, int length) +- throws IOException +- { +- InputStream is = _is; +- +- if (_length <= 0) { +- if (_isPacketEnd) +- return -1; +- +- _length = readChunkLength(is); +- +- if (_length <= 0) +- return -1; +- } +- +- int sublen = _length; +- if (length < sublen) +- sublen = length; +- +- sublen = is.read(buffer, offset, sublen); +- +- if (sublen < 0) +- return -1; +- +- _length -= sublen; +- +- return sublen; +- } +- +- private int readChunkLength(InputStream is) +- throws IOException +- { +- if (_isPacketEnd) +- return -1; +- +- int length = 0; +- +- int code = is.read(); +- +- if (code < 0) { +- _isPacketEnd = true; +- return -1; +- } +- +- _isPacketEnd = (code & 0x80) == 0; +- +- int len = is.read() & 0x7f; +- +- if (len < 0x7e) { +- length = len; +- } +- else if (len == 0x7e) { +- length = (((is.read() & 0xff) << 8) +- + (is.read() & 0xff)); +- } +- else { +- length = (((is.read() & 0xff) << 56) +- + ((is.read() & 0xff) << 48) +- + ((is.read() & 0xff) << 40) +- + ((is.read() & 0xff) << 32) +- + ((is.read() & 0xff) << 24) +- + ((is.read() & 0xff) << 16) +- + ((is.read() & 0xff) << 8) +- + ((is.read() & 0xff))); +- } +- +- return length; +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++ ++import java.util.logging.*; ++ ++/** ++ * Input stream for Hessian 2 streaming requests using WebSocket. ++ * ++ * For best performance, use HessianFactory: ++ * ++ *
++ * HessianFactory factory = new HessianFactory();
++ * Hessian2StreamingInput hIn = factory.createHessian2StreamingInput(is);
++ * 
++ */ ++public class Hessian2StreamingInput ++{ ++ private static final Logger log ++ = Logger.getLogger(Hessian2StreamingInput.class.getName()); ++ ++ private StreamingInputStream _is; ++ private Hessian2Input _in; ++ ++ /** ++ * Creates a new Hessian input stream, initialized with an ++ * underlying input stream. ++ * ++ * @param is the underlying output stream. ++ */ ++ public Hessian2StreamingInput(InputStream is) ++ { ++ _is = new StreamingInputStream(is); ++ _in = new Hessian2Input(_is); ++ } ++ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _in.setSerializerFactory(factory); ++ } ++ ++ public boolean isDataAvailable() ++ { ++ StreamingInputStream is = _is; ++ ++ return is != null && is.isDataAvailable(); ++ } ++ ++ public Hessian2Input startPacket() ++ throws IOException ++ { ++ if (_is.startPacket()) { ++ _in.resetReferences(); ++ _in.resetBuffer(); // XXX: ++ return _in; ++ } ++ else ++ return null; ++ } ++ ++ public void endPacket() ++ throws IOException ++ { ++ _is.endPacket(); ++ _in.resetBuffer(); // XXX: ++ } ++ ++ public Hessian2Input getHessianInput() ++ { ++ return _in; ++ } ++ ++ /** ++ * Read the next object ++ */ ++ public Object readObject() ++ throws IOException ++ { ++ _is.startPacket(); ++ ++ Object obj = _in.readStreamingObject(); ++ ++ _is.endPacket(); ++ ++ return obj; ++ } ++ ++ /** ++ * Close the output. ++ */ ++ public void close() ++ throws IOException ++ { ++ _in.close(); ++ } ++ ++ static class StreamingInputStream extends InputStream { ++ private InputStream _is; ++ ++ private int _length; ++ private boolean _isPacketEnd; ++ ++ StreamingInputStream(InputStream is) ++ { ++ _is = is; ++ } ++ ++ public boolean isDataAvailable() ++ { ++ try { ++ return _is != null && _is.available() > 0; ++ } catch (IOException e) { ++ log.log(Level.FINER, e.toString(), e); ++ ++ return true; ++ } ++ } ++ ++ public boolean startPacket() ++ throws IOException ++ { ++ // skip zero-length packets ++ do { ++ _isPacketEnd = false; ++ } while ((_length = readChunkLength(_is)) == 0); ++ ++ return _length > 0; ++ } ++ ++ public void endPacket() ++ throws IOException ++ { ++ while (! _isPacketEnd) { ++ if (_length <= 0) ++ _length = readChunkLength(_is); ++ ++ if (_length > 0) { ++ _is.skip(_length); ++ _length = 0; ++ } ++ } ++ ++ if (_length > 0) { ++ _is.skip(_length); ++ _length = 0; ++ } ++ } ++ ++ public int read() ++ throws IOException ++ { ++ InputStream is = _is; ++ ++ if (_length == 0) { ++ if (_isPacketEnd) ++ return -1; ++ ++ _length = readChunkLength(is); ++ ++ if (_length <= 0) ++ return -1; ++ } ++ ++ _length--; ++ ++ return is.read(); ++ } ++ ++ @Override ++ public int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ InputStream is = _is; ++ ++ if (_length <= 0) { ++ if (_isPacketEnd) ++ return -1; ++ ++ _length = readChunkLength(is); ++ ++ if (_length <= 0) ++ return -1; ++ } ++ ++ int sublen = _length; ++ if (length < sublen) ++ sublen = length; ++ ++ sublen = is.read(buffer, offset, sublen); ++ ++ if (sublen < 0) ++ return -1; ++ ++ _length -= sublen; ++ ++ return sublen; ++ } ++ ++ private int readChunkLength(InputStream is) ++ throws IOException ++ { ++ if (_isPacketEnd) ++ return -1; ++ ++ int length = 0; ++ ++ int code = is.read(); ++ ++ if (code < 0) { ++ _isPacketEnd = true; ++ return -1; ++ } ++ ++ _isPacketEnd = (code & 0x80) == 0; ++ ++ int len = is.read() & 0x7f; ++ ++ if (len < 0x7e) { ++ length = len; ++ } ++ else if (len == 0x7e) { ++ length = (((is.read() & 0xff) << 8) ++ + (is.read() & 0xff)); ++ } ++ else { ++ length = (((is.read() & 0xff) << 56) ++ + ((is.read() & 0xff) << 48) ++ + ((is.read() & 0xff) << 40) ++ + ((is.read() & 0xff) << 32) ++ + ((is.read() & 0xff) << 24) ++ + ((is.read() & 0xff) << 16) ++ + ((is.read() & 0xff) << 8) ++ + ((is.read() & 0xff))); ++ } ++ ++ return length; ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingOutput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,118 +1,118 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.OutputStream; +- +-/** +- * Output stream for Hessian 2 streaming requests. +- */ +-public class Hessian2StreamingOutput +-{ +- private Hessian2Output _out; +- +- /** +- * Creates a new Hessian output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public Hessian2StreamingOutput(OutputStream os) +- { +- _out = new Hessian2Output(os); +- } +- +- public Hessian2StreamingOutput(Hessian2Output out) +- { +- _out = out; +- } +- +- public Hessian2Output getHessian2Output() +- { +- return _out; +- } +- +- public void setCloseStreamOnClose(boolean isClose) +- { +- _out.setCloseStreamOnClose(isClose); +- } +- +- public boolean isCloseStreamOnClose() +- { +- return _out.isCloseStreamOnClose(); +- } +- +- /** +- * Writes any object to the output stream. +- */ +- public void writeObject(Object object) +- throws IOException +- { +- _out.writeStreamingObject(object); +- } +- +- /** +- * Flushes the output. +- */ +- public void flush() +- throws IOException +- { +- _out.flush(); +- } +- +- /** +- * Close the output. +- */ +- public void close() +- throws IOException +- { +- _out.close(); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++ ++/** ++ * Output stream for Hessian 2 streaming requests. ++ */ ++public class Hessian2StreamingOutput ++{ ++ private Hessian2Output _out; ++ ++ /** ++ * Creates a new Hessian output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public Hessian2StreamingOutput(OutputStream os) ++ { ++ _out = new Hessian2Output(os); ++ } ++ ++ public Hessian2StreamingOutput(Hessian2Output out) ++ { ++ _out = out; ++ } ++ ++ public Hessian2Output getHessian2Output() ++ { ++ return _out; ++ } ++ ++ public void setCloseStreamOnClose(boolean isClose) ++ { ++ _out.setCloseStreamOnClose(isClose); ++ } ++ ++ public boolean isCloseStreamOnClose() ++ { ++ return _out.isCloseStreamOnClose(); ++ } ++ ++ /** ++ * Writes any object to the output stream. ++ */ ++ public void writeObject(Object object) ++ throws IOException ++ { ++ _out.writeStreamingObject(object); ++ } ++ ++ /** ++ * Flushes the output. ++ */ ++ public void flush() ++ throws IOException ++ { ++ _out.flush(); ++ } ++ ++ /** ++ * Close the output. ++ */ ++ public void close() ++ throws IOException ++ { ++ _out.close(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugInputStream.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugInputStream.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugInputStream.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugInputStream.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,211 +1,211 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.Writer; +-import java.io.PrintWriter; +-import java.util.ArrayList; +- +-import java.util.logging.Logger; +-import java.util.logging.Level; +- +-/** +- * Debugging input stream for Hessian requests. +- */ +-public class HessianDebugInputStream extends InputStream +-{ +- private InputStream _is; +- +- private HessianDebugState _state; +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugInputStream(InputStream is, OutputStream os) +- { +- this(is, new PrintWriter(os)); +- } +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugInputStream(InputStream is, PrintWriter dbg) +- { +- _is = is; +- +- if (dbg == null) +- dbg = new PrintWriter(System.out); +- +- _state = new HessianDebugState(dbg); +- } +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugInputStream(InputStream is, Logger log, Level level) +- { +- this(is, new PrintWriter(new LogWriter(log, level))); +- } +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugInputStream(Logger log, Level level) +- { +- this(null, log, level); +- } +- +- public void initPacket(InputStream is) +- { +- _is = is; +- } +- +- public void startTop2() +- { +- _state.startTop2(); +- } +- +- public void startData1() +- { +- _state.startData1(); +- } +- +- public void startStreaming() +- { +- _state.startStreaming(); +- } +- +- public void setDepth(int depth) +- { +- _state.setDepth(depth); +- } +- +- /** +- * Reads a character. +- */ +- public int read() +- throws IOException +- { +- int ch; +- +- InputStream is = _is; +- +- if (is == null) +- return -1; +- else { +- ch = is.read(); +- } +- +- _state.next(ch); +- +- return ch; +- } +- +- /** +- * closes the stream. +- */ +- public void close() +- throws IOException +- { +- InputStream is = _is; +- _is = null; +- +- if (is != null) +- is.close(); +- +- _state.println(); +- } +- +- static class LogWriter extends Writer { +- private Logger _log; +- private Level _level; +- private StringBuilder _sb = new StringBuilder(); +- +- LogWriter(Logger log, Level level) +- { +- _log = log; +- _level = level; +- } +- +- public void write(char ch) +- { +- if (ch == '\n' && _sb.length() > 0) { +- _log.log(_level, _sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- +- public void write(char []buffer, int offset, int length) +- { +- for (int i = 0; i < length; i++) { +- char ch = buffer[offset + i]; +- +- if (ch == '\n' && _sb.length() > 0) { +- _log.log(_level, _sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- } +- +- public void flush() +- { +- } +- +- public void close() +- { +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.Writer; ++import java.io.PrintWriter; ++import java.util.ArrayList; ++ ++import java.util.logging.Logger; ++import java.util.logging.Level; ++ ++/** ++ * Debugging input stream for Hessian requests. ++ */ ++public class HessianDebugInputStream extends InputStream ++{ ++ private InputStream _is; ++ ++ private HessianDebugState _state; ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugInputStream(InputStream is, OutputStream os) ++ { ++ this(is, new PrintWriter(os)); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugInputStream(InputStream is, PrintWriter dbg) ++ { ++ _is = is; ++ ++ if (dbg == null) ++ dbg = new PrintWriter(System.out); ++ ++ _state = new HessianDebugState(dbg); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugInputStream(InputStream is, Logger log, Level level) ++ { ++ this(is, new PrintWriter(new LogWriter(log, level))); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugInputStream(Logger log, Level level) ++ { ++ this(null, log, level); ++ } ++ ++ public void initPacket(InputStream is) ++ { ++ _is = is; ++ } ++ ++ public void startTop2() ++ { ++ _state.startTop2(); ++ } ++ ++ public void startData1() ++ { ++ _state.startData1(); ++ } ++ ++ public void startStreaming() ++ { ++ _state.startStreaming(); ++ } ++ ++ public void setDepth(int depth) ++ { ++ _state.setDepth(depth); ++ } ++ ++ /** ++ * Reads a character. ++ */ ++ public int read() ++ throws IOException ++ { ++ int ch; ++ ++ InputStream is = _is; ++ ++ if (is == null) ++ return -1; ++ else { ++ ch = is.read(); ++ } ++ ++ _state.next(ch); ++ ++ return ch; ++ } ++ ++ /** ++ * closes the stream. ++ */ ++ public void close() ++ throws IOException ++ { ++ InputStream is = _is; ++ _is = null; ++ ++ if (is != null) ++ is.close(); ++ ++ _state.println(); ++ } ++ ++ static class LogWriter extends Writer { ++ private Logger _log; ++ private Level _level; ++ private StringBuilder _sb = new StringBuilder(); ++ ++ LogWriter(Logger log, Level level) ++ { ++ _log = log; ++ _level = level; ++ } ++ ++ public void write(char ch) ++ { ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.log(_level, _sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ ++ public void write(char []buffer, int offset, int length) ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = buffer[offset + i]; ++ ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.log(_level, _sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ } ++ ++ public void flush() ++ { ++ } ++ ++ public void close() ++ { ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugOutputStream.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugOutputStream.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugOutputStream.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugOutputStream.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,198 +1,198 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.OutputStream; +-import java.io.Writer; +-import java.io.PrintWriter; +- +-import java.util.logging.Logger; +-import java.util.logging.Level; +- +-/** +- * Debugging output stream for Hessian requests. +- */ +-public class HessianDebugOutputStream extends OutputStream +-{ +- private static final Logger log +- = Logger.getLogger(HessianDebugOutputStream.class.getName()); +- +- private OutputStream _os; +- +- private HessianDebugState _state; +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugOutputStream(OutputStream os, PrintWriter dbg) +- { +- _os = os; +- +- _state = new HessianDebugState(dbg); +- } +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugOutputStream(OutputStream os, Logger log, Level level) +- { +- this(os, new PrintWriter(new LogWriter(log, level))); +- } +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugOutputStream(Logger log, Level level) +- { +- this(null, new PrintWriter(new LogWriter(log, level))); +- } +- +- public void initPacket(OutputStream os) +- { +- _os = os; +- } +- +- public void startTop2() +- { +- _state.startTop2(); +- } +- +- public void startStreaming() +- { +- _state.startStreaming(); +- } +- +- /** +- * Writes a character. +- */ +- @Override +- public void write(int ch) +- throws IOException +- { +- ch = ch & 0xff; +- +- _os.write(ch); +- +- try { +- _state.next(ch); +- } catch (Exception e) { +- log.log(Level.WARNING, e.toString(), e); +- } +- } +- +- @Override +- public void flush() +- throws IOException +- { +- _os.flush(); +- } +- +- /** +- * closes the stream. +- */ +- @Override +- public void close() +- throws IOException +- { +- OutputStream os = _os; +- _os = null; +- +- if (os != null) { +- _state.next(-1); +- os.close(); +- } +- +- _state.println(); +- } +- +- static class LogWriter extends Writer { +- private Logger _log; +- private Level _level; +- private StringBuilder _sb = new StringBuilder(); +- +- LogWriter(Logger log, Level level) +- { +- _log = log; +- _level = level; +- } +- +- public void write(char ch) +- { +- if (ch == '\n' && _sb.length() > 0) { +- _log.log(_level, _sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- +- public void write(char []buffer, int offset, int length) +- { +- for (int i = 0; i < length; i++) { +- char ch = buffer[offset + i]; +- +- if (ch == '\n' && _sb.length() > 0) { +- _log.log(_level, _sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- } +- +- public void flush() +- { +- } +- +- public void close() +- { +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++import java.io.Writer; ++import java.io.PrintWriter; ++ ++import java.util.logging.Logger; ++import java.util.logging.Level; ++ ++/** ++ * Debugging output stream for Hessian requests. ++ */ ++public class HessianDebugOutputStream extends OutputStream ++{ ++ private static final Logger log ++ = Logger.getLogger(HessianDebugOutputStream.class.getName()); ++ ++ private OutputStream _os; ++ ++ private HessianDebugState _state; ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugOutputStream(OutputStream os, PrintWriter dbg) ++ { ++ _os = os; ++ ++ _state = new HessianDebugState(dbg); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugOutputStream(OutputStream os, Logger log, Level level) ++ { ++ this(os, new PrintWriter(new LogWriter(log, level))); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugOutputStream(Logger log, Level level) ++ { ++ this(null, new PrintWriter(new LogWriter(log, level))); ++ } ++ ++ public void initPacket(OutputStream os) ++ { ++ _os = os; ++ } ++ ++ public void startTop2() ++ { ++ _state.startTop2(); ++ } ++ ++ public void startStreaming() ++ { ++ _state.startStreaming(); ++ } ++ ++ /** ++ * Writes a character. ++ */ ++ @Override ++ public void write(int ch) ++ throws IOException ++ { ++ ch = ch & 0xff; ++ ++ _os.write(ch); ++ ++ try { ++ _state.next(ch); ++ } catch (Exception e) { ++ log.log(Level.WARNING, e.toString(), e); ++ } ++ } ++ ++ @Override ++ public void flush() ++ throws IOException ++ { ++ _os.flush(); ++ } ++ ++ /** ++ * closes the stream. ++ */ ++ @Override ++ public void close() ++ throws IOException ++ { ++ OutputStream os = _os; ++ _os = null; ++ ++ if (os != null) { ++ _state.next(-1); ++ os.close(); ++ } ++ ++ _state.println(); ++ } ++ ++ static class LogWriter extends Writer { ++ private Logger _log; ++ private Level _level; ++ private StringBuilder _sb = new StringBuilder(); ++ ++ LogWriter(Logger log, Level level) ++ { ++ _log = log; ++ _level = level; ++ } ++ ++ public void write(char ch) ++ { ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.log(_level, _sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ ++ public void write(char []buffer, int offset, int length) ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = buffer[offset + i]; ++ ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.log(_level, _sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ } ++ ++ public void flush() ++ { ++ } ++ ++ public void close() ++ { ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugState.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugState.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugState.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugState.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,2527 +1,2527 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.PrintWriter; +-import java.util.ArrayList; +-import java.util.logging.Logger; +- +-/** +- * Debugging input stream for Hessian requests. +- */ +-public class HessianDebugState implements Hessian2Constants +-{ +- private static final Logger log +- = Logger.getLogger(HessianDebugState.class.getName()); +- +- private PrintWriter _dbg; +- +- private State _state; +- private ArrayList _stateStack = new ArrayList(); +- +- private ArrayList _objectDefList +- = new ArrayList(); +- +- private ArrayList _typeDefList +- = new ArrayList(); +- +- private int _refId; +- private boolean _isNewline = true; +- private boolean _isObject = false; +- private int _column; +- +- private int _depth = 0; +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianDebugState(PrintWriter dbg) +- { +- _dbg = dbg; +- +- _state = new InitialState(); +- } +- +- public void startTop2() +- { +- _state = new Top2State(); +- } +- +- public void startData1() +- { +- _state = new InitialState1(); +- } +- +- public void startStreaming() +- { +- _state = new StreamingState(new InitialState(), false); +- } +- +- /** +- * Reads a character. +- */ +- public void next(int ch) +- throws IOException +- { +- _state = _state.next(ch); +- } +- +- void pushStack(State state) +- { +- _stateStack.add(state); +- } +- +- State popStack() +- { +- return _stateStack.remove(_stateStack.size() - 1); +- } +- +- public void setDepth(int depth) +- { +- _depth = depth; +- } +- +- public int getDepth() +- { +- return _depth; +- } +- +- void println() +- { +- if (! _isNewline) { +- _dbg.println(); +- _dbg.flush(); +- } +- +- _isNewline = true; +- _column = 0; +- } +- +- static boolean isString(int ch) +- { +- switch (ch) { +- case 0x00: case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- +- case 'R': +- case 'S': +- return true; +- +- default: +- return false; +- } +- } +- +- static boolean isInteger(int ch) +- { +- switch (ch) { +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc8: case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd4: case 0xd5: case 0xd6: case 0xd7: +- +- case 'I': +- return true; +- +- default: +- return false; +- } +- } +- +- abstract class State { +- State _next; +- +- State() +- { +- } +- +- State(State next) +- { +- _next = next; +- } +- +- abstract State next(int ch); +- +- boolean isShift(Object value) +- { +- return false; +- } +- +- State shift(Object value) +- { +- return this; +- } +- +- int depth() +- { +- if (_next != null) +- return _next.depth(); +- else +- return HessianDebugState.this.getDepth(); +- } +- +- void printIndent(int depth) +- { +- if (_isNewline) { +- for (int i = _column; i < depth() + depth; i++) { +- _dbg.print(" "); +- _column++; +- } +- } +- } +- +- void print(String string) +- { +- print(0, string); +- } +- +- void print(int depth, String string) +- { +- printIndent(depth); +- +- _dbg.print(string); +- _isNewline = false; +- _isObject = false; +- +- int p = string.lastIndexOf('\n'); +- if (p > 0) +- _column = string.length() - p - 1; +- else +- _column += string.length(); +- } +- +- void println(String string) +- { +- println(0, string); +- } +- +- void println(int depth, String string) +- { +- printIndent(depth); +- +- _dbg.println(string); +- _dbg.flush(); +- _isNewline = true; +- _isObject = false; +- _column = 0; +- } +- +- void println() +- { +- if (! _isNewline) { +- _dbg.println(); +- _dbg.flush(); +- } +- +- _isNewline = true; +- _isObject = false; +- _column = 0; +- } +- +- void printObject(String string) +- { +- if (_isObject) +- println(); +- +- printIndent(0); +- +- _dbg.print(string); +- _dbg.flush(); +- +- _column += string.length(); +- +- _isNewline = false; +- _isObject = true; +- } +- +- protected State nextObject(int ch) +- { +- switch (ch) { +- case -1: +- println(); +- return this; +- +- case 'N': +- if (isShift(null)) +- return shift(null); +- else { +- printObject("null"); +- return this; +- } +- +- case 'T': +- if (isShift(Boolean.TRUE)) +- return shift(Boolean.TRUE); +- else { +- printObject("true"); +- return this; +- } +- +- case 'F': +- if (isShift(Boolean.FALSE)) +- return shift(Boolean.FALSE); +- else { +- printObject("false"); +- return this; +- } +- +- case 0x80: case 0x81: case 0x82: case 0x83: +- case 0x84: case 0x85: case 0x86: case 0x87: +- case 0x88: case 0x89: case 0x8a: case 0x8b: +- case 0x8c: case 0x8d: case 0x8e: case 0x8f: +- +- case 0x90: case 0x91: case 0x92: case 0x93: +- case 0x94: case 0x95: case 0x96: case 0x97: +- case 0x98: case 0x99: case 0x9a: case 0x9b: +- case 0x9c: case 0x9d: case 0x9e: case 0x9f: +- +- case 0xa0: case 0xa1: case 0xa2: case 0xa3: +- case 0xa4: case 0xa5: case 0xa6: case 0xa7: +- case 0xa8: case 0xa9: case 0xaa: case 0xab: +- case 0xac: case 0xad: case 0xae: case 0xaf: +- +- case 0xb0: case 0xb1: case 0xb2: case 0xb3: +- case 0xb4: case 0xb5: case 0xb6: case 0xb7: +- case 0xb8: case 0xb9: case 0xba: case 0xbb: +- case 0xbc: case 0xbd: case 0xbe: case 0xbf: +- { +- Integer value = new Integer(ch - 0x90); +- +- if (isShift(value)) +- return shift(value); +- else { +- printObject(value.toString()); +- return this; +- } +- } +- +- case 0xc0: case 0xc1: case 0xc2: case 0xc3: +- case 0xc4: case 0xc5: case 0xc6: case 0xc7: +- case 0xc8: case 0xc9: case 0xca: case 0xcb: +- case 0xcc: case 0xcd: case 0xce: case 0xcf: +- return new IntegerState(this, "int", ch - 0xc8, 3); +- +- case 0xd0: case 0xd1: case 0xd2: case 0xd3: +- case 0xd4: case 0xd5: case 0xd6: case 0xd7: +- return new IntegerState(this, "int", ch - 0xd4, 2); +- +- case 'I': +- return new IntegerState(this, "int"); +- +- case 0xd8: case 0xd9: case 0xda: case 0xdb: +- case 0xdc: case 0xdd: case 0xde: case 0xdf: +- case 0xe0: case 0xe1: case 0xe2: case 0xe3: +- case 0xe4: case 0xe5: case 0xe6: case 0xe7: +- case 0xe8: case 0xe9: case 0xea: case 0xeb: +- case 0xec: case 0xed: case 0xee: case 0xef: +- { +- Long value = new Long(ch - 0xe0); +- +- if (isShift(value)) +- return shift(value); +- else { +- printObject(value.toString() + "L"); +- return this; +- } +- } +- +- case 0xf0: case 0xf1: case 0xf2: case 0xf3: +- case 0xf4: case 0xf5: case 0xf6: case 0xf7: +- case 0xf8: case 0xf9: case 0xfa: case 0xfb: +- case 0xfc: case 0xfd: case 0xfe: case 0xff: +- return new LongState(this, "long", ch - 0xf8, 7); +- +- case 0x38: case 0x39: case 0x3a: case 0x3b: +- case 0x3c: case 0x3d: case 0x3e: case 0x3f: +- return new LongState(this, "long", ch - 0x3c, 6); +- +- case BC_LONG_INT: +- return new LongState(this, "long", 0, 4); +- +- case 'L': +- return new LongState(this, "long"); +- +- case 0x5b: case 0x5c: +- { +- Double value = new Double(ch - 0x5b); +- +- if (isShift(value)) +- return shift(value); +- else { +- printObject(value.toString()); +- return this; +- } +- } +- +- case 0x5d: +- return new DoubleIntegerState(this, 3); +- +- case 0x5e: +- return new DoubleIntegerState(this, 2); +- +- case 0x5f: +- return new MillsState(this); +- +- case 'D': +- return new DoubleState(this); +- +- case 'Q': +- return new RefState(this); +- +- case BC_DATE: +- return new DateState(this); +- +- case BC_DATE_MINUTE: +- return new DateState(this, true); +- +- case 0x00: +- { +- String value = "\"\""; +- +- if (isShift(value)) +- return shift(value); +- else { +- printObject(value.toString()); +- return this; +- } +- } +- +- case 0x01: case 0x02: case 0x03: +- case 0x04: case 0x05: case 0x06: case 0x07: +- case 0x08: case 0x09: case 0x0a: case 0x0b: +- case 0x0c: case 0x0d: case 0x0e: case 0x0f: +- +- case 0x10: case 0x11: case 0x12: case 0x13: +- case 0x14: case 0x15: case 0x16: case 0x17: +- case 0x18: case 0x19: case 0x1a: case 0x1b: +- case 0x1c: case 0x1d: case 0x1e: case 0x1f: +- return new StringState(this, 'S', ch); +- +- case 0x30: case 0x31: case 0x32: case 0x33: +- return new StringState(this, 'S', ch - 0x30, true); +- +- case 'R': +- return new StringState(this, 'S', false); +- +- case 'S': +- return new StringState(this, 'S', true); +- +- case 0x20: +- { +- String value = "binary(0)"; +- +- if (isShift(value)) +- return shift(value); +- else { +- printObject(value.toString()); +- return this; +- } +- } +- +- case 0x21: case 0x22: case 0x23: +- case 0x24: case 0x25: case 0x26: case 0x27: +- case 0x28: case 0x29: case 0x2a: case 0x2b: +- case 0x2c: case 0x2d: case 0x2e: case 0x2f: +- return new BinaryState(this, 'B', ch - 0x20); +- +- case 0x34: case 0x35: case 0x36: case 0x37: +- return new BinaryState(this, 'B', ch - 0x34, true); +- +- case 'A': +- return new BinaryState(this, 'B', false); +- +- case 'B': +- return new BinaryState(this, 'B', true); +- +- case 'M': +- return new MapState(this, _refId++); +- +- case 'H': +- return new MapState(this, _refId++, false); +- +- case BC_LIST_VARIABLE: +- return new ListState(this, _refId++, true); +- +- case BC_LIST_VARIABLE_UNTYPED: +- return new ListState(this, _refId++, false); +- +- case BC_LIST_FIXED: +- return new CompactListState(this, _refId++, true); +- +- case BC_LIST_FIXED_UNTYPED: +- return new CompactListState(this, _refId++, false); +- +- case 0x70: case 0x71: case 0x72: case 0x73: +- case 0x74: case 0x75: case 0x76: case 0x77: +- return new CompactListState(this, _refId++, true, ch - 0x70); +- +- case 0x78: case 0x79: case 0x7a: case 0x7b: +- case 0x7c: case 0x7d: case 0x7e: case 0x7f: +- return new CompactListState(this, _refId++, false, ch - 0x78); +- +- case 'C': +- return new ObjectDefState(this); +- +- case 0x60: case 0x61: case 0x62: case 0x63: +- case 0x64: case 0x65: case 0x66: case 0x67: +- case 0x68: case 0x69: case 0x6a: case 0x6b: +- case 0x6c: case 0x6d: case 0x6e: case 0x6f: +- return new ObjectState(this, _refId++, ch - 0x60); +- +- case 'O': +- return new ObjectState(this, _refId++); +- +- default: +- return this; +- } +- } +- } +- +- abstract class State1 extends State { +- State1() +- { +- } +- +- State1(State next) +- { +- super(next); +- } +- +- protected State nextObject(int ch) +- { +- switch (ch) { +- case -1: +- println(); +- return this; +- +- case 'N': +- if (isShift(null)) +- return shift(null); +- else { +- printObject("null"); +- return this; +- } +- +- case 'T': +- if (isShift(Boolean.TRUE)) +- return shift(Boolean.TRUE); +- else { +- printObject("true"); +- return this; +- } +- +- case 'F': +- if (isShift(Boolean.FALSE)) +- return shift(Boolean.FALSE); +- else { +- printObject("false"); +- return this; +- } +- +- case 'I': +- return new IntegerState(this, "int"); +- +- case 'L': +- return new LongState(this, "long"); +- +- case 'D': +- return new DoubleState(this); +- +- case 'Q': +- return new RefState(this); +- +- case 'd': +- return new DateState(this); +- +- case 's': +- return new StringState(this, 'S', false); +- +- case 'S': +- return new StringState(this, 'S', true); +- +- case 'b': +- case 'A': +- return new BinaryState(this, 'B', false); +- +- case 'B': +- return new BinaryState(this, 'B', true); +- +- case 'M': +- return new MapState1(this, _refId++); +- +- case 'V': +- return new ListState1(this, _refId++); +- +- case 'R': +- return new IntegerState(new RefState1(this), "ref"); +- +- default: +- printObject("x" + String.format("%02x", ch)); +- return this; +- } +- } +- } +- +- class InitialState extends State { +- State next(int ch) +- { +- return nextObject(ch); +- } +- } +- +- class InitialState1 extends State1 { +- State next(int ch) +- { +- return nextObject(ch); +- } +- } +- +- class Top1State extends State1 { +- State next(int ch) +- { +- println(); +- +- if (ch == 'r') { +- return new ReplyState1(this); +- } +- else if (ch == 'c') { +- return new CallState1(this); +- } +- else +- return nextObject(ch); +- } +- } +- +- class Top2State extends State { +- State next(int ch) +- { +- println(); +- +- if (ch == 'R') { +- return new Reply2State(this); +- } +- else if (ch == 'F') { +- return new Fault2State(this); +- } +- else if (ch == 'C') { +- return new Call2State(this); +- } +- else if (ch == 'H') { +- return new Hessian2State(this); +- } +- else if (ch == 'r') { +- return new ReplyState1(this); +- } +- else if (ch == 'c') { +- return new CallState1(this); +- } +- else +- return nextObject(ch); +- } +- } +- +- class IntegerState extends State { +- String _typeCode; +- +- int _length; +- int _value; +- +- IntegerState(State next, String typeCode) +- { +- super(next); +- +- _typeCode = typeCode; +- } +- +- IntegerState(State next, String typeCode, int value, int length) +- { +- super(next); +- +- _typeCode = typeCode; +- +- _value = value; +- _length = length; +- } +- +- State next(int ch) +- { +- _value = 256 * _value + (ch & 0xff); +- +- if (++_length == 4) { +- Integer value = new Integer(_value); +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value.toString()); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class LongState extends State { +- String _typeCode; +- +- int _length; +- long _value; +- +- LongState(State next, String typeCode) +- { +- super(next); +- +- _typeCode = typeCode; +- } +- +- LongState(State next, String typeCode, long value, int length) +- { +- super(next); +- +- _typeCode = typeCode; +- +- _value = value; +- _length = length; +- } +- +- State next(int ch) +- { +- _value = 256 * _value + (ch & 0xff); +- +- if (++_length == 8) { +- Long value = new Long(_value); +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value.toString() + "L"); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class DoubleIntegerState extends State { +- int _length; +- int _value; +- boolean _isFirst = true; +- +- DoubleIntegerState(State next, int length) +- { +- super(next); +- +- _length = length; +- } +- +- State next(int ch) +- { +- if (_isFirst) +- _value = (byte) ch; +- else +- _value = 256 * _value + (ch & 0xff); +- +- _isFirst = false; +- +- if (++_length == 4) { +- Double value = new Double(_value); +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value.toString()); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class RefState extends State { +- String _typeCode; +- +- int _length; +- int _value; +- +- RefState(State next) +- { +- super(next); +- } +- +- RefState(State next, String typeCode) +- { +- super(next); +- +- _typeCode = typeCode; +- } +- +- RefState(State next, String typeCode, int value, int length) +- { +- super(next); +- +- _typeCode = typeCode; +- +- _value = value; +- _length = length; +- } +- +- @Override +- boolean isShift(Object o) +- { +- return true; +- } +- +- @Override +- State shift(Object o) +- { +- println("ref #" + o); +- +- return _next; +- } +- +- @Override +- State next(int ch) +- { +- return nextObject(ch); +- } +- } +- +- class RefState1 extends State { +- String _typeCode; +- +- RefState1(State next) +- { +- super(next); +- } +- +- @Override +- boolean isShift(Object o) +- { +- return true; +- } +- +- @Override +- State shift(Object o) +- { +- println("ref #" + o); +- +- return _next; +- } +- +- @Override +- State next(int ch) +- { +- return nextObject(ch); +- } +- } +- +- class DateState extends State { +- int _length; +- long _value; +- boolean _isMinute; +- +- DateState(State next) +- { +- super(next); +- } +- +- DateState(State next, boolean isMinute) +- { +- super(next); +- +- _length = 4; +- _isMinute = isMinute; +- } +- +- +- State next(int ch) +- { +- _value = 256 * _value + (ch & 0xff); +- +- if (++_length == 8) { +- java.util.Date value; +- +- if (_isMinute) +- value = new java.util.Date(_value * 60000L); +- else +- value = new java.util.Date(_value); +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value.toString()); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class DoubleState extends State { +- int _length; +- long _value; +- +- DoubleState(State next) +- { +- super(next); +- } +- +- State next(int ch) +- { +- _value = 256 * _value + (ch & 0xff); +- +- if (++_length == 8) { +- Double value = Double.longBitsToDouble(_value); +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value.toString()); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class MillsState extends State { +- int _length; +- int _value; +- +- MillsState(State next) +- { +- super(next); +- } +- +- State next(int ch) +- { +- _value = 256 * _value + (ch & 0xff); +- +- if (++_length == 4) { +- Double value = 0.001 * _value; +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value.toString()); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class StringState extends State { +- private static final int TOP = 0; +- private static final int UTF_2_1 = 1; +- private static final int UTF_3_1 = 2; +- private static final int UTF_3_2 = 3; +- +- char _typeCode; +- +- StringBuilder _value = new StringBuilder(); +- int _lengthIndex; +- int _length; +- boolean _isLastChunk; +- +- int _utfState; +- char _ch; +- +- StringState(State next, char typeCode, boolean isLastChunk) +- { +- super(next); +- +- _typeCode = typeCode; +- _isLastChunk = isLastChunk; +- } +- +- StringState(State next, char typeCode, int length) +- { +- super(next); +- +- _typeCode = typeCode; +- _isLastChunk = true; +- _length = length; +- _lengthIndex = 2; +- } +- +- StringState(State next, char typeCode, int length, boolean isLastChunk) +- { +- super(next); +- +- _typeCode = typeCode; +- _isLastChunk = isLastChunk; +- _length = length; +- _lengthIndex = 1; +- } +- +- State next(int ch) +- { +- if (_lengthIndex < 2) { +- _length = 256 * _length + (ch & 0xff); +- +- if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { +- if (_next.isShift(_value.toString())) +- return _next.shift(_value.toString()); +- else { +- printObject("\"" + _value + "\""); +- return _next; +- } +- } +- else +- return this; +- } +- else if (_length == 0) { +- if (ch == 's' || ch == 'x') { +- _isLastChunk = false; +- _lengthIndex = 0; +- return this; +- } +- else if (ch == 'S' || ch == 'X') { +- _isLastChunk = true; +- _lengthIndex = 0; +- return this; +- } +- else if (ch == 0x00) { +- if (_next.isShift(_value.toString())) +- return _next.shift(_value.toString()); +- else { +- printObject("\"" + _value + "\""); +- return _next; +- } +- } +- else if (0x00 <= ch && ch < 0x20) { +- _isLastChunk = true; +- _lengthIndex = 2; +- _length = ch & 0xff; +- return this; +- } +- else if (0x30 <= ch && ch < 0x34) { +- _isLastChunk = true; +- _lengthIndex = 1; +- _length = (ch - 0x30); +- return this; +- } +- else { +- println(this + " " + String.valueOf((char) ch) + ": unexpected character"); +- return _next; +- } +- } +- +- switch (_utfState) { +- case TOP: +- if (ch < 0x80) { +- _length--; +- +- _value.append((char) ch); +- } +- else if (ch < 0xe0) { +- _ch = (char) ((ch & 0x1f) << 6); +- _utfState = UTF_2_1; +- } +- else { +- _ch = (char) ((ch & 0xf) << 12); +- _utfState = UTF_3_1; +- } +- break; +- +- case UTF_2_1: +- case UTF_3_2: +- _ch += ch & 0x3f; +- _value.append(_ch); +- _length--; +- _utfState = TOP; +- break; +- +- case UTF_3_1: +- _ch += (char) ((ch & 0x3f) << 6); +- _utfState = UTF_3_2; +- break; +- } +- +- if (_length == 0 && _isLastChunk) { +- if (_next.isShift(_value.toString())) +- return _next.shift(_value.toString()); +- else { +- printObject("\"" + _value + "\""); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class BinaryState extends State { +- char _typeCode; +- +- int _totalLength; +- +- int _lengthIndex; +- int _length; +- boolean _isLastChunk; +- +- BinaryState(State next, char typeCode, boolean isLastChunk) +- { +- super(next); +- +- _typeCode = typeCode; +- _isLastChunk = isLastChunk; +- } +- +- BinaryState(State next, char typeCode, int length) +- { +- super(next); +- +- _typeCode = typeCode; +- _isLastChunk = true; +- _length = length; +- _lengthIndex = 2; +- } +- +- BinaryState(State next, char typeCode, int length, boolean isLastChunk) +- { +- super(next); +- +- _typeCode = typeCode; +- _isLastChunk = isLastChunk; +- _length = length; +- _lengthIndex = 1; +- } +- +- @Override +- State next(int ch) +- { +- if (_lengthIndex < 2) { +- _length = 256 * _length + (ch & 0xff); +- +- if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { +- String value = "binary(" + _totalLength + ")"; +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value); +- return _next; +- } +- } +- else +- return this; +- } +- else if (_length == 0) { +- if (ch == 'b' || ch == 'A') { +- _isLastChunk = false; +- _lengthIndex = 0; +- return this; +- } +- else if (ch == 'B') { +- _isLastChunk = true; +- _lengthIndex = 0; +- return this; +- } +- else if (ch == 0x20) { +- String value = "binary(" + _totalLength + ")"; +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value); +- return _next; +- } +- } +- else if (0x20 <= ch && ch < 0x30) { +- _isLastChunk = true; +- _lengthIndex = 2; +- _length = (ch & 0xff) - 0x20; +- return this; +- } +- else { +- println(this + " 0x" + Integer.toHexString(ch) + " " + String.valueOf((char) ch) + ": unexpected character"); +- return _next; +- } +- } +- +- _length--; +- _totalLength++; +- +- if (_length == 0 && _isLastChunk) { +- String value = "binary(" + _totalLength + ")"; +- +- if (_next.isShift(value)) +- return _next.shift(value); +- else { +- printObject(value); +- +- return _next; +- } +- } +- else +- return this; +- } +- } +- +- class MapState extends State { +- private static final int TYPE = 0; +- private static final int KEY = 1; +- private static final int VALUE = 2; +- +- private int _refId; +- +- private int _state; +- private int _valueDepth; +- private boolean _hasData; +- +- MapState(State next, int refId) +- { +- super(next); +- +- _refId = refId; +- _state = TYPE; +- } +- +- MapState(State next, int refId, boolean isType) +- { +- super(next); +- +- _refId = refId; +- +- if (isType) +- _state = TYPE; +- else { +- printObject("map (#" + _refId + ")"); +- _state = VALUE; +- } +- } +- +- @Override +- boolean isShift(Object value) +- { +- return _state == TYPE; +- } +- +- @Override +- State shift(Object type) +- { +- if (_state == TYPE) { +- if (type instanceof String) { +- _typeDefList.add((String) type); +- } +- else if (type instanceof Integer) { +- int iValue = (Integer) type; +- +- if (iValue >= 0 && iValue < _typeDefList.size()) +- type = _typeDefList.get(iValue); +- } +- +- printObject("map " + type + " (#" + _refId + ")"); +- +- _state = VALUE; +- +- return this; +- } +- else { +- printObject(this + " unknown shift state= " + _state + " type=" + type); +- +- return this; +- } +- } +- +- @Override +- int depth() +- { +- if (_state == TYPE) +- return _next.depth(); +- else if (_state == KEY) +- return _next.depth() + 2; +- else +- return _valueDepth; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- return nextObject(ch); +- +- case VALUE: +- if (ch == 'Z') { +- if (_hasData) +- println(); +- +- return _next; +- } +- else { +- if (_hasData) +- println(); +- +- _hasData = true; +- _state = KEY; +- +- return nextObject(ch); +- } +- +- case KEY: +- print(" => "); +- _isObject = false; +- _valueDepth = _column; +- +- _state = VALUE; +- +- return nextObject(ch); +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class MapState1 extends State1 { +- private static final int TYPE = 0; +- private static final int KEY = 1; +- private static final int VALUE = 2; +- +- private int _refId; +- +- private int _state; +- private int _valueDepth; +- private boolean _hasData; +- +- MapState1(State next, int refId) +- { +- super(next); +- +- _refId = refId; +- _state = TYPE; +- } +- +- MapState1(State next, int refId, boolean isType) +- { +- super(next); +- +- _refId = refId; +- +- if (isType) +- _state = TYPE; +- else { +- printObject("map (#" + _refId + ")"); +- _state = VALUE; +- } +- } +- +- @Override +- boolean isShift(Object value) +- { +- return _state == TYPE; +- } +- +- @Override +- State shift(Object type) +- { +- if (_state == TYPE) { +- if (type instanceof String) { +- _typeDefList.add((String) type); +- } +- else if (type instanceof Integer) { +- int iValue = (Integer) type; +- +- if (iValue >= 0 && iValue < _typeDefList.size()) +- type = _typeDefList.get(iValue); +- } +- +- printObject("map " + type + " (#" + _refId + ")"); +- +- _state = VALUE; +- +- return this; +- } +- else +- throw new IllegalStateException(); +- } +- +- @Override +- int depth() +- { +- if (_state == TYPE) +- return _next.depth(); +- else if (_state == KEY) +- return _next.depth() + 2; +- else +- return _valueDepth; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- if (ch == 't') { +- return new StringState(this, 't', true); +- } +- else if (ch == 'z') { +- println("map (#" + _refId + ")"); +- return _next; +- } +- else { +- println("map (#" + _refId + ")"); +- _hasData = true; +- _state = KEY; +- return nextObject(ch); +- } +- +- case VALUE: +- if (ch == 'z') { +- if (_hasData) +- println(); +- +- return _next; +- } +- else { +- if (_hasData) +- println(); +- +- _hasData = true; +- _state = KEY; +- +- return nextObject(ch); +- } +- +- case KEY: +- print(" => "); +- _isObject = false; +- _valueDepth = _column; +- +- _state = VALUE; +- +- return nextObject(ch); +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class ObjectDefState extends State { +- private static final int TYPE = 1; +- private static final int COUNT = 2; +- private static final int FIELD = 3; +- private static final int COMPLETE = 4; +- +- private int _state; +- private int _count; +- +- private String _type; +- private ArrayList _fields = new ArrayList(); +- +- ObjectDefState(State next) +- { +- super(next); +- +- _state = TYPE; +- } +- +- @Override +- boolean isShift(Object value) +- { +- return true; +- } +- +- @Override +- State shift(Object object) +- { +- if (_state == TYPE) { +- _type = (String) object; +- +- print("/* defun " + _type + " ["); +- +- _objectDefList.add(new ObjectDef(_type, _fields)); +- +- _state = COUNT; +- } +- else if (_state == COUNT) { +- _count = (Integer) object; +- +- _state = FIELD; +- } +- else if (_state == FIELD) { +- String field = (String) object; +- +- _count--; +- +- _fields.add(field); +- +- if (_fields.size() == 1) +- print(field); +- else +- print(", " + field); +- } +- else { +- throw new UnsupportedOperationException(); +- } +- +- return this; +- } +- +- @Override +- int depth() +- { +- if (_state <= TYPE) +- return _next.depth(); +- else +- return _next.depth() + 2; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- return nextObject(ch); +- +- case COUNT: +- return nextObject(ch); +- +- case FIELD: +- if (_count == 0) { +- println("] */"); +- _next.printIndent(0); +- +- return _next.nextObject(ch); +- } +- else +- return nextObject(ch); +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class ObjectState extends State { +- private static final int TYPE = 0; +- private static final int FIELD = 1; +- +- private int _refId; +- +- private int _state; +- private ObjectDef _def; +- private int _count; +- private int _fieldDepth; +- +- ObjectState(State next, int refId) +- { +- super(next); +- +- _refId = refId; +- _state = TYPE; +- } +- +- ObjectState(State next, int refId, int def) +- { +- super(next); +- +- _refId = refId; +- _state = FIELD; +- +- if (def < 0 || _objectDefList.size() <= def) { +- log.warning(this + " " + def + " is an unknown object type"); +- +- println(this + " object unknown (#" + _refId + ")"); +- } +- +- _def = _objectDefList.get(def); +- +- if (_isObject) +- println(); +- +- println("object " + _def.getType() + " (#" + _refId + ")"); +- } +- +- @Override +- boolean isShift(Object value) +- { +- if (_state == TYPE) +- return true; +- else +- return false; +- } +- +- @Override +- State shift(Object object) +- { +- if (_state == TYPE) { +- int def = (Integer) object; +- +- _def = _objectDefList.get(def); +- +- println("object " + _def.getType() + " (#" + _refId + ")"); +- +- _state = FIELD; +- +- if (_def.getFields().size() == 0) +- return _next; +- } +- +- return this; +- } +- +- @Override +- int depth() +- { +- if (_state <= TYPE) +- return _next.depth(); +- else +- return _fieldDepth; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- return nextObject(ch); +- +- case FIELD: +- if (_def.getFields().size() <= _count) +- return _next.next(ch); +- +- _fieldDepth = _next.depth() + 2; +- println(); +- print(_def.getFields().get(_count++) + ": "); +- +- _fieldDepth = _column; +- +- _isObject = false; +- return nextObject(ch); +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class ListState1 extends State1 { +- private static final int TYPE = 0; +- private static final int LENGTH = 1; +- private static final int VALUE = 2; +- +- private int _refId; +- +- private int _state; +- private int _count; +- private int _valueDepth; +- +- ListState1(State next, int refId) +- { +- super(next); +- +- _refId = refId; +- +- _state = TYPE; +- } +- +- @Override +- boolean isShift(Object value) +- { +- return _state == TYPE || _state == LENGTH; +- } +- +- @Override +- State shift(Object object) +- { +- if (_state == TYPE) { +- Object type = object; +- +- if (type instanceof String) { +- _typeDefList.add((String) type); +- } +- else if (object instanceof Integer) { +- int index = (Integer) object; +- +- if (index >= 0 && index < _typeDefList.size()) +- type = _typeDefList.get(index); +- else +- type = "type-unknown(" + index + ")"; +- } +- +- printObject("list " + type + "(#" + _refId + ")"); +- +- _state = VALUE; +- +- return this; +- } +- else if (_state == LENGTH) { +- _state = VALUE; +- +- return this; +- } +- else +- return this; +- } +- +- @Override +- int depth() +- { +- if (_state <= LENGTH) +- return _next.depth(); +- else if (_state == VALUE) +- return _valueDepth; +- else +- return _next.depth() + 2; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- if (ch == 'z') { +- printObject("list (#" + _refId + ")"); +- +- return _next; +- } +- else if (ch == 't') { +- return new StringState(this, 't', true); +- } +- else { +- printObject("list (#" + _refId + ")"); +- printObject(" " + _count++ + ": "); +- _valueDepth = _column; +- _isObject = false; +- _state = VALUE; +- +- return nextObject(ch); +- } +- +- case VALUE: +- if (ch == 'z') { +- if (_count > 0) +- println(); +- +- return _next; +- } +- else { +- _valueDepth = _next.depth() + 2; +- println(); +- printObject(_count++ + ": "); +- _valueDepth = _column; +- _isObject = false; +- +- return nextObject(ch); +- } +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class ListState extends State { +- private static final int TYPE = 0; +- private static final int LENGTH = 1; +- private static final int VALUE = 2; +- +- private int _refId; +- +- private int _state; +- private int _count; +- private int _valueDepth; +- +- ListState(State next, int refId, boolean isType) +- { +- super(next); +- +- _refId = refId; +- +- if (isType) +- _state = TYPE; +- else { +- printObject("list (#" + _refId + ")"); +- _state = VALUE; +- } +- } +- +- @Override +- boolean isShift(Object value) +- { +- return _state == TYPE || _state == LENGTH; +- } +- +- @Override +- State shift(Object object) +- { +- if (_state == TYPE) { +- Object type = object; +- +- if (type instanceof String) { +- _typeDefList.add((String) type); +- } +- else if (object instanceof Integer) { +- int index = (Integer) object; +- +- if (index >= 0 && index < _typeDefList.size()) +- type = _typeDefList.get(index); +- else +- type = "type-unknown(" + index + ")"; +- } +- +- printObject("list " + type + "(#" + _refId + ")"); +- +- _state = VALUE; +- +- return this; +- } +- else if (_state == LENGTH) { +- _state = VALUE; +- +- return this; +- } +- else +- return this; +- } +- +- @Override +- int depth() +- { +- if (_state <= LENGTH) +- return _next.depth(); +- else if (_state == VALUE) +- return _valueDepth; +- else +- return _next.depth() + 2; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- return nextObject(ch); +- +- case VALUE: +- if (ch == 'Z') { +- if (_count > 0) +- println(); +- +- return _next; +- } +- else { +- _valueDepth = _next.depth() + 2; +- println(); +- printObject(_count++ + ": "); +- _valueDepth = _column; +- _isObject = false; +- +- return nextObject(ch); +- } +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class CompactListState extends State { +- private static final int TYPE = 0; +- private static final int LENGTH = 1; +- private static final int VALUE = 2; +- +- private int _refId; +- +- private boolean _isTyped; +- private boolean _isLength; +- +- private int _state; +- private int _length; +- private int _count; +- private int _valueDepth; +- +- CompactListState(State next, int refId, boolean isTyped) +- { +- super(next); +- +- _isTyped = isTyped; +- _refId = refId; +- +- if (isTyped) +- _state = TYPE; +- else +- _state = LENGTH; +- } +- +- CompactListState(State next, int refId, boolean isTyped, int length) +- { +- super(next); +- +- _isTyped = isTyped; +- _refId = refId; +- _length = length; +- +- _isLength = true; +- +- if (isTyped) +- _state = TYPE; +- else { +- printObject("list (#" + _refId + ")"); +- +- _state = VALUE; +- } +- } +- +- @Override +- boolean isShift(Object value) +- { +- return _state == TYPE || _state == LENGTH; +- } +- +- @Override +- State shift(Object object) +- { +- if (_state == TYPE) { +- Object type = object; +- +- if (object instanceof Integer) { +- int index = (Integer) object; +- +- if (index >= 0 && index < _typeDefList.size()) +- type = _typeDefList.get(index); +- else +- type = "type-unknown(" + index + ")"; +- } +- else if (object instanceof String) +- _typeDefList.add((String) object); +- +- printObject("list " + type + " (#" + _refId + ")"); +- +- if (_isLength) { +- _state = VALUE; +- +- if (_length == 0) +- return _next; +- } +- else +- _state = LENGTH; +- +- return this; +- } +- else if (_state == LENGTH) { +- _length = (Integer) object; +- +- if (! _isTyped) +- printObject("list (#" + _refId + ")"); +- +- _state = VALUE; +- +- if (_length == 0) +- return _next; +- else +- return this; +- } +- else +- return this; +- } +- +- @Override +- int depth() +- { +- if (_state <= LENGTH) +- return _next.depth(); +- else if (_state == VALUE) +- return _valueDepth; +- else +- return _next.depth() + 2; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- return nextObject(ch); +- +- case LENGTH: +- return nextObject(ch); +- +- case VALUE: +- if (_length <= _count) +- return _next.next(ch); +- else { +- _valueDepth = _next.depth() + 2; +- println(); +- printObject(_count++ + ": "); +- _valueDepth = _column; +- _isObject = false; +- +- return nextObject(ch); +- } +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class Hessian2State extends State { +- private static final int MAJOR = 0; +- private static final int MINOR = 1; +- +- private int _state; +- private int _major; +- private int _minor; +- +- Hessian2State(State next) +- { +- super(next); +- } +- +- int depth() +- { +- return _next.depth() + 2; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case MAJOR: +- _major = ch; +- _state = MINOR; +- return this; +- +- case MINOR: +- _minor = ch; +- println(-2, "Hessian " + _major + "." + _minor); +- return _next; +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class CallState1 extends State1 { +- private static final int MAJOR = 0; +- private static final int MINOR = 1; +- private static final int HEADER = 2; +- private static final int METHOD = 3; +- private static final int VALUE = 4; +- private static final int ARG = 5; +- +- private int _state; +- private int _major; +- private int _minor; +- +- CallState1(State next) +- { +- super(next); +- } +- +- int depth() +- { +- return _next.depth() + 2; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case MAJOR: +- _major = ch; +- _state = MINOR; +- return this; +- +- case MINOR: +- _minor = ch; +- _state = HEADER; +- println(-2, "call " + _major + "." + _minor); +- return this; +- +- case HEADER: +- if (ch == 'H') { +- println(); +- print("header "); +- _isObject = false; +- _state = VALUE; +- return new StringState(this, 'H', true); +- } +- else if (ch == 'm') { +- println(); +- print("method "); +- _isObject = false; +- _state = ARG; +- return new StringState(this, 'm', true); +- } +- else { +- println((char) ch + ": unexpected char"); +- return popStack(); +- } +- +- case VALUE: +- print(" => "); +- _isObject = false; +- _state = HEADER; +- return nextObject(ch); +- +- case ARG: +- if (ch == 'z') { +- println(); +- return _next; +- } +- else +- return nextObject(ch); +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class Call2State extends State { +- private static final int METHOD = 0; +- private static final int COUNT = 1; +- private static final int ARG = 2; +- +- private int _state = METHOD; +- private int _i; +- private int _count; +- +- Call2State(State next) +- { +- super(next); +- } +- +- int depth() +- { +- return _next.depth() + 5; +- } +- +- @Override +- boolean isShift(Object value) +- { +- return _state != ARG; +- } +- +- @Override +- State shift(Object object) +- { +- if (_state == METHOD) { +- println(-5, "Call " + object); +- +- _state = COUNT; +- return this; +- } +- else if (_state == COUNT) { +- Integer count = (Integer) object; +- +- _count = count; +- +- _state = ARG; +- +- if (_count == 0) { +- return _next; +- } +- else +- return this; +- } +- else { +- return this; +- } +- } +- +- @Override +- State next(int ch) +- { +- switch (_state) { +- case COUNT: +- return nextObject(ch); +- +- case METHOD: +- return nextObject(ch); +- +- case ARG: +- if (_count <= _i) { +- println(); +- return _next.next(ch); +- } +- else { +- println(); +- print(-3, _i++ + ": "); +- +- return nextObject(ch); +- } +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class ReplyState1 extends State1 { +- private static final int MAJOR = 0; +- private static final int MINOR = 1; +- private static final int HEADER = 2; +- private static final int VALUE = 3; +- private static final int END = 4; +- +- private int _state; +- private int _major; +- private int _minor; +- +- ReplyState1(State next) +- { +- _next = next; +- } +- +- int depth() +- { +- return _next.depth() + 2; +- } +- +- State next(int ch) +- { +- switch (_state) { +- case MAJOR: +- if (ch == 't' || ch == 'S') +- return new RemoteState(this).next(ch); +- +- _major = ch; +- _state = MINOR; +- return this; +- +- case MINOR: +- _minor = ch; +- _state = HEADER; +- println(-2, "reply " + _major + "." + _minor); +- return this; +- +- case HEADER: +- if (ch == 'H') { +- _state = VALUE; +- return new StringState(this, 'H', true); +- } +- else if (ch == 'f') { +- print("fault "); +- _isObject = false; +- _state = END; +- return new MapState(this, 0); +- } +- else { +- _state = END; +- return nextObject(ch); +- } +- +- case VALUE: +- _state = HEADER; +- return nextObject(ch); +- +- case END: +- println(); +- if (ch == 'z') { +- return _next; +- } +- else +- return _next.next(ch); +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class Reply2State extends State { +- Reply2State(State next) +- { +- super(next); +- +- println(-2, "Reply"); +- } +- +- int depth() +- { +- return _next.depth() + 2; +- } +- +- @Override +- State next(int ch) +- { +- if (ch < 0) { +- println(); +- return _next; +- } +- else { +- return nextObject(ch); +- } +- } +- } +- +- class Fault2State extends State { +- Fault2State(State next) +- { +- super(next); +- +- println(-2, "Fault"); +- } +- +- int depth() +- { +- return _next.depth() + 2; +- } +- +- @Override +- State next(int ch) +- { +- return nextObject(ch); +- } +- } +- +- class IndirectState extends State { +- IndirectState(State next) +- { +- super(next); +- } +- +- boolean isShift(Object object) +- { +- return _next.isShift(object); +- } +- +- State shift(Object object) +- { +- return _next.shift(object); +- } +- +- State next(int ch) +- { +- return nextObject(ch); +- } +- } +- +- class RemoteState extends State { +- private static final int TYPE = 0; +- private static final int VALUE = 1; +- private static final int END = 2; +- +- private int _state; +- private int _major; +- private int _minor; +- +- RemoteState(State next) +- { +- super(next); +- } +- +- @Override +- State next(int ch) +- { +- switch (_state) { +- case TYPE: +- println(-1, "remote"); +- if (ch == 't') { +- _state = VALUE; +- return new StringState(this, 't', false); +- } +- else { +- _state = END; +- return nextObject(ch); +- } +- +- case VALUE: +- _state = END; +- return _next.nextObject(ch); +- +- case END: +- return _next.next(ch); +- +- default: +- throw new IllegalStateException(); +- } +- } +- } +- +- class StreamingState extends State { +- private long _length; +- private int _metaLength; +- private boolean _isLast; +- private boolean _isFirst = true; +- +- private boolean _isLengthState; +- +- private State _childState; +- +- StreamingState(State next, boolean isLast) +- { +- super(next); +- +- _isLast = isLast; +- _childState = new InitialState(); +- } +- +- State next(int ch) +- { +- if (_metaLength > 0) { +- _length = 256 * _length + ch; +- _metaLength--; +- +- if (_metaLength == 0 && _isFirst) { +- if (_isLast) +- println(-1, "--- packet-start(" + _length + ")"); +- else +- println(-1, "--- packet-start(fragment)"); +- _isFirst = false; +- } +- +- return this; +- } +- +- if (_length > 0) { +- _length--; +- _childState = _childState.next(ch); +- +- return this; +- } +- +- if (! _isLengthState) { +- _isLengthState = true; +- +- if (_isLast) { +- println(-1, ""); +- println(-1, "--- packet-end"); +- _refId = 0; +- +- _isFirst = true; +- } +- +- _isLast = (ch & 0x80) == 0x00; +- _isLengthState = true; +- } +- else { +- _isLengthState = false; +- _length = (ch & 0x7f); +- +- if (_length == 0x7e) { +- _length = 0; +- _metaLength = 2; +- } +- else if (_length == 0x7f) { +- _length = 0; +- _metaLength = 8; +- } +- else { +- if (_isFirst) { +- if (_isLast) +- println(-1, "--- packet-start(" + _length + ")"); +- else +- println(-1, "--- packet-start(fragment)"); +- _isFirst = false; +- } +- } +- } +- +- return this; +- } +- } +- +- static class ObjectDef { +- private String _type; +- private ArrayList _fields; +- +- ObjectDef(String type, ArrayList fields) +- { +- _type = type; +- _fields = fields; +- } +- +- String getType() +- { +- return _type; +- } +- +- ArrayList getFields() +- { +- return _fields; +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.PrintWriter; ++import java.util.ArrayList; ++import java.util.logging.Logger; ++ ++/** ++ * Debugging input stream for Hessian requests. ++ */ ++public class HessianDebugState implements Hessian2Constants ++{ ++ private static final Logger log ++ = Logger.getLogger(HessianDebugState.class.getName()); ++ ++ private PrintWriter _dbg; ++ ++ private State _state; ++ private ArrayList _stateStack = new ArrayList(); ++ ++ private ArrayList _objectDefList ++ = new ArrayList(); ++ ++ private ArrayList _typeDefList ++ = new ArrayList(); ++ ++ private int _refId; ++ private boolean _isNewline = true; ++ private boolean _isObject = false; ++ private int _column; ++ ++ private int _depth = 0; ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianDebugState(PrintWriter dbg) ++ { ++ _dbg = dbg; ++ ++ _state = new InitialState(); ++ } ++ ++ public void startTop2() ++ { ++ _state = new Top2State(); ++ } ++ ++ public void startData1() ++ { ++ _state = new InitialState1(); ++ } ++ ++ public void startStreaming() ++ { ++ _state = new StreamingState(new InitialState(), false); ++ } ++ ++ /** ++ * Reads a character. ++ */ ++ public void next(int ch) ++ throws IOException ++ { ++ _state = _state.next(ch); ++ } ++ ++ void pushStack(State state) ++ { ++ _stateStack.add(state); ++ } ++ ++ State popStack() ++ { ++ return _stateStack.remove(_stateStack.size() - 1); ++ } ++ ++ public void setDepth(int depth) ++ { ++ _depth = depth; ++ } ++ ++ public int getDepth() ++ { ++ return _depth; ++ } ++ ++ void println() ++ { ++ if (! _isNewline) { ++ _dbg.println(); ++ _dbg.flush(); ++ } ++ ++ _isNewline = true; ++ _column = 0; ++ } ++ ++ static boolean isString(int ch) ++ { ++ switch (ch) { ++ case 0x00: case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ ++ case 'R': ++ case 'S': ++ return true; ++ ++ default: ++ return false; ++ } ++ } ++ ++ static boolean isInteger(int ch) ++ { ++ switch (ch) { ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc8: case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd4: case 0xd5: case 0xd6: case 0xd7: ++ ++ case 'I': ++ return true; ++ ++ default: ++ return false; ++ } ++ } ++ ++ abstract class State { ++ State _next; ++ ++ State() ++ { ++ } ++ ++ State(State next) ++ { ++ _next = next; ++ } ++ ++ abstract State next(int ch); ++ ++ boolean isShift(Object value) ++ { ++ return false; ++ } ++ ++ State shift(Object value) ++ { ++ return this; ++ } ++ ++ int depth() ++ { ++ if (_next != null) ++ return _next.depth(); ++ else ++ return HessianDebugState.this.getDepth(); ++ } ++ ++ void printIndent(int depth) ++ { ++ if (_isNewline) { ++ for (int i = _column; i < depth() + depth; i++) { ++ _dbg.print(" "); ++ _column++; ++ } ++ } ++ } ++ ++ void print(String string) ++ { ++ print(0, string); ++ } ++ ++ void print(int depth, String string) ++ { ++ printIndent(depth); ++ ++ _dbg.print(string); ++ _isNewline = false; ++ _isObject = false; ++ ++ int p = string.lastIndexOf('\n'); ++ if (p > 0) ++ _column = string.length() - p - 1; ++ else ++ _column += string.length(); ++ } ++ ++ void println(String string) ++ { ++ println(0, string); ++ } ++ ++ void println(int depth, String string) ++ { ++ printIndent(depth); ++ ++ _dbg.println(string); ++ _dbg.flush(); ++ _isNewline = true; ++ _isObject = false; ++ _column = 0; ++ } ++ ++ void println() ++ { ++ if (! _isNewline) { ++ _dbg.println(); ++ _dbg.flush(); ++ } ++ ++ _isNewline = true; ++ _isObject = false; ++ _column = 0; ++ } ++ ++ void printObject(String string) ++ { ++ if (_isObject) ++ println(); ++ ++ printIndent(0); ++ ++ _dbg.print(string); ++ _dbg.flush(); ++ ++ _column += string.length(); ++ ++ _isNewline = false; ++ _isObject = true; ++ } ++ ++ protected State nextObject(int ch) ++ { ++ switch (ch) { ++ case -1: ++ println(); ++ return this; ++ ++ case 'N': ++ if (isShift(null)) ++ return shift(null); ++ else { ++ printObject("null"); ++ return this; ++ } ++ ++ case 'T': ++ if (isShift(Boolean.TRUE)) ++ return shift(Boolean.TRUE); ++ else { ++ printObject("true"); ++ return this; ++ } ++ ++ case 'F': ++ if (isShift(Boolean.FALSE)) ++ return shift(Boolean.FALSE); ++ else { ++ printObject("false"); ++ return this; ++ } ++ ++ case 0x80: case 0x81: case 0x82: case 0x83: ++ case 0x84: case 0x85: case 0x86: case 0x87: ++ case 0x88: case 0x89: case 0x8a: case 0x8b: ++ case 0x8c: case 0x8d: case 0x8e: case 0x8f: ++ ++ case 0x90: case 0x91: case 0x92: case 0x93: ++ case 0x94: case 0x95: case 0x96: case 0x97: ++ case 0x98: case 0x99: case 0x9a: case 0x9b: ++ case 0x9c: case 0x9d: case 0x9e: case 0x9f: ++ ++ case 0xa0: case 0xa1: case 0xa2: case 0xa3: ++ case 0xa4: case 0xa5: case 0xa6: case 0xa7: ++ case 0xa8: case 0xa9: case 0xaa: case 0xab: ++ case 0xac: case 0xad: case 0xae: case 0xaf: ++ ++ case 0xb0: case 0xb1: case 0xb2: case 0xb3: ++ case 0xb4: case 0xb5: case 0xb6: case 0xb7: ++ case 0xb8: case 0xb9: case 0xba: case 0xbb: ++ case 0xbc: case 0xbd: case 0xbe: case 0xbf: ++ { ++ Integer value = new Integer(ch - 0x90); ++ ++ if (isShift(value)) ++ return shift(value); ++ else { ++ printObject(value.toString()); ++ return this; ++ } ++ } ++ ++ case 0xc0: case 0xc1: case 0xc2: case 0xc3: ++ case 0xc4: case 0xc5: case 0xc6: case 0xc7: ++ case 0xc8: case 0xc9: case 0xca: case 0xcb: ++ case 0xcc: case 0xcd: case 0xce: case 0xcf: ++ return new IntegerState(this, "int", ch - 0xc8, 3); ++ ++ case 0xd0: case 0xd1: case 0xd2: case 0xd3: ++ case 0xd4: case 0xd5: case 0xd6: case 0xd7: ++ return new IntegerState(this, "int", ch - 0xd4, 2); ++ ++ case 'I': ++ return new IntegerState(this, "int"); ++ ++ case 0xd8: case 0xd9: case 0xda: case 0xdb: ++ case 0xdc: case 0xdd: case 0xde: case 0xdf: ++ case 0xe0: case 0xe1: case 0xe2: case 0xe3: ++ case 0xe4: case 0xe5: case 0xe6: case 0xe7: ++ case 0xe8: case 0xe9: case 0xea: case 0xeb: ++ case 0xec: case 0xed: case 0xee: case 0xef: ++ { ++ Long value = new Long(ch - 0xe0); ++ ++ if (isShift(value)) ++ return shift(value); ++ else { ++ printObject(value.toString() + "L"); ++ return this; ++ } ++ } ++ ++ case 0xf0: case 0xf1: case 0xf2: case 0xf3: ++ case 0xf4: case 0xf5: case 0xf6: case 0xf7: ++ case 0xf8: case 0xf9: case 0xfa: case 0xfb: ++ case 0xfc: case 0xfd: case 0xfe: case 0xff: ++ return new LongState(this, "long", ch - 0xf8, 7); ++ ++ case 0x38: case 0x39: case 0x3a: case 0x3b: ++ case 0x3c: case 0x3d: case 0x3e: case 0x3f: ++ return new LongState(this, "long", ch - 0x3c, 6); ++ ++ case BC_LONG_INT: ++ return new LongState(this, "long", 0, 4); ++ ++ case 'L': ++ return new LongState(this, "long"); ++ ++ case 0x5b: case 0x5c: ++ { ++ Double value = new Double(ch - 0x5b); ++ ++ if (isShift(value)) ++ return shift(value); ++ else { ++ printObject(value.toString()); ++ return this; ++ } ++ } ++ ++ case 0x5d: ++ return new DoubleIntegerState(this, 3); ++ ++ case 0x5e: ++ return new DoubleIntegerState(this, 2); ++ ++ case 0x5f: ++ return new MillsState(this); ++ ++ case 'D': ++ return new DoubleState(this); ++ ++ case 'Q': ++ return new RefState(this); ++ ++ case BC_DATE: ++ return new DateState(this); ++ ++ case BC_DATE_MINUTE: ++ return new DateState(this, true); ++ ++ case 0x00: ++ { ++ String value = "\"\""; ++ ++ if (isShift(value)) ++ return shift(value); ++ else { ++ printObject(value.toString()); ++ return this; ++ } ++ } ++ ++ case 0x01: case 0x02: case 0x03: ++ case 0x04: case 0x05: case 0x06: case 0x07: ++ case 0x08: case 0x09: case 0x0a: case 0x0b: ++ case 0x0c: case 0x0d: case 0x0e: case 0x0f: ++ ++ case 0x10: case 0x11: case 0x12: case 0x13: ++ case 0x14: case 0x15: case 0x16: case 0x17: ++ case 0x18: case 0x19: case 0x1a: case 0x1b: ++ case 0x1c: case 0x1d: case 0x1e: case 0x1f: ++ return new StringState(this, 'S', ch); ++ ++ case 0x30: case 0x31: case 0x32: case 0x33: ++ return new StringState(this, 'S', ch - 0x30, true); ++ ++ case 'R': ++ return new StringState(this, 'S', false); ++ ++ case 'S': ++ return new StringState(this, 'S', true); ++ ++ case 0x20: ++ { ++ String value = "binary(0)"; ++ ++ if (isShift(value)) ++ return shift(value); ++ else { ++ printObject(value.toString()); ++ return this; ++ } ++ } ++ ++ case 0x21: case 0x22: case 0x23: ++ case 0x24: case 0x25: case 0x26: case 0x27: ++ case 0x28: case 0x29: case 0x2a: case 0x2b: ++ case 0x2c: case 0x2d: case 0x2e: case 0x2f: ++ return new BinaryState(this, 'B', ch - 0x20); ++ ++ case 0x34: case 0x35: case 0x36: case 0x37: ++ return new BinaryState(this, 'B', ch - 0x34, true); ++ ++ case 'A': ++ return new BinaryState(this, 'B', false); ++ ++ case 'B': ++ return new BinaryState(this, 'B', true); ++ ++ case 'M': ++ return new MapState(this, _refId++); ++ ++ case 'H': ++ return new MapState(this, _refId++, false); ++ ++ case BC_LIST_VARIABLE: ++ return new ListState(this, _refId++, true); ++ ++ case BC_LIST_VARIABLE_UNTYPED: ++ return new ListState(this, _refId++, false); ++ ++ case BC_LIST_FIXED: ++ return new CompactListState(this, _refId++, true); ++ ++ case BC_LIST_FIXED_UNTYPED: ++ return new CompactListState(this, _refId++, false); ++ ++ case 0x70: case 0x71: case 0x72: case 0x73: ++ case 0x74: case 0x75: case 0x76: case 0x77: ++ return new CompactListState(this, _refId++, true, ch - 0x70); ++ ++ case 0x78: case 0x79: case 0x7a: case 0x7b: ++ case 0x7c: case 0x7d: case 0x7e: case 0x7f: ++ return new CompactListState(this, _refId++, false, ch - 0x78); ++ ++ case 'C': ++ return new ObjectDefState(this); ++ ++ case 0x60: case 0x61: case 0x62: case 0x63: ++ case 0x64: case 0x65: case 0x66: case 0x67: ++ case 0x68: case 0x69: case 0x6a: case 0x6b: ++ case 0x6c: case 0x6d: case 0x6e: case 0x6f: ++ return new ObjectState(this, _refId++, ch - 0x60); ++ ++ case 'O': ++ return new ObjectState(this, _refId++); ++ ++ default: ++ return this; ++ } ++ } ++ } ++ ++ abstract class State1 extends State { ++ State1() ++ { ++ } ++ ++ State1(State next) ++ { ++ super(next); ++ } ++ ++ protected State nextObject(int ch) ++ { ++ switch (ch) { ++ case -1: ++ println(); ++ return this; ++ ++ case 'N': ++ if (isShift(null)) ++ return shift(null); ++ else { ++ printObject("null"); ++ return this; ++ } ++ ++ case 'T': ++ if (isShift(Boolean.TRUE)) ++ return shift(Boolean.TRUE); ++ else { ++ printObject("true"); ++ return this; ++ } ++ ++ case 'F': ++ if (isShift(Boolean.FALSE)) ++ return shift(Boolean.FALSE); ++ else { ++ printObject("false"); ++ return this; ++ } ++ ++ case 'I': ++ return new IntegerState(this, "int"); ++ ++ case 'L': ++ return new LongState(this, "long"); ++ ++ case 'D': ++ return new DoubleState(this); ++ ++ case 'Q': ++ return new RefState(this); ++ ++ case 'd': ++ return new DateState(this); ++ ++ case 's': ++ return new StringState(this, 'S', false); ++ ++ case 'S': ++ return new StringState(this, 'S', true); ++ ++ case 'b': ++ case 'A': ++ return new BinaryState(this, 'B', false); ++ ++ case 'B': ++ return new BinaryState(this, 'B', true); ++ ++ case 'M': ++ return new MapState1(this, _refId++); ++ ++ case 'V': ++ return new ListState1(this, _refId++); ++ ++ case 'R': ++ return new IntegerState(new RefState1(this), "ref"); ++ ++ default: ++ printObject("x" + String.format("%02x", ch)); ++ return this; ++ } ++ } ++ } ++ ++ class InitialState extends State { ++ State next(int ch) ++ { ++ return nextObject(ch); ++ } ++ } ++ ++ class InitialState1 extends State1 { ++ State next(int ch) ++ { ++ return nextObject(ch); ++ } ++ } ++ ++ class Top1State extends State1 { ++ State next(int ch) ++ { ++ println(); ++ ++ if (ch == 'r') { ++ return new ReplyState1(this); ++ } ++ else if (ch == 'c') { ++ return new CallState1(this); ++ } ++ else ++ return nextObject(ch); ++ } ++ } ++ ++ class Top2State extends State { ++ State next(int ch) ++ { ++ println(); ++ ++ if (ch == 'R') { ++ return new Reply2State(this); ++ } ++ else if (ch == 'F') { ++ return new Fault2State(this); ++ } ++ else if (ch == 'C') { ++ return new Call2State(this); ++ } ++ else if (ch == 'H') { ++ return new Hessian2State(this); ++ } ++ else if (ch == 'r') { ++ return new ReplyState1(this); ++ } ++ else if (ch == 'c') { ++ return new CallState1(this); ++ } ++ else ++ return nextObject(ch); ++ } ++ } ++ ++ class IntegerState extends State { ++ String _typeCode; ++ ++ int _length; ++ int _value; ++ ++ IntegerState(State next, String typeCode) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ } ++ ++ IntegerState(State next, String typeCode, int value, int length) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ ++ _value = value; ++ _length = length; ++ } ++ ++ State next(int ch) ++ { ++ _value = 256 * _value + (ch & 0xff); ++ ++ if (++_length == 4) { ++ Integer value = new Integer(_value); ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value.toString()); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class LongState extends State { ++ String _typeCode; ++ ++ int _length; ++ long _value; ++ ++ LongState(State next, String typeCode) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ } ++ ++ LongState(State next, String typeCode, long value, int length) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ ++ _value = value; ++ _length = length; ++ } ++ ++ State next(int ch) ++ { ++ _value = 256 * _value + (ch & 0xff); ++ ++ if (++_length == 8) { ++ Long value = new Long(_value); ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value.toString() + "L"); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class DoubleIntegerState extends State { ++ int _length; ++ int _value; ++ boolean _isFirst = true; ++ ++ DoubleIntegerState(State next, int length) ++ { ++ super(next); ++ ++ _length = length; ++ } ++ ++ State next(int ch) ++ { ++ if (_isFirst) ++ _value = (byte) ch; ++ else ++ _value = 256 * _value + (ch & 0xff); ++ ++ _isFirst = false; ++ ++ if (++_length == 4) { ++ Double value = new Double(_value); ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value.toString()); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class RefState extends State { ++ String _typeCode; ++ ++ int _length; ++ int _value; ++ ++ RefState(State next) ++ { ++ super(next); ++ } ++ ++ RefState(State next, String typeCode) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ } ++ ++ RefState(State next, String typeCode, int value, int length) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ ++ _value = value; ++ _length = length; ++ } ++ ++ @Override ++ boolean isShift(Object o) ++ { ++ return true; ++ } ++ ++ @Override ++ State shift(Object o) ++ { ++ println("ref #" + o); ++ ++ return _next; ++ } ++ ++ @Override ++ State next(int ch) ++ { ++ return nextObject(ch); ++ } ++ } ++ ++ class RefState1 extends State { ++ String _typeCode; ++ ++ RefState1(State next) ++ { ++ super(next); ++ } ++ ++ @Override ++ boolean isShift(Object o) ++ { ++ return true; ++ } ++ ++ @Override ++ State shift(Object o) ++ { ++ println("ref #" + o); ++ ++ return _next; ++ } ++ ++ @Override ++ State next(int ch) ++ { ++ return nextObject(ch); ++ } ++ } ++ ++ class DateState extends State { ++ int _length; ++ long _value; ++ boolean _isMinute; ++ ++ DateState(State next) ++ { ++ super(next); ++ } ++ ++ DateState(State next, boolean isMinute) ++ { ++ super(next); ++ ++ _length = 4; ++ _isMinute = isMinute; ++ } ++ ++ ++ State next(int ch) ++ { ++ _value = 256 * _value + (ch & 0xff); ++ ++ if (++_length == 8) { ++ java.util.Date value; ++ ++ if (_isMinute) ++ value = new java.util.Date(_value * 60000L); ++ else ++ value = new java.util.Date(_value); ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value.toString()); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class DoubleState extends State { ++ int _length; ++ long _value; ++ ++ DoubleState(State next) ++ { ++ super(next); ++ } ++ ++ State next(int ch) ++ { ++ _value = 256 * _value + (ch & 0xff); ++ ++ if (++_length == 8) { ++ Double value = Double.longBitsToDouble(_value); ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value.toString()); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class MillsState extends State { ++ int _length; ++ int _value; ++ ++ MillsState(State next) ++ { ++ super(next); ++ } ++ ++ State next(int ch) ++ { ++ _value = 256 * _value + (ch & 0xff); ++ ++ if (++_length == 4) { ++ Double value = 0.001 * _value; ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value.toString()); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class StringState extends State { ++ private static final int TOP = 0; ++ private static final int UTF_2_1 = 1; ++ private static final int UTF_3_1 = 2; ++ private static final int UTF_3_2 = 3; ++ ++ char _typeCode; ++ ++ StringBuilder _value = new StringBuilder(); ++ int _lengthIndex; ++ int _length; ++ boolean _isLastChunk; ++ ++ int _utfState; ++ char _ch; ++ ++ StringState(State next, char typeCode, boolean isLastChunk) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ _isLastChunk = isLastChunk; ++ } ++ ++ StringState(State next, char typeCode, int length) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ _isLastChunk = true; ++ _length = length; ++ _lengthIndex = 2; ++ } ++ ++ StringState(State next, char typeCode, int length, boolean isLastChunk) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ _isLastChunk = isLastChunk; ++ _length = length; ++ _lengthIndex = 1; ++ } ++ ++ State next(int ch) ++ { ++ if (_lengthIndex < 2) { ++ _length = 256 * _length + (ch & 0xff); ++ ++ if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { ++ if (_next.isShift(_value.toString())) ++ return _next.shift(_value.toString()); ++ else { ++ printObject("\"" + _value + "\""); ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ else if (_length == 0) { ++ if (ch == 's' || ch == 'x') { ++ _isLastChunk = false; ++ _lengthIndex = 0; ++ return this; ++ } ++ else if (ch == 'S' || ch == 'X') { ++ _isLastChunk = true; ++ _lengthIndex = 0; ++ return this; ++ } ++ else if (ch == 0x00) { ++ if (_next.isShift(_value.toString())) ++ return _next.shift(_value.toString()); ++ else { ++ printObject("\"" + _value + "\""); ++ return _next; ++ } ++ } ++ else if (0x00 <= ch && ch < 0x20) { ++ _isLastChunk = true; ++ _lengthIndex = 2; ++ _length = ch & 0xff; ++ return this; ++ } ++ else if (0x30 <= ch && ch < 0x34) { ++ _isLastChunk = true; ++ _lengthIndex = 1; ++ _length = (ch - 0x30); ++ return this; ++ } ++ else { ++ println(this + " " + String.valueOf((char) ch) + ": unexpected character"); ++ return _next; ++ } ++ } ++ ++ switch (_utfState) { ++ case TOP: ++ if (ch < 0x80) { ++ _length--; ++ ++ _value.append((char) ch); ++ } ++ else if (ch < 0xe0) { ++ _ch = (char) ((ch & 0x1f) << 6); ++ _utfState = UTF_2_1; ++ } ++ else { ++ _ch = (char) ((ch & 0xf) << 12); ++ _utfState = UTF_3_1; ++ } ++ break; ++ ++ case UTF_2_1: ++ case UTF_3_2: ++ _ch += ch & 0x3f; ++ _value.append(_ch); ++ _length--; ++ _utfState = TOP; ++ break; ++ ++ case UTF_3_1: ++ _ch += (char) ((ch & 0x3f) << 6); ++ _utfState = UTF_3_2; ++ break; ++ } ++ ++ if (_length == 0 && _isLastChunk) { ++ if (_next.isShift(_value.toString())) ++ return _next.shift(_value.toString()); ++ else { ++ printObject("\"" + _value + "\""); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class BinaryState extends State { ++ char _typeCode; ++ ++ int _totalLength; ++ ++ int _lengthIndex; ++ int _length; ++ boolean _isLastChunk; ++ ++ BinaryState(State next, char typeCode, boolean isLastChunk) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ _isLastChunk = isLastChunk; ++ } ++ ++ BinaryState(State next, char typeCode, int length) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ _isLastChunk = true; ++ _length = length; ++ _lengthIndex = 2; ++ } ++ ++ BinaryState(State next, char typeCode, int length, boolean isLastChunk) ++ { ++ super(next); ++ ++ _typeCode = typeCode; ++ _isLastChunk = isLastChunk; ++ _length = length; ++ _lengthIndex = 1; ++ } ++ ++ @Override ++ State next(int ch) ++ { ++ if (_lengthIndex < 2) { ++ _length = 256 * _length + (ch & 0xff); ++ ++ if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { ++ String value = "binary(" + _totalLength + ")"; ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value); ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ else if (_length == 0) { ++ if (ch == 'b' || ch == 'A') { ++ _isLastChunk = false; ++ _lengthIndex = 0; ++ return this; ++ } ++ else if (ch == 'B') { ++ _isLastChunk = true; ++ _lengthIndex = 0; ++ return this; ++ } ++ else if (ch == 0x20) { ++ String value = "binary(" + _totalLength + ")"; ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value); ++ return _next; ++ } ++ } ++ else if (0x20 <= ch && ch < 0x30) { ++ _isLastChunk = true; ++ _lengthIndex = 2; ++ _length = (ch & 0xff) - 0x20; ++ return this; ++ } ++ else { ++ println(this + " 0x" + Integer.toHexString(ch) + " " + String.valueOf((char) ch) + ": unexpected character"); ++ return _next; ++ } ++ } ++ ++ _length--; ++ _totalLength++; ++ ++ if (_length == 0 && _isLastChunk) { ++ String value = "binary(" + _totalLength + ")"; ++ ++ if (_next.isShift(value)) ++ return _next.shift(value); ++ else { ++ printObject(value); ++ ++ return _next; ++ } ++ } ++ else ++ return this; ++ } ++ } ++ ++ class MapState extends State { ++ private static final int TYPE = 0; ++ private static final int KEY = 1; ++ private static final int VALUE = 2; ++ ++ private int _refId; ++ ++ private int _state; ++ private int _valueDepth; ++ private boolean _hasData; ++ ++ MapState(State next, int refId) ++ { ++ super(next); ++ ++ _refId = refId; ++ _state = TYPE; ++ } ++ ++ MapState(State next, int refId, boolean isType) ++ { ++ super(next); ++ ++ _refId = refId; ++ ++ if (isType) ++ _state = TYPE; ++ else { ++ printObject("map (#" + _refId + ")"); ++ _state = VALUE; ++ } ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ return _state == TYPE; ++ } ++ ++ @Override ++ State shift(Object type) ++ { ++ if (_state == TYPE) { ++ if (type instanceof String) { ++ _typeDefList.add((String) type); ++ } ++ else if (type instanceof Integer) { ++ int iValue = (Integer) type; ++ ++ if (iValue >= 0 && iValue < _typeDefList.size()) ++ type = _typeDefList.get(iValue); ++ } ++ ++ printObject("map " + type + " (#" + _refId + ")"); ++ ++ _state = VALUE; ++ ++ return this; ++ } ++ else { ++ printObject(this + " unknown shift state= " + _state + " type=" + type); ++ ++ return this; ++ } ++ } ++ ++ @Override ++ int depth() ++ { ++ if (_state == TYPE) ++ return _next.depth(); ++ else if (_state == KEY) ++ return _next.depth() + 2; ++ else ++ return _valueDepth; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ return nextObject(ch); ++ ++ case VALUE: ++ if (ch == 'Z') { ++ if (_hasData) ++ println(); ++ ++ return _next; ++ } ++ else { ++ if (_hasData) ++ println(); ++ ++ _hasData = true; ++ _state = KEY; ++ ++ return nextObject(ch); ++ } ++ ++ case KEY: ++ print(" => "); ++ _isObject = false; ++ _valueDepth = _column; ++ ++ _state = VALUE; ++ ++ return nextObject(ch); ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class MapState1 extends State1 { ++ private static final int TYPE = 0; ++ private static final int KEY = 1; ++ private static final int VALUE = 2; ++ ++ private int _refId; ++ ++ private int _state; ++ private int _valueDepth; ++ private boolean _hasData; ++ ++ MapState1(State next, int refId) ++ { ++ super(next); ++ ++ _refId = refId; ++ _state = TYPE; ++ } ++ ++ MapState1(State next, int refId, boolean isType) ++ { ++ super(next); ++ ++ _refId = refId; ++ ++ if (isType) ++ _state = TYPE; ++ else { ++ printObject("map (#" + _refId + ")"); ++ _state = VALUE; ++ } ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ return _state == TYPE; ++ } ++ ++ @Override ++ State shift(Object type) ++ { ++ if (_state == TYPE) { ++ if (type instanceof String) { ++ _typeDefList.add((String) type); ++ } ++ else if (type instanceof Integer) { ++ int iValue = (Integer) type; ++ ++ if (iValue >= 0 && iValue < _typeDefList.size()) ++ type = _typeDefList.get(iValue); ++ } ++ ++ printObject("map " + type + " (#" + _refId + ")"); ++ ++ _state = VALUE; ++ ++ return this; ++ } ++ else ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ int depth() ++ { ++ if (_state == TYPE) ++ return _next.depth(); ++ else if (_state == KEY) ++ return _next.depth() + 2; ++ else ++ return _valueDepth; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ if (ch == 't') { ++ return new StringState(this, 't', true); ++ } ++ else if (ch == 'z') { ++ println("map (#" + _refId + ")"); ++ return _next; ++ } ++ else { ++ println("map (#" + _refId + ")"); ++ _hasData = true; ++ _state = KEY; ++ return nextObject(ch); ++ } ++ ++ case VALUE: ++ if (ch == 'z') { ++ if (_hasData) ++ println(); ++ ++ return _next; ++ } ++ else { ++ if (_hasData) ++ println(); ++ ++ _hasData = true; ++ _state = KEY; ++ ++ return nextObject(ch); ++ } ++ ++ case KEY: ++ print(" => "); ++ _isObject = false; ++ _valueDepth = _column; ++ ++ _state = VALUE; ++ ++ return nextObject(ch); ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class ObjectDefState extends State { ++ private static final int TYPE = 1; ++ private static final int COUNT = 2; ++ private static final int FIELD = 3; ++ private static final int COMPLETE = 4; ++ ++ private int _state; ++ private int _count; ++ ++ private String _type; ++ private ArrayList _fields = new ArrayList(); ++ ++ ObjectDefState(State next) ++ { ++ super(next); ++ ++ _state = TYPE; ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ return true; ++ } ++ ++ @Override ++ State shift(Object object) ++ { ++ if (_state == TYPE) { ++ _type = (String) object; ++ ++ print("/* defun " + _type + " ["); ++ ++ _objectDefList.add(new ObjectDef(_type, _fields)); ++ ++ _state = COUNT; ++ } ++ else if (_state == COUNT) { ++ _count = (Integer) object; ++ ++ _state = FIELD; ++ } ++ else if (_state == FIELD) { ++ String field = (String) object; ++ ++ _count--; ++ ++ _fields.add(field); ++ ++ if (_fields.size() == 1) ++ print(field); ++ else ++ print(", " + field); ++ } ++ else { ++ throw new UnsupportedOperationException(); ++ } ++ ++ return this; ++ } ++ ++ @Override ++ int depth() ++ { ++ if (_state <= TYPE) ++ return _next.depth(); ++ else ++ return _next.depth() + 2; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ return nextObject(ch); ++ ++ case COUNT: ++ return nextObject(ch); ++ ++ case FIELD: ++ if (_count == 0) { ++ println("] */"); ++ _next.printIndent(0); ++ ++ return _next.nextObject(ch); ++ } ++ else ++ return nextObject(ch); ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class ObjectState extends State { ++ private static final int TYPE = 0; ++ private static final int FIELD = 1; ++ ++ private int _refId; ++ ++ private int _state; ++ private ObjectDef _def; ++ private int _count; ++ private int _fieldDepth; ++ ++ ObjectState(State next, int refId) ++ { ++ super(next); ++ ++ _refId = refId; ++ _state = TYPE; ++ } ++ ++ ObjectState(State next, int refId, int def) ++ { ++ super(next); ++ ++ _refId = refId; ++ _state = FIELD; ++ ++ if (def < 0 || _objectDefList.size() <= def) { ++ log.warning(this + " " + def + " is an unknown object type"); ++ ++ println(this + " object unknown (#" + _refId + ")"); ++ } ++ ++ _def = _objectDefList.get(def); ++ ++ if (_isObject) ++ println(); ++ ++ println("object " + _def.getType() + " (#" + _refId + ")"); ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ if (_state == TYPE) ++ return true; ++ else ++ return false; ++ } ++ ++ @Override ++ State shift(Object object) ++ { ++ if (_state == TYPE) { ++ int def = (Integer) object; ++ ++ _def = _objectDefList.get(def); ++ ++ println("object " + _def.getType() + " (#" + _refId + ")"); ++ ++ _state = FIELD; ++ ++ if (_def.getFields().size() == 0) ++ return _next; ++ } ++ ++ return this; ++ } ++ ++ @Override ++ int depth() ++ { ++ if (_state <= TYPE) ++ return _next.depth(); ++ else ++ return _fieldDepth; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ return nextObject(ch); ++ ++ case FIELD: ++ if (_def.getFields().size() <= _count) ++ return _next.next(ch); ++ ++ _fieldDepth = _next.depth() + 2; ++ println(); ++ print(_def.getFields().get(_count++) + ": "); ++ ++ _fieldDepth = _column; ++ ++ _isObject = false; ++ return nextObject(ch); ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class ListState1 extends State1 { ++ private static final int TYPE = 0; ++ private static final int LENGTH = 1; ++ private static final int VALUE = 2; ++ ++ private int _refId; ++ ++ private int _state; ++ private int _count; ++ private int _valueDepth; ++ ++ ListState1(State next, int refId) ++ { ++ super(next); ++ ++ _refId = refId; ++ ++ _state = TYPE; ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ return _state == TYPE || _state == LENGTH; ++ } ++ ++ @Override ++ State shift(Object object) ++ { ++ if (_state == TYPE) { ++ Object type = object; ++ ++ if (type instanceof String) { ++ _typeDefList.add((String) type); ++ } ++ else if (object instanceof Integer) { ++ int index = (Integer) object; ++ ++ if (index >= 0 && index < _typeDefList.size()) ++ type = _typeDefList.get(index); ++ else ++ type = "type-unknown(" + index + ")"; ++ } ++ ++ printObject("list " + type + "(#" + _refId + ")"); ++ ++ _state = VALUE; ++ ++ return this; ++ } ++ else if (_state == LENGTH) { ++ _state = VALUE; ++ ++ return this; ++ } ++ else ++ return this; ++ } ++ ++ @Override ++ int depth() ++ { ++ if (_state <= LENGTH) ++ return _next.depth(); ++ else if (_state == VALUE) ++ return _valueDepth; ++ else ++ return _next.depth() + 2; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ if (ch == 'z') { ++ printObject("list (#" + _refId + ")"); ++ ++ return _next; ++ } ++ else if (ch == 't') { ++ return new StringState(this, 't', true); ++ } ++ else { ++ printObject("list (#" + _refId + ")"); ++ printObject(" " + _count++ + ": "); ++ _valueDepth = _column; ++ _isObject = false; ++ _state = VALUE; ++ ++ return nextObject(ch); ++ } ++ ++ case VALUE: ++ if (ch == 'z') { ++ if (_count > 0) ++ println(); ++ ++ return _next; ++ } ++ else { ++ _valueDepth = _next.depth() + 2; ++ println(); ++ printObject(_count++ + ": "); ++ _valueDepth = _column; ++ _isObject = false; ++ ++ return nextObject(ch); ++ } ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class ListState extends State { ++ private static final int TYPE = 0; ++ private static final int LENGTH = 1; ++ private static final int VALUE = 2; ++ ++ private int _refId; ++ ++ private int _state; ++ private int _count; ++ private int _valueDepth; ++ ++ ListState(State next, int refId, boolean isType) ++ { ++ super(next); ++ ++ _refId = refId; ++ ++ if (isType) ++ _state = TYPE; ++ else { ++ printObject("list (#" + _refId + ")"); ++ _state = VALUE; ++ } ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ return _state == TYPE || _state == LENGTH; ++ } ++ ++ @Override ++ State shift(Object object) ++ { ++ if (_state == TYPE) { ++ Object type = object; ++ ++ if (type instanceof String) { ++ _typeDefList.add((String) type); ++ } ++ else if (object instanceof Integer) { ++ int index = (Integer) object; ++ ++ if (index >= 0 && index < _typeDefList.size()) ++ type = _typeDefList.get(index); ++ else ++ type = "type-unknown(" + index + ")"; ++ } ++ ++ printObject("list " + type + "(#" + _refId + ")"); ++ ++ _state = VALUE; ++ ++ return this; ++ } ++ else if (_state == LENGTH) { ++ _state = VALUE; ++ ++ return this; ++ } ++ else ++ return this; ++ } ++ ++ @Override ++ int depth() ++ { ++ if (_state <= LENGTH) ++ return _next.depth(); ++ else if (_state == VALUE) ++ return _valueDepth; ++ else ++ return _next.depth() + 2; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ return nextObject(ch); ++ ++ case VALUE: ++ if (ch == 'Z') { ++ if (_count > 0) ++ println(); ++ ++ return _next; ++ } ++ else { ++ _valueDepth = _next.depth() + 2; ++ println(); ++ printObject(_count++ + ": "); ++ _valueDepth = _column; ++ _isObject = false; ++ ++ return nextObject(ch); ++ } ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class CompactListState extends State { ++ private static final int TYPE = 0; ++ private static final int LENGTH = 1; ++ private static final int VALUE = 2; ++ ++ private int _refId; ++ ++ private boolean _isTyped; ++ private boolean _isLength; ++ ++ private int _state; ++ private int _length; ++ private int _count; ++ private int _valueDepth; ++ ++ CompactListState(State next, int refId, boolean isTyped) ++ { ++ super(next); ++ ++ _isTyped = isTyped; ++ _refId = refId; ++ ++ if (isTyped) ++ _state = TYPE; ++ else ++ _state = LENGTH; ++ } ++ ++ CompactListState(State next, int refId, boolean isTyped, int length) ++ { ++ super(next); ++ ++ _isTyped = isTyped; ++ _refId = refId; ++ _length = length; ++ ++ _isLength = true; ++ ++ if (isTyped) ++ _state = TYPE; ++ else { ++ printObject("list (#" + _refId + ")"); ++ ++ _state = VALUE; ++ } ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ return _state == TYPE || _state == LENGTH; ++ } ++ ++ @Override ++ State shift(Object object) ++ { ++ if (_state == TYPE) { ++ Object type = object; ++ ++ if (object instanceof Integer) { ++ int index = (Integer) object; ++ ++ if (index >= 0 && index < _typeDefList.size()) ++ type = _typeDefList.get(index); ++ else ++ type = "type-unknown(" + index + ")"; ++ } ++ else if (object instanceof String) ++ _typeDefList.add((String) object); ++ ++ printObject("list " + type + " (#" + _refId + ")"); ++ ++ if (_isLength) { ++ _state = VALUE; ++ ++ if (_length == 0) ++ return _next; ++ } ++ else ++ _state = LENGTH; ++ ++ return this; ++ } ++ else if (_state == LENGTH) { ++ _length = (Integer) object; ++ ++ if (! _isTyped) ++ printObject("list (#" + _refId + ")"); ++ ++ _state = VALUE; ++ ++ if (_length == 0) ++ return _next; ++ else ++ return this; ++ } ++ else ++ return this; ++ } ++ ++ @Override ++ int depth() ++ { ++ if (_state <= LENGTH) ++ return _next.depth(); ++ else if (_state == VALUE) ++ return _valueDepth; ++ else ++ return _next.depth() + 2; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ return nextObject(ch); ++ ++ case LENGTH: ++ return nextObject(ch); ++ ++ case VALUE: ++ if (_length <= _count) ++ return _next.next(ch); ++ else { ++ _valueDepth = _next.depth() + 2; ++ println(); ++ printObject(_count++ + ": "); ++ _valueDepth = _column; ++ _isObject = false; ++ ++ return nextObject(ch); ++ } ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class Hessian2State extends State { ++ private static final int MAJOR = 0; ++ private static final int MINOR = 1; ++ ++ private int _state; ++ private int _major; ++ private int _minor; ++ ++ Hessian2State(State next) ++ { ++ super(next); ++ } ++ ++ int depth() ++ { ++ return _next.depth() + 2; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case MAJOR: ++ _major = ch; ++ _state = MINOR; ++ return this; ++ ++ case MINOR: ++ _minor = ch; ++ println(-2, "Hessian " + _major + "." + _minor); ++ return _next; ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class CallState1 extends State1 { ++ private static final int MAJOR = 0; ++ private static final int MINOR = 1; ++ private static final int HEADER = 2; ++ private static final int METHOD = 3; ++ private static final int VALUE = 4; ++ private static final int ARG = 5; ++ ++ private int _state; ++ private int _major; ++ private int _minor; ++ ++ CallState1(State next) ++ { ++ super(next); ++ } ++ ++ int depth() ++ { ++ return _next.depth() + 2; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case MAJOR: ++ _major = ch; ++ _state = MINOR; ++ return this; ++ ++ case MINOR: ++ _minor = ch; ++ _state = HEADER; ++ println(-2, "call " + _major + "." + _minor); ++ return this; ++ ++ case HEADER: ++ if (ch == 'H') { ++ println(); ++ print("header "); ++ _isObject = false; ++ _state = VALUE; ++ return new StringState(this, 'H', true); ++ } ++ else if (ch == 'm') { ++ println(); ++ print("method "); ++ _isObject = false; ++ _state = ARG; ++ return new StringState(this, 'm', true); ++ } ++ else { ++ println((char) ch + ": unexpected char"); ++ return popStack(); ++ } ++ ++ case VALUE: ++ print(" => "); ++ _isObject = false; ++ _state = HEADER; ++ return nextObject(ch); ++ ++ case ARG: ++ if (ch == 'z') { ++ println(); ++ return _next; ++ } ++ else ++ return nextObject(ch); ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class Call2State extends State { ++ private static final int METHOD = 0; ++ private static final int COUNT = 1; ++ private static final int ARG = 2; ++ ++ private int _state = METHOD; ++ private int _i; ++ private int _count; ++ ++ Call2State(State next) ++ { ++ super(next); ++ } ++ ++ int depth() ++ { ++ return _next.depth() + 5; ++ } ++ ++ @Override ++ boolean isShift(Object value) ++ { ++ return _state != ARG; ++ } ++ ++ @Override ++ State shift(Object object) ++ { ++ if (_state == METHOD) { ++ println(-5, "Call " + object); ++ ++ _state = COUNT; ++ return this; ++ } ++ else if (_state == COUNT) { ++ Integer count = (Integer) object; ++ ++ _count = count; ++ ++ _state = ARG; ++ ++ if (_count == 0) { ++ return _next; ++ } ++ else ++ return this; ++ } ++ else { ++ return this; ++ } ++ } ++ ++ @Override ++ State next(int ch) ++ { ++ switch (_state) { ++ case COUNT: ++ return nextObject(ch); ++ ++ case METHOD: ++ return nextObject(ch); ++ ++ case ARG: ++ if (_count <= _i) { ++ println(); ++ return _next.next(ch); ++ } ++ else { ++ println(); ++ print(-3, _i++ + ": "); ++ ++ return nextObject(ch); ++ } ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class ReplyState1 extends State1 { ++ private static final int MAJOR = 0; ++ private static final int MINOR = 1; ++ private static final int HEADER = 2; ++ private static final int VALUE = 3; ++ private static final int END = 4; ++ ++ private int _state; ++ private int _major; ++ private int _minor; ++ ++ ReplyState1(State next) ++ { ++ _next = next; ++ } ++ ++ int depth() ++ { ++ return _next.depth() + 2; ++ } ++ ++ State next(int ch) ++ { ++ switch (_state) { ++ case MAJOR: ++ if (ch == 't' || ch == 'S') ++ return new RemoteState(this).next(ch); ++ ++ _major = ch; ++ _state = MINOR; ++ return this; ++ ++ case MINOR: ++ _minor = ch; ++ _state = HEADER; ++ println(-2, "reply " + _major + "." + _minor); ++ return this; ++ ++ case HEADER: ++ if (ch == 'H') { ++ _state = VALUE; ++ return new StringState(this, 'H', true); ++ } ++ else if (ch == 'f') { ++ print("fault "); ++ _isObject = false; ++ _state = END; ++ return new MapState(this, 0); ++ } ++ else { ++ _state = END; ++ return nextObject(ch); ++ } ++ ++ case VALUE: ++ _state = HEADER; ++ return nextObject(ch); ++ ++ case END: ++ println(); ++ if (ch == 'z') { ++ return _next; ++ } ++ else ++ return _next.next(ch); ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class Reply2State extends State { ++ Reply2State(State next) ++ { ++ super(next); ++ ++ println(-2, "Reply"); ++ } ++ ++ int depth() ++ { ++ return _next.depth() + 2; ++ } ++ ++ @Override ++ State next(int ch) ++ { ++ if (ch < 0) { ++ println(); ++ return _next; ++ } ++ else { ++ return nextObject(ch); ++ } ++ } ++ } ++ ++ class Fault2State extends State { ++ Fault2State(State next) ++ { ++ super(next); ++ ++ println(-2, "Fault"); ++ } ++ ++ int depth() ++ { ++ return _next.depth() + 2; ++ } ++ ++ @Override ++ State next(int ch) ++ { ++ return nextObject(ch); ++ } ++ } ++ ++ class IndirectState extends State { ++ IndirectState(State next) ++ { ++ super(next); ++ } ++ ++ boolean isShift(Object object) ++ { ++ return _next.isShift(object); ++ } ++ ++ State shift(Object object) ++ { ++ return _next.shift(object); ++ } ++ ++ State next(int ch) ++ { ++ return nextObject(ch); ++ } ++ } ++ ++ class RemoteState extends State { ++ private static final int TYPE = 0; ++ private static final int VALUE = 1; ++ private static final int END = 2; ++ ++ private int _state; ++ private int _major; ++ private int _minor; ++ ++ RemoteState(State next) ++ { ++ super(next); ++ } ++ ++ @Override ++ State next(int ch) ++ { ++ switch (_state) { ++ case TYPE: ++ println(-1, "remote"); ++ if (ch == 't') { ++ _state = VALUE; ++ return new StringState(this, 't', false); ++ } ++ else { ++ _state = END; ++ return nextObject(ch); ++ } ++ ++ case VALUE: ++ _state = END; ++ return _next.nextObject(ch); ++ ++ case END: ++ return _next.next(ch); ++ ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ } ++ ++ class StreamingState extends State { ++ private long _length; ++ private int _metaLength; ++ private boolean _isLast; ++ private boolean _isFirst = true; ++ ++ private boolean _isLengthState; ++ ++ private State _childState; ++ ++ StreamingState(State next, boolean isLast) ++ { ++ super(next); ++ ++ _isLast = isLast; ++ _childState = new InitialState(); ++ } ++ ++ State next(int ch) ++ { ++ if (_metaLength > 0) { ++ _length = 256 * _length + ch; ++ _metaLength--; ++ ++ if (_metaLength == 0 && _isFirst) { ++ if (_isLast) ++ println(-1, "--- packet-start(" + _length + ")"); ++ else ++ println(-1, "--- packet-start(fragment)"); ++ _isFirst = false; ++ } ++ ++ return this; ++ } ++ ++ if (_length > 0) { ++ _length--; ++ _childState = _childState.next(ch); ++ ++ return this; ++ } ++ ++ if (! _isLengthState) { ++ _isLengthState = true; ++ ++ if (_isLast) { ++ println(-1, ""); ++ println(-1, "--- packet-end"); ++ _refId = 0; ++ ++ _isFirst = true; ++ } ++ ++ _isLast = (ch & 0x80) == 0x00; ++ _isLengthState = true; ++ } ++ else { ++ _isLengthState = false; ++ _length = (ch & 0x7f); ++ ++ if (_length == 0x7e) { ++ _length = 0; ++ _metaLength = 2; ++ } ++ else if (_length == 0x7f) { ++ _length = 0; ++ _metaLength = 8; ++ } ++ else { ++ if (_isFirst) { ++ if (_isLast) ++ println(-1, "--- packet-start(" + _length + ")"); ++ else ++ println(-1, "--- packet-start(fragment)"); ++ _isFirst = false; ++ } ++ } ++ } ++ ++ return this; ++ } ++ } ++ ++ static class ObjectDef { ++ private String _type; ++ private ArrayList _fields; ++ ++ ObjectDef(String type, ArrayList fields) ++ { ++ _type = type; ++ _fields = fields; ++ } ++ ++ String getType() ++ { ++ return _type; ++ } ++ ++ ArrayList getFields() ++ { ++ return _fields; ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianEnvelope.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianEnvelope.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianEnvelope.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianEnvelope.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,78 +1,78 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.*; +- +-/** +- * Factory class for wrapping and unwrapping hessian streams. +- */ +-abstract public class HessianEnvelope { +- /** +- * Wrap the Hessian output stream in an envelope. +- */ +- abstract public Hessian2Output wrap(Hessian2Output out) +- throws IOException; +- +- /** +- * Unwrap the Hessian input stream with this envelope. It is an +- * error if the actual envelope does not match the expected envelope +- * class. +- */ +- abstract public Hessian2Input unwrap(Hessian2Input in) +- throws IOException; +- +- /** +- * Unwrap the envelope after having read the envelope code ('E') and +- * the envelope method. Called by the EnvelopeFactory for dynamic +- * reading of the envelopes. +- */ +- abstract public Hessian2Input unwrapHeaders(Hessian2Input in) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.*; ++ ++/** ++ * Factory class for wrapping and unwrapping hessian streams. ++ */ ++abstract public class HessianEnvelope { ++ /** ++ * Wrap the Hessian output stream in an envelope. ++ */ ++ abstract public Hessian2Output wrap(Hessian2Output out) ++ throws IOException; ++ ++ /** ++ * Unwrap the Hessian input stream with this envelope. It is an ++ * error if the actual envelope does not match the expected envelope ++ * class. ++ */ ++ abstract public Hessian2Input unwrap(Hessian2Input in) ++ throws IOException; ++ ++ /** ++ * Unwrap the envelope after having read the envelope code ('E') and ++ * the envelope method. Called by the EnvelopeFactory for dynamic ++ * reading of the envelopes. ++ */ ++ abstract public Hessian2Input unwrapHeaders(Hessian2Input in) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,268 +1,268 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.logging.*; +-import java.io.*; +-import com.caucho.hessian.util.HessianFreeList; +- +-/** +- * Factory for creating HessianInput and HessianOutput streams. +- */ +-public class HessianFactory +-{ +- public static final Logger log +- = Logger.getLogger(HessianFactory.class.getName()); +- +- private SerializerFactory _serializerFactory; +- private SerializerFactory _defaultSerializerFactory; +- +- private final HessianFreeList _freeHessian2Output +- = new HessianFreeList(32); +- +- private final HessianFreeList _freeHessianOutput +- = new HessianFreeList(32); +- +- private final HessianFreeList _freeHessian2Input +- = new HessianFreeList(32); +- +- private final HessianFreeList _freeHessianInput +- = new HessianFreeList(32); +- +- public HessianFactory() +- { +- _defaultSerializerFactory = SerializerFactory.createDefault(); +- _serializerFactory = _defaultSerializerFactory; +- } +- +- public void setSerializerFactory(SerializerFactory factory) +- { +- _serializerFactory = factory; +- } +- +- public SerializerFactory getSerializerFactory() +- { +- // the default serializer factory cannot be modified by external +- // callers +- if (_serializerFactory == _defaultSerializerFactory) { +- _serializerFactory = new SerializerFactory(); +- } +- +- return _serializerFactory; +- } +- +- /** +- * Enable whitelist deserialization mode. Only classes matching the whitelist +- * will be allowed. +- */ +- public void setWhitelist(boolean isWhitelist) +- { +- getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); +- } +- +- /** +- * Allow a class or package based on a pattern. +- * +- * Examples: "java.util.*", "com.foo.io.Bean" +- */ +- public void allow(String pattern) +- { +- getSerializerFactory().getClassFactory().allow(pattern); +- } +- +- +- /** +- * Deny a class or package based on a pattern. +- * +- * Examples: "java.util.*", "com.foo.io.Bean" +- */ +- public void deny(String pattern) +- { +- getSerializerFactory().getClassFactory().deny(pattern); +- } +- +- /** +- * Creates a new Hessian 2.0 deserializer. +- */ +- public Hessian2Input createHessian2Input(InputStream is) +- { +- Hessian2Input in = _freeHessian2Input.allocate(); +- +- if (in == null) { +- in = new Hessian2Input(is); +- in.setSerializerFactory(getSerializerFactory()); +- } +- else { +- in.init(is); +- } +- +- return in; +- } +- +- /** +- * Frees a Hessian 2.0 deserializer +- */ +- public void freeHessian2Input(Hessian2Input in) +- { +- if (in == null) +- return; +- +- in.free(); +- +- _freeHessian2Input.free(in); +- } +- +- /** +- * Creates a new Hessian 2.0 deserializer. +- */ +- public Hessian2StreamingInput createHessian2StreamingInput(InputStream is) +- { +- Hessian2StreamingInput in = new Hessian2StreamingInput(is); +- in.setSerializerFactory(getSerializerFactory()); +- +- return in; +- } +- +- /** +- * Frees a Hessian 2.0 deserializer +- */ +- public void freeHessian2StreamingInput(Hessian2StreamingInput in) +- { +- } +- +- /** +- * Creates a new Hessian 1.0 deserializer. +- */ +- public HessianInput createHessianInput(InputStream is) +- { +- return new HessianInput(is); +- } +- +- /** +- * Creates a new Hessian 2.0 serializer. +- */ +- public Hessian2Output createHessian2Output(OutputStream os) +- { +- Hessian2Output out = createHessian2Output(); +- +- out.init(os); +- +- return out; +- } +- +- /** +- * Creates a new Hessian 2.0 serializer. +- */ +- public Hessian2Output createHessian2Output() +- { +- Hessian2Output out = _freeHessian2Output.allocate(); +- +- if (out == null) { +- out = new Hessian2Output(); +- +- out.setSerializerFactory(getSerializerFactory()); +- } +- +- return out; +- } +- +- /** +- * Frees a Hessian 2.0 serializer +- */ +- public void freeHessian2Output(Hessian2Output out) +- { +- if (out == null) +- return; +- +- out.free(); +- +- _freeHessian2Output.free(out); +- } +- +- /** +- * Creates a new Hessian 2.0 serializer. +- */ +- public Hessian2StreamingOutput createHessian2StreamingOutput(OutputStream os) +- { +- Hessian2Output out = createHessian2Output(os); +- +- return new Hessian2StreamingOutput(out); +- } +- +- /** +- * Frees a Hessian 2.0 serializer +- */ +- public void freeHessian2StreamingOutput(Hessian2StreamingOutput out) +- { +- if (out == null) +- return; +- +- freeHessian2Output(out.getHessian2Output()); +- } +- +- /** +- * Creates a new Hessian 1.0 serializer. +- */ +- public HessianOutput createHessianOutput(OutputStream os) +- { +- return new HessianOutput(os); +- } +- +- public OutputStream createHessian2DebugOutput(OutputStream os, +- Logger log, +- Level level) +- { +- HessianDebugOutputStream out +- = new HessianDebugOutputStream(os, log, level); +- +- out.startTop2(); +- +- return out; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.logging.*; ++import java.io.*; ++import com.caucho.hessian.util.HessianFreeList; ++ ++/** ++ * Factory for creating HessianInput and HessianOutput streams. ++ */ ++public class HessianFactory ++{ ++ public static final Logger log ++ = Logger.getLogger(HessianFactory.class.getName()); ++ ++ private SerializerFactory _serializerFactory; ++ private SerializerFactory _defaultSerializerFactory; ++ ++ private final HessianFreeList _freeHessian2Output ++ = new HessianFreeList(32); ++ ++ private final HessianFreeList _freeHessianOutput ++ = new HessianFreeList(32); ++ ++ private final HessianFreeList _freeHessian2Input ++ = new HessianFreeList(32); ++ ++ private final HessianFreeList _freeHessianInput ++ = new HessianFreeList(32); ++ ++ public HessianFactory() ++ { ++ _defaultSerializerFactory = SerializerFactory.createDefault(); ++ _serializerFactory = _defaultSerializerFactory; ++ } ++ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ public SerializerFactory getSerializerFactory() ++ { ++ // the default serializer factory cannot be modified by external ++ // callers ++ if (_serializerFactory == _defaultSerializerFactory) { ++ _serializerFactory = new SerializerFactory(); ++ } ++ ++ return _serializerFactory; ++ } ++ ++ /** ++ * Enable whitelist deserialization mode. Only classes matching the whitelist ++ * will be allowed. ++ */ ++ public void setWhitelist(boolean isWhitelist) ++ { ++ getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); ++ } ++ ++ /** ++ * Allow a class or package based on a pattern. ++ * ++ * Examples: "java.util.*", "com.foo.io.Bean" ++ */ ++ public void allow(String pattern) ++ { ++ getSerializerFactory().getClassFactory().allow(pattern); ++ } ++ ++ ++ /** ++ * Deny a class or package based on a pattern. ++ * ++ * Examples: "java.util.*", "com.foo.io.Bean" ++ */ ++ public void deny(String pattern) ++ { ++ getSerializerFactory().getClassFactory().deny(pattern); ++ } ++ ++ /** ++ * Creates a new Hessian 2.0 deserializer. ++ */ ++ public Hessian2Input createHessian2Input(InputStream is) ++ { ++ Hessian2Input in = _freeHessian2Input.allocate(); ++ ++ if (in == null) { ++ in = new Hessian2Input(is); ++ in.setSerializerFactory(getSerializerFactory()); ++ } ++ else { ++ in.init(is); ++ } ++ ++ return in; ++ } ++ ++ /** ++ * Frees a Hessian 2.0 deserializer ++ */ ++ public void freeHessian2Input(Hessian2Input in) ++ { ++ if (in == null) ++ return; ++ ++ in.free(); ++ ++ _freeHessian2Input.free(in); ++ } ++ ++ /** ++ * Creates a new Hessian 2.0 deserializer. ++ */ ++ public Hessian2StreamingInput createHessian2StreamingInput(InputStream is) ++ { ++ Hessian2StreamingInput in = new Hessian2StreamingInput(is); ++ in.setSerializerFactory(getSerializerFactory()); ++ ++ return in; ++ } ++ ++ /** ++ * Frees a Hessian 2.0 deserializer ++ */ ++ public void freeHessian2StreamingInput(Hessian2StreamingInput in) ++ { ++ } ++ ++ /** ++ * Creates a new Hessian 1.0 deserializer. ++ */ ++ public HessianInput createHessianInput(InputStream is) ++ { ++ return new HessianInput(is); ++ } ++ ++ /** ++ * Creates a new Hessian 2.0 serializer. ++ */ ++ public Hessian2Output createHessian2Output(OutputStream os) ++ { ++ Hessian2Output out = createHessian2Output(); ++ ++ out.init(os); ++ ++ return out; ++ } ++ ++ /** ++ * Creates a new Hessian 2.0 serializer. ++ */ ++ public Hessian2Output createHessian2Output() ++ { ++ Hessian2Output out = _freeHessian2Output.allocate(); ++ ++ if (out == null) { ++ out = new Hessian2Output(); ++ ++ out.setSerializerFactory(getSerializerFactory()); ++ } ++ ++ return out; ++ } ++ ++ /** ++ * Frees a Hessian 2.0 serializer ++ */ ++ public void freeHessian2Output(Hessian2Output out) ++ { ++ if (out == null) ++ return; ++ ++ out.free(); ++ ++ _freeHessian2Output.free(out); ++ } ++ ++ /** ++ * Creates a new Hessian 2.0 serializer. ++ */ ++ public Hessian2StreamingOutput createHessian2StreamingOutput(OutputStream os) ++ { ++ Hessian2Output out = createHessian2Output(os); ++ ++ return new Hessian2StreamingOutput(out); ++ } ++ ++ /** ++ * Frees a Hessian 2.0 serializer ++ */ ++ public void freeHessian2StreamingOutput(Hessian2StreamingOutput out) ++ { ++ if (out == null) ++ return; ++ ++ freeHessian2Output(out.getHessian2Output()); ++ } ++ ++ /** ++ * Creates a new Hessian 1.0 serializer. ++ */ ++ public HessianOutput createHessianOutput(OutputStream os) ++ { ++ return new HessianOutput(os); ++ } ++ ++ public OutputStream createHessian2DebugOutput(OutputStream os, ++ Logger log, ++ Level level) ++ { ++ HessianDebugOutputStream out ++ = new HessianDebugOutputStream(os, log, level); ++ ++ out.startTop2(); ++ ++ return out; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianFieldException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianFieldException.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianFieldException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianFieldException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,87 +1,87 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Exception during field reading. +- */ +-public class HessianFieldException extends HessianProtocolException { +- /** +- * Zero-arg constructor. +- */ +- public HessianFieldException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public HessianFieldException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public HessianFieldException(String message, Throwable cause) +- { +- super(message, cause); +- } +- +- /** +- * Create the exception. +- */ +- public HessianFieldException(Throwable cause) +- { +- super(cause); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Exception during field reading. ++ */ ++public class HessianFieldException extends HessianProtocolException { ++ /** ++ * Zero-arg constructor. ++ */ ++ public HessianFieldException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianFieldException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianFieldException(String message, Throwable cause) ++ { ++ super(message, cause); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianFieldException(Throwable cause) ++ { ++ super(cause); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianHandle.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianHandle.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianHandle.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,55 +1,55 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-/** +- * Marks a type as a handle +- */ +-public interface HessianHandle { +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++/** ++ * Marks a type as a handle ++ */ ++public interface HessianHandle { ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianInput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianInput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,1707 +1,1707 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.ByteArrayOutputStream; +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.Reader; +-import java.lang.reflect.Field; +-import java.util.ArrayList; +-import java.util.Date; +-import java.util.HashMap; +- +-/** +- * Input stream for Hessian requests. +- * +- *

HessianInput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * InputStream is = ...; // from http connection
+- * HessianInput in = new HessianInput(is);
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-public class HessianInput extends AbstractHessianInput { +- private static int END_OF_DATA = -2; +- +- private static Field _detailMessageField; +- +- // factory for deserializing objects in the input stream +- protected SerializerFactory _serializerFactory; +- +- protected ArrayList _refs; +- +- // the underlying input stream +- private InputStream _is; +- // a peek character +- protected int _peek = -1; +- +- // the method for a call +- private String _method; +- +- private Reader _chunkReader; +- private InputStream _chunkInputStream; +- +- private Throwable _replyFault; +- +- private StringBuffer _sbuf = new StringBuffer(); +- +- // true if this is the last chunk +- private boolean _isLastChunk; +- // the chunk length +- private int _chunkLength; +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianInput() +- { +- } +- +- /** +- * Creates a new Hessian input stream, initialized with an +- * underlying input stream. +- * +- * @param is the underlying input stream. +- */ +- public HessianInput(InputStream is) +- { +- init(is); +- } +- +- /** +- * Sets the serializer factory. +- */ +- public void setSerializerFactory(SerializerFactory factory) +- { +- _serializerFactory = factory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- public SerializerFactory getSerializerFactory() +- { +- return _serializerFactory; +- } +- +- /** +- * Initialize the hessian stream with the underlying input stream. +- */ +- public void init(InputStream is) +- { +- _is = is; +- _method = null; +- _isLastChunk = true; +- _chunkLength = 0; +- _peek = -1; +- _refs = null; +- _replyFault = null; +- +- if (_serializerFactory == null) +- _serializerFactory = new SerializerFactory(); +- } +- +- /** +- * Returns the calls method +- */ +- public String getMethod() +- { +- return _method; +- } +- +- /** +- * Returns any reply fault. +- */ +- public Throwable getReplyFault() +- { +- return _replyFault; +- } +- +- /** +- * Starts reading the call +- * +- *
+-   * c major minor
+-   * 
+- */ +- public int readCall() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'c') +- throw error("expected hessian call ('c') at " + codeName(tag)); +- +- int major = read(); +- int minor = read(); +- +- return (major << 16) + minor; +- } +- +- /** +- * For backward compatibility with HessianSkeleton +- */ +- public void skipOptionalCall() +- throws IOException +- { +- int tag = read(); +- +- if (tag == 'c') { +- read(); +- read(); +- } +- else +- _peek = tag; +- } +- +- /** +- * Starts reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * m b16 b8 method
+-   * 
+- */ +- public String readMethod() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'm') +- throw error("expected hessian method ('m') at " + codeName(tag)); +- int d1 = read(); +- int d2 = read(); +- +- _isLastChunk = true; +- _chunkLength = d1 * 256 + d2; +- _sbuf.setLength(0); +- int ch; +- while ((ch = parseChar()) >= 0) +- _sbuf.append((char) ch); +- +- _method = _sbuf.toString(); +- +- return _method; +- } +- +- /** +- * Starts reading the call, including the headers. +- * +- *

The call expects the following protocol data +- * +- *

+-   * c major minor
+-   * m b16 b8 method
+-   * 
+- */ +- public void startCall() +- throws IOException +- { +- readCall(); +- +- while (readHeader() != null) { +- readObject(); +- } +- +- readMethod(); +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- int tag = read(); +- +- if (tag == 'z') { +- } +- else +- throw error("expected end of call ('z') at " + codeName(tag) + ". Check method arguments and ensure method overloading is enabled if necessary"); +- } +- +- /** +- * Reads a reply as an object. +- * If the reply has a fault, throws the exception. +- */ +- public Object readReply(Class expectedClass) +- throws Throwable +- { +- int tag = read(); +- +- if (tag != 'r') +- error("expected hessian reply at " + codeName(tag)); +- +- int major = read(); +- int minor = read(); +- +- tag = read(); +- if (tag == 'f') +- throw prepareFault(); +- else { +- _peek = tag; +- +- Object value = readObject(expectedClass); +- +- completeValueReply(); +- +- return value; +- } +- } +- +- /** +- * Starts reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * r
+-   * 
+- */ +- public void startReply() +- throws Throwable +- { +- int tag = read(); +- +- if (tag != 'r') +- error("expected hessian reply at " + codeName(tag)); +- +- int major = read(); +- int minor = read(); +- +- startReplyBody(); +- } +- +- public void startReplyBody() +- throws Throwable +- { +- int tag = read(); +- +- if (tag == 'f') +- throw prepareFault(); +- else +- _peek = tag; +- } +- +- /** +- * Prepares the fault. +- */ +- private Throwable prepareFault() +- throws IOException +- { +- HashMap fault = readFault(); +- +- Object detail = fault.get("detail"); +- String message = (String) fault.get("message"); +- +- if (detail instanceof Throwable) { +- _replyFault = (Throwable) detail; +- +- if (message != null && _detailMessageField != null) { +- try { +- _detailMessageField.set(_replyFault, message); +- } catch (Throwable e) { +- } +- } +- +- return _replyFault; +- } +- +- else { +- String code = (String) fault.get("code"); +- +- _replyFault = new HessianServiceException(message, code, detail); +- +- return _replyFault; +- } +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeReply() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'z') +- error("expected end of reply at " + codeName(tag)); +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeValueReply() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'z') +- error("expected end of reply at " + codeName(tag)); +- } +- +- /** +- * Reads a header, returning null if there are no headers. +- * +- *
+-   * H b16 b8 value
+-   * 
+- */ +- public String readHeader() +- throws IOException +- { +- int tag = read(); +- +- if (tag == 'H') { +- _isLastChunk = true; +- _chunkLength = (read() << 8) + read(); +- +- _sbuf.setLength(0); +- int ch; +- while ((ch = parseChar()) >= 0) +- _sbuf.append((char) ch); +- +- return _sbuf.toString(); +- } +- +- _peek = tag; +- +- return null; +- } +- +- /** +- * Reads a null +- * +- *
+-   * N
+-   * 
+- */ +- public void readNull() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': return; +- +- default: +- throw expect("null", tag); +- } +- } +- +- /** +- * Reads a boolean +- * +- *
+-   * T
+-   * F
+-   * 
+- */ +- public boolean readBoolean() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'T': return true; +- case 'F': return false; +- case 'I': return parseInt() == 0; +- case 'L': return parseLong() == 0; +- case 'D': return parseDouble() == 0.0; +- case 'N': return false; +- +- default: +- throw expect("boolean", tag); +- } +- } +- +- /** +- * Reads a byte +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- */ +- /* +- public byte readByte() +- throws IOException +- { +- return (byte) readInt(); +- } +- */ +- +- /** +- * Reads a short +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- */ +- public short readShort() +- throws IOException +- { +- return (short) readInt(); +- } +- +- /** +- * Reads an integer +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- */ +- public int readInt() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'T': return 1; +- case 'F': return 0; +- case 'I': return parseInt(); +- case 'L': return (int) parseLong(); +- case 'D': return (int) parseDouble(); +- +- default: +- throw expect("int", tag); +- } +- } +- +- /** +- * Reads a long +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public long readLong() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'T': return 1; +- case 'F': return 0; +- case 'I': return parseInt(); +- case 'L': return parseLong(); +- case 'D': return (long) parseDouble(); +- +- default: +- throw expect("long", tag); +- } +- } +- +- /** +- * Reads a float +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public float readFloat() +- throws IOException +- { +- return (float) readDouble(); +- } +- +- /** +- * Reads a double +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public double readDouble() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'T': return 1; +- case 'F': return 0; +- case 'I': return parseInt(); +- case 'L': return (double) parseLong(); +- case 'D': return parseDouble(); +- +- default: +- throw expect("long", tag); +- } +- } +- +- /** +- * Reads a date. +- * +- *
+-   * T b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public long readUTCDate() +- throws IOException +- { +- int tag = read(); +- +- if (tag != 'd') +- throw error("expected date at " + codeName(tag)); +- +- long b64 = read(); +- long b56 = read(); +- long b48 = read(); +- long b40 = read(); +- long b32 = read(); +- long b24 = read(); +- long b16 = read(); +- long b8 = read(); +- +- return ((b64 << 56) + +- (b56 << 48) + +- (b48 << 40) + +- (b40 << 32) + +- (b32 << 24) + +- (b24 << 16) + +- (b16 << 8) + +- b8); +- } +- +- /** +- * Reads a byte from the stream. +- */ +- public int readChar() +- throws IOException +- { +- if (_chunkLength > 0) { +- _chunkLength--; +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- int ch = parseUTF8Char(); +- return ch; +- } +- else if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'S': +- case 's': +- case 'X': +- case 'x': +- _isLastChunk = tag == 'S' || tag == 'X'; +- _chunkLength = (read() << 8) + read(); +- +- _chunkLength--; +- int value = parseUTF8Char(); +- +- // special code so successive read byte won't +- // be read as a single object. +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- return value; +- +- default: +- throw new IOException("expected 'S' at " + (char) tag); +- } +- } +- +- /** +- * Reads a byte array from the stream. +- */ +- public int readString(char []buffer, int offset, int length) +- throws IOException +- { +- int readLength = 0; +- +- if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- else if (_chunkLength == 0) { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'S': +- case 's': +- case 'X': +- case 'x': +- _isLastChunk = tag == 'S' || tag == 'X'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw new IOException("expected 'S' at " + (char) tag); +- } +- } +- +- while (length > 0) { +- if (_chunkLength > 0) { +- buffer[offset++] = (char) parseUTF8Char(); +- _chunkLength--; +- length--; +- readLength++; +- } +- else if (_isLastChunk) { +- if (readLength == 0) +- return -1; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- else { +- int tag = read(); +- +- switch (tag) { +- case 'S': +- case 's': +- case 'X': +- case 'x': +- _isLastChunk = tag == 'S' || tag == 'X'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw new IOException("expected 'S' at " + (char) tag); +- } +- } +- } +- +- if (readLength == 0) +- return -1; +- else if (_chunkLength > 0 || ! _isLastChunk) +- return readLength; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- +- /** +- * Reads a string +- * +- *
+-   * S b16 b8 string value
+-   * 
+- */ +- public String readString() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'I': +- return String.valueOf(parseInt()); +- case 'L': +- return String.valueOf(parseLong()); +- case 'D': +- return String.valueOf(parseDouble()); +- +- case 'S': +- case 's': +- case 'X': +- case 'x': +- _isLastChunk = tag == 'S' || tag == 'X'; +- _chunkLength = (read() << 8) + read(); +- +- _sbuf.setLength(0); +- int ch; +- +- while ((ch = parseChar()) >= 0) +- _sbuf.append((char) ch); +- +- return _sbuf.toString(); +- +- default: +- throw expect("string", tag); +- } +- } +- +- /** +- * Reads an XML node. +- * +- *
+-   * S b16 b8 string value
+-   * 
+- */ +- public org.w3c.dom.Node readNode() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'S': +- case 's': +- case 'X': +- case 'x': +- _isLastChunk = tag == 'S' || tag == 'X'; +- _chunkLength = (read() << 8) + read(); +- +- throw error("Can't handle string in this context"); +- +- default: +- throw expect("string", tag); +- } +- } +- +- /** +- * Reads a byte array +- * +- *
+-   * B b16 b8 data value
+-   * 
+- */ +- public byte []readBytes() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'B': +- case 'b': +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- int data; +- while ((data = parseByte()) >= 0) +- bos.write(data); +- +- return bos.toByteArray(); +- +- default: +- throw expect("bytes", tag); +- } +- } +- +- /** +- * Reads a byte from the stream. +- */ +- public int readByte() +- throws IOException +- { +- if (_chunkLength > 0) { +- _chunkLength--; +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- return read(); +- } +- else if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'B': +- case 'b': +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- +- int value = parseByte(); +- +- // special code so successive read byte won't +- // be read as a single object. +- if (_chunkLength == 0 && _isLastChunk) +- _chunkLength = END_OF_DATA; +- +- return value; +- +- default: +- throw new IOException("expected 'B' at " + (char) tag); +- } +- } +- +- /** +- * Reads a byte array from the stream. +- */ +- public int readBytes(byte []buffer, int offset, int length) +- throws IOException +- { +- int readLength = 0; +- +- if (_chunkLength == END_OF_DATA) { +- _chunkLength = 0; +- return -1; +- } +- else if (_chunkLength == 0) { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return -1; +- +- case 'B': +- case 'b': +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw new IOException("expected 'B' at " + (char) tag); +- } +- } +- +- while (length > 0) { +- if (_chunkLength > 0) { +- buffer[offset++] = (byte) read(); +- _chunkLength--; +- length--; +- readLength++; +- } +- else if (_isLastChunk) { +- if (readLength == 0) +- return -1; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- else { +- int tag = read(); +- +- switch (tag) { +- case 'B': +- case 'b': +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw new IOException("expected 'B' at " + (char) tag); +- } +- } +- } +- +- if (readLength == 0) +- return -1; +- else if (_chunkLength > 0 || ! _isLastChunk) +- return readLength; +- else { +- _chunkLength = END_OF_DATA; +- return readLength; +- } +- } +- +- /** +- * Reads a fault. +- */ +- private HashMap readFault() +- throws IOException +- { +- HashMap map = new HashMap(); +- +- int code = read(); +- for (; code > 0 && code != 'z'; code = read()) { +- _peek = code; +- +- Object key = readObject(); +- Object value = readObject(); +- +- if (key != null && value != null) +- map.put(key, value); +- } +- +- if (code != 'z') +- throw expect("fault", code); +- +- return map; +- } +- +- /** +- * Reads an object from the input stream with an expected type. +- */ +- public Object readObject(Class cl) +- throws IOException +- { +- if (cl == null || cl == Object.class) +- return readObject(); +- +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'M': +- { +- String type = readType(); +- +- // hessian/3386 +- if ("".equals(type)) { +- Deserializer reader; +- reader = _serializerFactory.getDeserializer(cl); +- +- return reader.readMap(this); +- } +- else { +- Deserializer reader; +- reader = _serializerFactory.getObjectDeserializer(type); +- +- return reader.readMap(this); +- } +- } +- +- case 'V': +- { +- String type = readType(); +- int length = readLength(); +- +- Deserializer reader; +- reader = _serializerFactory.getObjectDeserializer(type); +- +- if (cl != reader.getType() && cl.isAssignableFrom(reader.getType())) +- return reader.readList(this, length); +- +- reader = _serializerFactory.getDeserializer(cl); +- +- Object v = reader.readList(this, length); +- +- return v; +- } +- +- case 'R': +- { +- int ref = parseInt(); +- +- return _refs.get(ref); +- } +- +- case 'r': +- { +- String type = readType(); +- String url = readString(); +- +- return resolveRemote(type, url); +- } +- } +- +- _peek = tag; +- +- // hessian/332i vs hessian/3406 +- //return readObject(); +- +- Object value = _serializerFactory.getDeserializer(cl).readObject(this); +- +- return value; +- } +- +- /** +- * Reads an arbitrary object from the input stream when the type +- * is unknown. +- */ +- public Object readObject() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'T': +- return Boolean.valueOf(true); +- +- case 'F': +- return Boolean.valueOf(false); +- +- case 'I': +- return Integer.valueOf(parseInt()); +- +- case 'L': +- return Long.valueOf(parseLong()); +- +- case 'D': +- return Double.valueOf(parseDouble()); +- +- case 'd': +- return new Date(parseLong()); +- +- case 'x': +- case 'X': { +- _isLastChunk = tag == 'X'; +- _chunkLength = (read() << 8) + read(); +- +- return parseXML(); +- } +- +- case 's': +- case 'S': { +- _isLastChunk = tag == 'S'; +- _chunkLength = (read() << 8) + read(); +- +- int data; +- _sbuf.setLength(0); +- +- while ((data = parseChar()) >= 0) +- _sbuf.append((char) data); +- +- return _sbuf.toString(); +- } +- +- case 'b': +- case 'B': { +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- +- int data; +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- while ((data = parseByte()) >= 0) +- bos.write(data); +- +- return bos.toByteArray(); +- } +- +- case 'V': { +- String type = readType(); +- int length = readLength(); +- +- return _serializerFactory.readList(this, length, type); +- } +- +- case 'M': { +- String type = readType(); +- +- return _serializerFactory.readMap(this, type); +- } +- +- case 'R': { +- int ref = parseInt(); +- +- return _refs.get(ref); +- } +- +- case 'r': { +- String type = readType(); +- String url = readString(); +- +- return resolveRemote(type, url); +- } +- +- default: +- throw error("unknown code for readObject at " + codeName(tag)); +- } +- } +- +- /** +- * Reads a remote object. +- */ +- public Object readRemote() +- throws IOException +- { +- String type = readType(); +- String url = readString(); +- +- return resolveRemote(type, url); +- } +- +- /** +- * Reads a reference. +- */ +- public Object readRef() +- throws IOException +- { +- return _refs.get(parseInt()); +- } +- +- /** +- * Reads the start of a list. +- */ +- public int readListStart() +- throws IOException +- { +- return read(); +- } +- +- /** +- * Reads the start of a list. +- */ +- public int readMapStart() +- throws IOException +- { +- return read(); +- } +- +- /** +- * Returns true if this is the end of a list or a map. +- */ +- public boolean isEnd() +- throws IOException +- { +- int code = read(); +- +- _peek = code; +- +- return (code < 0 || code == 'z'); +- } +- +- /** +- * Reads the end byte. +- */ +- public void readEnd() +- throws IOException +- { +- int code = read(); +- +- if (code != 'z') +- throw error("unknown code at " + codeName(code)); +- } +- +- /** +- * Reads the end byte. +- */ +- public void readMapEnd() +- throws IOException +- { +- int code = read(); +- +- if (code != 'z') +- throw error("expected end of map ('z') at " + codeName(code)); +- } +- +- /** +- * Reads the end byte. +- */ +- public void readListEnd() +- throws IOException +- { +- int code = read(); +- +- if (code != 'z') +- throw error("expected end of list ('z') at " + codeName(code)); +- } +- +- /** +- * Adds a list/map reference. +- */ +- public int addRef(Object ref) +- { +- if (_refs == null) +- _refs = new ArrayList(); +- +- _refs.add(ref); +- +- return _refs.size() - 1; +- } +- +- /** +- * Adds a list/map reference. +- */ +- public void setRef(int i, Object ref) +- { +- _refs.set(i, ref); +- } +- +- /** +- * Resets the references for streaming. +- */ +- public void resetReferences() +- { +- if (_refs != null) +- _refs.clear(); +- } +- +- /** +- * Resolves a remote object. +- */ +- public Object resolveRemote(String type, String url) +- throws IOException +- { +- HessianRemoteResolver resolver = getRemoteResolver(); +- +- if (resolver != null) +- return resolver.lookup(type, url); +- else +- return new HessianRemote(type, url); +- } +- +- /** +- * Parses a type from the stream. +- * +- *
+-   * t b16 b8
+-   * 
+- */ +- public String readType() +- throws IOException +- { +- int code = read(); +- +- if (code != 't') { +- _peek = code; +- return ""; +- } +- +- _isLastChunk = true; +- _chunkLength = (read() << 8) + read(); +- +- _sbuf.setLength(0); +- int ch; +- while ((ch = parseChar()) >= 0) +- _sbuf.append((char) ch); +- +- return _sbuf.toString(); +- } +- +- /** +- * Parses the length for an array +- * +- *
+-   * l b32 b24 b16 b8
+-   * 
+- */ +- public int readLength() +- throws IOException +- { +- int code = read(); +- +- if (code != 'l') { +- _peek = code; +- return -1; +- } +- +- return parseInt(); +- } +- +- /** +- * Parses a 32-bit integer value from the stream. +- * +- *
+-   * b32 b24 b16 b8
+-   * 
+- */ +- private int parseInt() +- throws IOException +- { +- int b32 = read(); +- int b24 = read(); +- int b16 = read(); +- int b8 = read(); +- +- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; +- } +- +- /** +- * Parses a 64-bit long value from the stream. +- * +- *
+-   * b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- private long parseLong() +- throws IOException +- { +- long b64 = read(); +- long b56 = read(); +- long b48 = read(); +- long b40 = read(); +- long b32 = read(); +- long b24 = read(); +- long b16 = read(); +- long b8 = read(); +- +- return ((b64 << 56) + +- (b56 << 48) + +- (b48 << 40) + +- (b40 << 32) + +- (b32 << 24) + +- (b24 << 16) + +- (b16 << 8) + +- b8); +- } +- +- /** +- * Parses a 64-bit double value from the stream. +- * +- *
+-   * b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- private double parseDouble() +- throws IOException +- { +- long b64 = read(); +- long b56 = read(); +- long b48 = read(); +- long b40 = read(); +- long b32 = read(); +- long b24 = read(); +- long b16 = read(); +- long b8 = read(); +- +- long bits = ((b64 << 56) + +- (b56 << 48) + +- (b48 << 40) + +- (b40 << 32) + +- (b32 << 24) + +- (b24 << 16) + +- (b16 << 8) + +- b8); +- +- return Double.longBitsToDouble(bits); +- } +- +- org.w3c.dom.Node parseXML() +- throws IOException +- { +- throw new UnsupportedOperationException(); +- } +- +- /** +- * Reads a character from the underlying stream. +- */ +- private int parseChar() +- throws IOException +- { +- while (_chunkLength <= 0) { +- if (_isLastChunk) +- return -1; +- +- int code = read(); +- +- switch (code) { +- case 's': +- case 'x': +- _isLastChunk = false; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 'S': +- case 'X': +- _isLastChunk = true; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw expect("string", code); +- } +- +- } +- +- _chunkLength--; +- +- return parseUTF8Char(); +- } +- +- /** +- * Parses a single UTF8 character. +- */ +- private int parseUTF8Char() +- throws IOException +- { +- int ch = read(); +- +- if (ch < 0x80) +- return ch; +- else if ((ch & 0xe0) == 0xc0) { +- int ch1 = read(); +- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); +- +- return v; +- } +- else if ((ch & 0xf0) == 0xe0) { +- int ch1 = read(); +- int ch2 = read(); +- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); +- +- return v; +- } +- else +- throw error("bad utf-8 encoding at " + codeName(ch)); +- } +- +- /** +- * Reads a byte from the underlying stream. +- */ +- private int parseByte() +- throws IOException +- { +- while (_chunkLength <= 0) { +- if (_isLastChunk) { +- return -1; +- } +- +- int code = read(); +- +- switch (code) { +- case 'b': +- _isLastChunk = false; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 'B': +- _isLastChunk = true; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw expect("byte[]", code); +- } +- } +- +- _chunkLength--; +- +- return read(); +- } +- +- /** +- * Reads bytes based on an input stream. +- */ +- public InputStream readInputStream() +- throws IOException +- { +- int tag = read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'B': +- case 'b': +- _isLastChunk = tag == 'B'; +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw expect("inputStream", tag); +- } +- +- return new InputStream() { +- boolean _isClosed = false; +- +- public int read() +- throws IOException +- { +- if (_isClosed || _is == null) +- return -1; +- +- int ch = parseByte(); +- if (ch < 0) +- _isClosed = true; +- +- return ch; +- } +- +- public int read(byte []buffer, int offset, int length) +- throws IOException +- { +- if (_isClosed || _is == null) +- return -1; +- +- int len = HessianInput.this.read(buffer, offset, length); +- if (len < 0) +- _isClosed = true; +- +- return len; +- } +- +- public void close() +- throws IOException +- { +- while (read() >= 0) { +- } +- +- _isClosed = true; +- } +- }; +- } +- +- /** +- * Reads bytes from the underlying stream. +- */ +- int read(byte []buffer, int offset, int length) +- throws IOException +- { +- int readLength = 0; +- +- while (length > 0) { +- while (_chunkLength <= 0) { +- if (_isLastChunk) +- return readLength == 0 ? -1 : readLength; +- +- int code = read(); +- +- switch (code) { +- case 'b': +- _isLastChunk = false; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- case 'B': +- _isLastChunk = true; +- +- _chunkLength = (read() << 8) + read(); +- break; +- +- default: +- throw expect("byte[]", code); +- } +- } +- +- int sublen = _chunkLength; +- if (length < sublen) +- sublen = length; +- +- sublen = _is.read(buffer, offset, sublen); +- offset += sublen; +- readLength += sublen; +- length -= sublen; +- _chunkLength -= sublen; +- } +- +- return readLength; +- } +- +- final int read() +- throws IOException +- { +- if (_peek >= 0) { +- int value = _peek; +- _peek = -1; +- return value; +- } +- +- int ch = _is.read(); +- +- return ch; +- } +- +- public void close() +- { +- _is = null; +- } +- +- public Reader getReader() +- { +- return null; +- } +- +- protected IOException expect(String expect, int ch) +- { +- return error("expected " + expect + " at " + codeName(ch)); +- } +- +- protected String codeName(int ch) +- { +- if (ch < 0) +- return "end of file"; +- else +- return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; +- } +- +- protected IOException error(String message) +- { +- if (_method != null) +- return new HessianProtocolException(_method + ": " + message); +- else +- return new HessianProtocolException(message); +- } +- +- static { +- try { +- _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); +- _detailMessageField.setAccessible(true); +- } catch (Throwable e) { +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.ByteArrayOutputStream; ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.Reader; ++import java.lang.reflect.Field; ++import java.util.ArrayList; ++import java.util.Date; ++import java.util.HashMap; ++ ++/** ++ * Input stream for Hessian requests. ++ * ++ *

HessianInput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * InputStream is = ...; // from http connection
++ * HessianInput in = new HessianInput(is);
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++public class HessianInput extends AbstractHessianInput { ++ private static int END_OF_DATA = -2; ++ ++ private static Field _detailMessageField; ++ ++ // factory for deserializing objects in the input stream ++ protected SerializerFactory _serializerFactory; ++ ++ protected ArrayList _refs; ++ ++ // the underlying input stream ++ private InputStream _is; ++ // a peek character ++ protected int _peek = -1; ++ ++ // the method for a call ++ private String _method; ++ ++ private Reader _chunkReader; ++ private InputStream _chunkInputStream; ++ ++ private Throwable _replyFault; ++ ++ private StringBuffer _sbuf = new StringBuffer(); ++ ++ // true if this is the last chunk ++ private boolean _isLastChunk; ++ // the chunk length ++ private int _chunkLength; ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianInput() ++ { ++ } ++ ++ /** ++ * Creates a new Hessian input stream, initialized with an ++ * underlying input stream. ++ * ++ * @param is the underlying input stream. ++ */ ++ public HessianInput(InputStream is) ++ { ++ init(is); ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ return _serializerFactory; ++ } ++ ++ /** ++ * Initialize the hessian stream with the underlying input stream. ++ */ ++ public void init(InputStream is) ++ { ++ _is = is; ++ _method = null; ++ _isLastChunk = true; ++ _chunkLength = 0; ++ _peek = -1; ++ _refs = null; ++ _replyFault = null; ++ ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(); ++ } ++ ++ /** ++ * Returns the calls method ++ */ ++ public String getMethod() ++ { ++ return _method; ++ } ++ ++ /** ++ * Returns any reply fault. ++ */ ++ public Throwable getReplyFault() ++ { ++ return _replyFault; ++ } ++ ++ /** ++ * Starts reading the call ++ * ++ *
++   * c major minor
++   * 
++ */ ++ public int readCall() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'c') ++ throw error("expected hessian call ('c') at " + codeName(tag)); ++ ++ int major = read(); ++ int minor = read(); ++ ++ return (major << 16) + minor; ++ } ++ ++ /** ++ * For backward compatibility with HessianSkeleton ++ */ ++ public void skipOptionalCall() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag == 'c') { ++ read(); ++ read(); ++ } ++ else ++ _peek = tag; ++ } ++ ++ /** ++ * Starts reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * m b16 b8 method
++   * 
++ */ ++ public String readMethod() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'm') ++ throw error("expected hessian method ('m') at " + codeName(tag)); ++ int d1 = read(); ++ int d2 = read(); ++ ++ _isLastChunk = true; ++ _chunkLength = d1 * 256 + d2; ++ _sbuf.setLength(0); ++ int ch; ++ while ((ch = parseChar()) >= 0) ++ _sbuf.append((char) ch); ++ ++ _method = _sbuf.toString(); ++ ++ return _method; ++ } ++ ++ /** ++ * Starts reading the call, including the headers. ++ * ++ *

The call expects the following protocol data ++ * ++ *

++   * c major minor
++   * m b16 b8 method
++   * 
++ */ ++ public void startCall() ++ throws IOException ++ { ++ readCall(); ++ ++ while (readHeader() != null) { ++ readObject(); ++ } ++ ++ readMethod(); ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag == 'z') { ++ } ++ else ++ throw error("expected end of call ('z') at " + codeName(tag) + ". Check method arguments and ensure method overloading is enabled if necessary"); ++ } ++ ++ /** ++ * Reads a reply as an object. ++ * If the reply has a fault, throws the exception. ++ */ ++ public Object readReply(Class expectedClass) ++ throws Throwable ++ { ++ int tag = read(); ++ ++ if (tag != 'r') ++ error("expected hessian reply at " + codeName(tag)); ++ ++ int major = read(); ++ int minor = read(); ++ ++ tag = read(); ++ if (tag == 'f') ++ throw prepareFault(); ++ else { ++ _peek = tag; ++ ++ Object value = readObject(expectedClass); ++ ++ completeValueReply(); ++ ++ return value; ++ } ++ } ++ ++ /** ++ * Starts reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * r
++   * 
++ */ ++ public void startReply() ++ throws Throwable ++ { ++ int tag = read(); ++ ++ if (tag != 'r') ++ error("expected hessian reply at " + codeName(tag)); ++ ++ int major = read(); ++ int minor = read(); ++ ++ startReplyBody(); ++ } ++ ++ public void startReplyBody() ++ throws Throwable ++ { ++ int tag = read(); ++ ++ if (tag == 'f') ++ throw prepareFault(); ++ else ++ _peek = tag; ++ } ++ ++ /** ++ * Prepares the fault. ++ */ ++ private Throwable prepareFault() ++ throws IOException ++ { ++ HashMap fault = readFault(); ++ ++ Object detail = fault.get("detail"); ++ String message = (String) fault.get("message"); ++ ++ if (detail instanceof Throwable) { ++ _replyFault = (Throwable) detail; ++ ++ if (message != null && _detailMessageField != null) { ++ try { ++ _detailMessageField.set(_replyFault, message); ++ } catch (Throwable e) { ++ } ++ } ++ ++ return _replyFault; ++ } ++ ++ else { ++ String code = (String) fault.get("code"); ++ ++ _replyFault = new HessianServiceException(message, code, detail); ++ ++ return _replyFault; ++ } ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeReply() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'z') ++ error("expected end of reply at " + codeName(tag)); ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeValueReply() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'z') ++ error("expected end of reply at " + codeName(tag)); ++ } ++ ++ /** ++ * Reads a header, returning null if there are no headers. ++ * ++ *
++   * H b16 b8 value
++   * 
++ */ ++ public String readHeader() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag == 'H') { ++ _isLastChunk = true; ++ _chunkLength = (read() << 8) + read(); ++ ++ _sbuf.setLength(0); ++ int ch; ++ while ((ch = parseChar()) >= 0) ++ _sbuf.append((char) ch); ++ ++ return _sbuf.toString(); ++ } ++ ++ _peek = tag; ++ ++ return null; ++ } ++ ++ /** ++ * Reads a null ++ * ++ *
++   * N
++   * 
++ */ ++ public void readNull() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': return; ++ ++ default: ++ throw expect("null", tag); ++ } ++ } ++ ++ /** ++ * Reads a boolean ++ * ++ *
++   * T
++   * F
++   * 
++ */ ++ public boolean readBoolean() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'T': return true; ++ case 'F': return false; ++ case 'I': return parseInt() == 0; ++ case 'L': return parseLong() == 0; ++ case 'D': return parseDouble() == 0.0; ++ case 'N': return false; ++ ++ default: ++ throw expect("boolean", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ */ ++ /* ++ public byte readByte() ++ throws IOException ++ { ++ return (byte) readInt(); ++ } ++ */ ++ ++ /** ++ * Reads a short ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ */ ++ public short readShort() ++ throws IOException ++ { ++ return (short) readInt(); ++ } ++ ++ /** ++ * Reads an integer ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ */ ++ public int readInt() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'T': return 1; ++ case 'F': return 0; ++ case 'I': return parseInt(); ++ case 'L': return (int) parseLong(); ++ case 'D': return (int) parseDouble(); ++ ++ default: ++ throw expect("int", tag); ++ } ++ } ++ ++ /** ++ * Reads a long ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public long readLong() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'T': return 1; ++ case 'F': return 0; ++ case 'I': return parseInt(); ++ case 'L': return parseLong(); ++ case 'D': return (long) parseDouble(); ++ ++ default: ++ throw expect("long", tag); ++ } ++ } ++ ++ /** ++ * Reads a float ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public float readFloat() ++ throws IOException ++ { ++ return (float) readDouble(); ++ } ++ ++ /** ++ * Reads a double ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public double readDouble() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'T': return 1; ++ case 'F': return 0; ++ case 'I': return parseInt(); ++ case 'L': return (double) parseLong(); ++ case 'D': return parseDouble(); ++ ++ default: ++ throw expect("long", tag); ++ } ++ } ++ ++ /** ++ * Reads a date. ++ * ++ *
++   * T b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public long readUTCDate() ++ throws IOException ++ { ++ int tag = read(); ++ ++ if (tag != 'd') ++ throw error("expected date at " + codeName(tag)); ++ ++ long b64 = read(); ++ long b56 = read(); ++ long b48 = read(); ++ long b40 = read(); ++ long b32 = read(); ++ long b24 = read(); ++ long b16 = read(); ++ long b8 = read(); ++ ++ return ((b64 << 56) + ++ (b56 << 48) + ++ (b48 << 40) + ++ (b40 << 32) + ++ (b32 << 24) + ++ (b24 << 16) + ++ (b16 << 8) + ++ b8); ++ } ++ ++ /** ++ * Reads a byte from the stream. ++ */ ++ public int readChar() ++ throws IOException ++ { ++ if (_chunkLength > 0) { ++ _chunkLength--; ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ int ch = parseUTF8Char(); ++ return ch; ++ } ++ else if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'S': ++ case 's': ++ case 'X': ++ case 'x': ++ _isLastChunk = tag == 'S' || tag == 'X'; ++ _chunkLength = (read() << 8) + read(); ++ ++ _chunkLength--; ++ int value = parseUTF8Char(); ++ ++ // special code so successive read byte won't ++ // be read as a single object. ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ return value; ++ ++ default: ++ throw new IOException("expected 'S' at " + (char) tag); ++ } ++ } ++ ++ /** ++ * Reads a byte array from the stream. ++ */ ++ public int readString(char []buffer, int offset, int length) ++ throws IOException ++ { ++ int readLength = 0; ++ ++ if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ else if (_chunkLength == 0) { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'S': ++ case 's': ++ case 'X': ++ case 'x': ++ _isLastChunk = tag == 'S' || tag == 'X'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw new IOException("expected 'S' at " + (char) tag); ++ } ++ } ++ ++ while (length > 0) { ++ if (_chunkLength > 0) { ++ buffer[offset++] = (char) parseUTF8Char(); ++ _chunkLength--; ++ length--; ++ readLength++; ++ } ++ else if (_isLastChunk) { ++ if (readLength == 0) ++ return -1; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ else { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'S': ++ case 's': ++ case 'X': ++ case 'x': ++ _isLastChunk = tag == 'S' || tag == 'X'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw new IOException("expected 'S' at " + (char) tag); ++ } ++ } ++ } ++ ++ if (readLength == 0) ++ return -1; ++ else if (_chunkLength > 0 || ! _isLastChunk) ++ return readLength; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ ++ /** ++ * Reads a string ++ * ++ *
++   * S b16 b8 string value
++   * 
++ */ ++ public String readString() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'I': ++ return String.valueOf(parseInt()); ++ case 'L': ++ return String.valueOf(parseLong()); ++ case 'D': ++ return String.valueOf(parseDouble()); ++ ++ case 'S': ++ case 's': ++ case 'X': ++ case 'x': ++ _isLastChunk = tag == 'S' || tag == 'X'; ++ _chunkLength = (read() << 8) + read(); ++ ++ _sbuf.setLength(0); ++ int ch; ++ ++ while ((ch = parseChar()) >= 0) ++ _sbuf.append((char) ch); ++ ++ return _sbuf.toString(); ++ ++ default: ++ throw expect("string", tag); ++ } ++ } ++ ++ /** ++ * Reads an XML node. ++ * ++ *
++   * S b16 b8 string value
++   * 
++ */ ++ public org.w3c.dom.Node readNode() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'S': ++ case 's': ++ case 'X': ++ case 'x': ++ _isLastChunk = tag == 'S' || tag == 'X'; ++ _chunkLength = (read() << 8) + read(); ++ ++ throw error("Can't handle string in this context"); ++ ++ default: ++ throw expect("string", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte array ++ * ++ *
++   * B b16 b8 data value
++   * 
++ */ ++ public byte []readBytes() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'B': ++ case 'b': ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ int data; ++ while ((data = parseByte()) >= 0) ++ bos.write(data); ++ ++ return bos.toByteArray(); ++ ++ default: ++ throw expect("bytes", tag); ++ } ++ } ++ ++ /** ++ * Reads a byte from the stream. ++ */ ++ public int readByte() ++ throws IOException ++ { ++ if (_chunkLength > 0) { ++ _chunkLength--; ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ return read(); ++ } ++ else if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'B': ++ case 'b': ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ ++ int value = parseByte(); ++ ++ // special code so successive read byte won't ++ // be read as a single object. ++ if (_chunkLength == 0 && _isLastChunk) ++ _chunkLength = END_OF_DATA; ++ ++ return value; ++ ++ default: ++ throw new IOException("expected 'B' at " + (char) tag); ++ } ++ } ++ ++ /** ++ * Reads a byte array from the stream. ++ */ ++ public int readBytes(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ int readLength = 0; ++ ++ if (_chunkLength == END_OF_DATA) { ++ _chunkLength = 0; ++ return -1; ++ } ++ else if (_chunkLength == 0) { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return -1; ++ ++ case 'B': ++ case 'b': ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw new IOException("expected 'B' at " + (char) tag); ++ } ++ } ++ ++ while (length > 0) { ++ if (_chunkLength > 0) { ++ buffer[offset++] = (byte) read(); ++ _chunkLength--; ++ length--; ++ readLength++; ++ } ++ else if (_isLastChunk) { ++ if (readLength == 0) ++ return -1; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ else { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'B': ++ case 'b': ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw new IOException("expected 'B' at " + (char) tag); ++ } ++ } ++ } ++ ++ if (readLength == 0) ++ return -1; ++ else if (_chunkLength > 0 || ! _isLastChunk) ++ return readLength; ++ else { ++ _chunkLength = END_OF_DATA; ++ return readLength; ++ } ++ } ++ ++ /** ++ * Reads a fault. ++ */ ++ private HashMap readFault() ++ throws IOException ++ { ++ HashMap map = new HashMap(); ++ ++ int code = read(); ++ for (; code > 0 && code != 'z'; code = read()) { ++ _peek = code; ++ ++ Object key = readObject(); ++ Object value = readObject(); ++ ++ if (key != null && value != null) ++ map.put(key, value); ++ } ++ ++ if (code != 'z') ++ throw expect("fault", code); ++ ++ return map; ++ } ++ ++ /** ++ * Reads an object from the input stream with an expected type. ++ */ ++ public Object readObject(Class cl) ++ throws IOException ++ { ++ if (cl == null || cl == Object.class) ++ return readObject(); ++ ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'M': ++ { ++ String type = readType(); ++ ++ // hessian/3386 ++ if ("".equals(type)) { ++ Deserializer reader; ++ reader = _serializerFactory.getDeserializer(cl); ++ ++ return reader.readMap(this); ++ } ++ else { ++ Deserializer reader; ++ reader = _serializerFactory.getObjectDeserializer(type); ++ ++ return reader.readMap(this); ++ } ++ } ++ ++ case 'V': ++ { ++ String type = readType(); ++ int length = readLength(); ++ ++ Deserializer reader; ++ reader = _serializerFactory.getObjectDeserializer(type); ++ ++ if (cl != reader.getType() && cl.isAssignableFrom(reader.getType())) ++ return reader.readList(this, length); ++ ++ reader = _serializerFactory.getDeserializer(cl); ++ ++ Object v = reader.readList(this, length); ++ ++ return v; ++ } ++ ++ case 'R': ++ { ++ int ref = parseInt(); ++ ++ return _refs.get(ref); ++ } ++ ++ case 'r': ++ { ++ String type = readType(); ++ String url = readString(); ++ ++ return resolveRemote(type, url); ++ } ++ } ++ ++ _peek = tag; ++ ++ // hessian/332i vs hessian/3406 ++ //return readObject(); ++ ++ Object value = _serializerFactory.getDeserializer(cl).readObject(this); ++ ++ return value; ++ } ++ ++ /** ++ * Reads an arbitrary object from the input stream when the type ++ * is unknown. ++ */ ++ public Object readObject() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'T': ++ return Boolean.valueOf(true); ++ ++ case 'F': ++ return Boolean.valueOf(false); ++ ++ case 'I': ++ return Integer.valueOf(parseInt()); ++ ++ case 'L': ++ return Long.valueOf(parseLong()); ++ ++ case 'D': ++ return Double.valueOf(parseDouble()); ++ ++ case 'd': ++ return new Date(parseLong()); ++ ++ case 'x': ++ case 'X': { ++ _isLastChunk = tag == 'X'; ++ _chunkLength = (read() << 8) + read(); ++ ++ return parseXML(); ++ } ++ ++ case 's': ++ case 'S': { ++ _isLastChunk = tag == 'S'; ++ _chunkLength = (read() << 8) + read(); ++ ++ int data; ++ _sbuf.setLength(0); ++ ++ while ((data = parseChar()) >= 0) ++ _sbuf.append((char) data); ++ ++ return _sbuf.toString(); ++ } ++ ++ case 'b': ++ case 'B': { ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ ++ int data; ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ while ((data = parseByte()) >= 0) ++ bos.write(data); ++ ++ return bos.toByteArray(); ++ } ++ ++ case 'V': { ++ String type = readType(); ++ int length = readLength(); ++ ++ return _serializerFactory.readList(this, length, type); ++ } ++ ++ case 'M': { ++ String type = readType(); ++ ++ return _serializerFactory.readMap(this, type); ++ } ++ ++ case 'R': { ++ int ref = parseInt(); ++ ++ return _refs.get(ref); ++ } ++ ++ case 'r': { ++ String type = readType(); ++ String url = readString(); ++ ++ return resolveRemote(type, url); ++ } ++ ++ default: ++ throw error("unknown code for readObject at " + codeName(tag)); ++ } ++ } ++ ++ /** ++ * Reads a remote object. ++ */ ++ public Object readRemote() ++ throws IOException ++ { ++ String type = readType(); ++ String url = readString(); ++ ++ return resolveRemote(type, url); ++ } ++ ++ /** ++ * Reads a reference. ++ */ ++ public Object readRef() ++ throws IOException ++ { ++ return _refs.get(parseInt()); ++ } ++ ++ /** ++ * Reads the start of a list. ++ */ ++ public int readListStart() ++ throws IOException ++ { ++ return read(); ++ } ++ ++ /** ++ * Reads the start of a list. ++ */ ++ public int readMapStart() ++ throws IOException ++ { ++ return read(); ++ } ++ ++ /** ++ * Returns true if this is the end of a list or a map. ++ */ ++ public boolean isEnd() ++ throws IOException ++ { ++ int code = read(); ++ ++ _peek = code; ++ ++ return (code < 0 || code == 'z'); ++ } ++ ++ /** ++ * Reads the end byte. ++ */ ++ public void readEnd() ++ throws IOException ++ { ++ int code = read(); ++ ++ if (code != 'z') ++ throw error("unknown code at " + codeName(code)); ++ } ++ ++ /** ++ * Reads the end byte. ++ */ ++ public void readMapEnd() ++ throws IOException ++ { ++ int code = read(); ++ ++ if (code != 'z') ++ throw error("expected end of map ('z') at " + codeName(code)); ++ } ++ ++ /** ++ * Reads the end byte. ++ */ ++ public void readListEnd() ++ throws IOException ++ { ++ int code = read(); ++ ++ if (code != 'z') ++ throw error("expected end of list ('z') at " + codeName(code)); ++ } ++ ++ /** ++ * Adds a list/map reference. ++ */ ++ public int addRef(Object ref) ++ { ++ if (_refs == null) ++ _refs = new ArrayList(); ++ ++ _refs.add(ref); ++ ++ return _refs.size() - 1; ++ } ++ ++ /** ++ * Adds a list/map reference. ++ */ ++ public void setRef(int i, Object ref) ++ { ++ _refs.set(i, ref); ++ } ++ ++ /** ++ * Resets the references for streaming. ++ */ ++ public void resetReferences() ++ { ++ if (_refs != null) ++ _refs.clear(); ++ } ++ ++ /** ++ * Resolves a remote object. ++ */ ++ public Object resolveRemote(String type, String url) ++ throws IOException ++ { ++ HessianRemoteResolver resolver = getRemoteResolver(); ++ ++ if (resolver != null) ++ return resolver.lookup(type, url); ++ else ++ return new HessianRemote(type, url); ++ } ++ ++ /** ++ * Parses a type from the stream. ++ * ++ *
++   * t b16 b8
++   * 
++ */ ++ public String readType() ++ throws IOException ++ { ++ int code = read(); ++ ++ if (code != 't') { ++ _peek = code; ++ return ""; ++ } ++ ++ _isLastChunk = true; ++ _chunkLength = (read() << 8) + read(); ++ ++ _sbuf.setLength(0); ++ int ch; ++ while ((ch = parseChar()) >= 0) ++ _sbuf.append((char) ch); ++ ++ return _sbuf.toString(); ++ } ++ ++ /** ++ * Parses the length for an array ++ * ++ *
++   * l b32 b24 b16 b8
++   * 
++ */ ++ public int readLength() ++ throws IOException ++ { ++ int code = read(); ++ ++ if (code != 'l') { ++ _peek = code; ++ return -1; ++ } ++ ++ return parseInt(); ++ } ++ ++ /** ++ * Parses a 32-bit integer value from the stream. ++ * ++ *
++   * b32 b24 b16 b8
++   * 
++ */ ++ private int parseInt() ++ throws IOException ++ { ++ int b32 = read(); ++ int b24 = read(); ++ int b16 = read(); ++ int b8 = read(); ++ ++ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; ++ } ++ ++ /** ++ * Parses a 64-bit long value from the stream. ++ * ++ *
++   * b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ private long parseLong() ++ throws IOException ++ { ++ long b64 = read(); ++ long b56 = read(); ++ long b48 = read(); ++ long b40 = read(); ++ long b32 = read(); ++ long b24 = read(); ++ long b16 = read(); ++ long b8 = read(); ++ ++ return ((b64 << 56) + ++ (b56 << 48) + ++ (b48 << 40) + ++ (b40 << 32) + ++ (b32 << 24) + ++ (b24 << 16) + ++ (b16 << 8) + ++ b8); ++ } ++ ++ /** ++ * Parses a 64-bit double value from the stream. ++ * ++ *
++   * b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ private double parseDouble() ++ throws IOException ++ { ++ long b64 = read(); ++ long b56 = read(); ++ long b48 = read(); ++ long b40 = read(); ++ long b32 = read(); ++ long b24 = read(); ++ long b16 = read(); ++ long b8 = read(); ++ ++ long bits = ((b64 << 56) + ++ (b56 << 48) + ++ (b48 << 40) + ++ (b40 << 32) + ++ (b32 << 24) + ++ (b24 << 16) + ++ (b16 << 8) + ++ b8); ++ ++ return Double.longBitsToDouble(bits); ++ } ++ ++ org.w3c.dom.Node parseXML() ++ throws IOException ++ { ++ throw new UnsupportedOperationException(); ++ } ++ ++ /** ++ * Reads a character from the underlying stream. ++ */ ++ private int parseChar() ++ throws IOException ++ { ++ while (_chunkLength <= 0) { ++ if (_isLastChunk) ++ return -1; ++ ++ int code = read(); ++ ++ switch (code) { ++ case 's': ++ case 'x': ++ _isLastChunk = false; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 'S': ++ case 'X': ++ _isLastChunk = true; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw expect("string", code); ++ } ++ ++ } ++ ++ _chunkLength--; ++ ++ return parseUTF8Char(); ++ } ++ ++ /** ++ * Parses a single UTF8 character. ++ */ ++ private int parseUTF8Char() ++ throws IOException ++ { ++ int ch = read(); ++ ++ if (ch < 0x80) ++ return ch; ++ else if ((ch & 0xe0) == 0xc0) { ++ int ch1 = read(); ++ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); ++ ++ return v; ++ } ++ else if ((ch & 0xf0) == 0xe0) { ++ int ch1 = read(); ++ int ch2 = read(); ++ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); ++ ++ return v; ++ } ++ else ++ throw error("bad utf-8 encoding at " + codeName(ch)); ++ } ++ ++ /** ++ * Reads a byte from the underlying stream. ++ */ ++ private int parseByte() ++ throws IOException ++ { ++ while (_chunkLength <= 0) { ++ if (_isLastChunk) { ++ return -1; ++ } ++ ++ int code = read(); ++ ++ switch (code) { ++ case 'b': ++ _isLastChunk = false; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 'B': ++ _isLastChunk = true; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw expect("byte[]", code); ++ } ++ } ++ ++ _chunkLength--; ++ ++ return read(); ++ } ++ ++ /** ++ * Reads bytes based on an input stream. ++ */ ++ public InputStream readInputStream() ++ throws IOException ++ { ++ int tag = read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'B': ++ case 'b': ++ _isLastChunk = tag == 'B'; ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw expect("inputStream", tag); ++ } ++ ++ return new InputStream() { ++ boolean _isClosed = false; ++ ++ public int read() ++ throws IOException ++ { ++ if (_isClosed || _is == null) ++ return -1; ++ ++ int ch = parseByte(); ++ if (ch < 0) ++ _isClosed = true; ++ ++ return ch; ++ } ++ ++ public int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (_isClosed || _is == null) ++ return -1; ++ ++ int len = HessianInput.this.read(buffer, offset, length); ++ if (len < 0) ++ _isClosed = true; ++ ++ return len; ++ } ++ ++ public void close() ++ throws IOException ++ { ++ while (read() >= 0) { ++ } ++ ++ _isClosed = true; ++ } ++ }; ++ } ++ ++ /** ++ * Reads bytes from the underlying stream. ++ */ ++ int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ int readLength = 0; ++ ++ while (length > 0) { ++ while (_chunkLength <= 0) { ++ if (_isLastChunk) ++ return readLength == 0 ? -1 : readLength; ++ ++ int code = read(); ++ ++ switch (code) { ++ case 'b': ++ _isLastChunk = false; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ case 'B': ++ _isLastChunk = true; ++ ++ _chunkLength = (read() << 8) + read(); ++ break; ++ ++ default: ++ throw expect("byte[]", code); ++ } ++ } ++ ++ int sublen = _chunkLength; ++ if (length < sublen) ++ sublen = length; ++ ++ sublen = _is.read(buffer, offset, sublen); ++ offset += sublen; ++ readLength += sublen; ++ length -= sublen; ++ _chunkLength -= sublen; ++ } ++ ++ return readLength; ++ } ++ ++ final int read() ++ throws IOException ++ { ++ if (_peek >= 0) { ++ int value = _peek; ++ _peek = -1; ++ return value; ++ } ++ ++ int ch = _is.read(); ++ ++ return ch; ++ } ++ ++ public void close() ++ { ++ _is = null; ++ } ++ ++ public Reader getReader() ++ { ++ return null; ++ } ++ ++ protected IOException expect(String expect, int ch) ++ { ++ return error("expected " + expect + " at " + codeName(ch)); ++ } ++ ++ protected String codeName(int ch) ++ { ++ if (ch < 0) ++ return "end of file"; ++ else ++ return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; ++ } ++ ++ protected IOException error(String message) ++ { ++ if (_method != null) ++ return new HessianProtocolException(_method + ": " + message); ++ else ++ return new HessianProtocolException(message); ++ } ++ ++ static { ++ try { ++ _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); ++ _detailMessageField.setAccessible(true); ++ } catch (Throwable e) { ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianInputFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianInputFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianInputFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianInputFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,173 +1,173 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.logging.*; +-import java.io.*; +- +-public class HessianInputFactory +-{ +- public static final Logger log +- = Logger.getLogger(HessianInputFactory.class.getName()); +- +- private HessianFactory _factory = new HessianFactory(); +- +- public void setSerializerFactory(SerializerFactory factory) +- { +- _factory.setSerializerFactory(factory); +- } +- +- public SerializerFactory getSerializerFactory() +- { +- return _factory.getSerializerFactory(); +- } +- +- public HeaderType readHeader(InputStream is) +- throws IOException +- { +- int code = is.read(); +- +- int major = is.read(); +- int minor = is.read(); +- +- switch (code) { +- case -1: +- throw new IOException("Unexpected end of file for Hessian message"); +- +- case 'c': +- if (major >= 2) +- return HeaderType.CALL_1_REPLY_2; +- else +- return HeaderType.CALL_1_REPLY_1; +- case 'r': +- return HeaderType.REPLY_1; +- +- case 'H': +- return HeaderType.HESSIAN_2; +- +- default: +- throw new IOException((char) code + " 0x" + Integer.toHexString(code) + " is an unknown Hessian message code."); +- } +- } +- +- public AbstractHessianInput open(InputStream is) +- throws IOException +- { +- int code = is.read(); +- +- int major = is.read(); +- int minor = is.read(); +- +- switch (code) { +- case 'c': +- case 'C': +- case 'r': +- case 'R': +- if (major >= 2) { +- return _factory.createHessian2Input(is); +- } +- else { +- return _factory.createHessianInput(is); +- } +- +- default: +- throw new IOException((char) code + " is an unknown Hessian message code."); +- } +- } +- +- public enum HeaderType { +- CALL_1_REPLY_1, +- CALL_1_REPLY_2, +- HESSIAN_2, +- REPLY_1, +- REPLY_2; +- +- public boolean isCall1() +- { +- switch (this) { +- case CALL_1_REPLY_1: +- case CALL_1_REPLY_2: +- return true; +- default: +- return false; +- } +- } +- +- public boolean isCall2() +- { +- switch (this) { +- case HESSIAN_2: +- return true; +- default: +- return false; +- } +- } +- +- public boolean isReply1() +- { +- switch (this) { +- case CALL_1_REPLY_1: +- return true; +- default: +- return false; +- } +- } +- +- public boolean isReply2() +- { +- switch (this) { +- case CALL_1_REPLY_2: +- case HESSIAN_2: +- return true; +- default: +- return false; +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.logging.*; ++import java.io.*; ++ ++public class HessianInputFactory ++{ ++ public static final Logger log ++ = Logger.getLogger(HessianInputFactory.class.getName()); ++ ++ private HessianFactory _factory = new HessianFactory(); ++ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _factory.setSerializerFactory(factory); ++ } ++ ++ public SerializerFactory getSerializerFactory() ++ { ++ return _factory.getSerializerFactory(); ++ } ++ ++ public HeaderType readHeader(InputStream is) ++ throws IOException ++ { ++ int code = is.read(); ++ ++ int major = is.read(); ++ int minor = is.read(); ++ ++ switch (code) { ++ case -1: ++ throw new IOException("Unexpected end of file for Hessian message"); ++ ++ case 'c': ++ if (major >= 2) ++ return HeaderType.CALL_1_REPLY_2; ++ else ++ return HeaderType.CALL_1_REPLY_1; ++ case 'r': ++ return HeaderType.REPLY_1; ++ ++ case 'H': ++ return HeaderType.HESSIAN_2; ++ ++ default: ++ throw new IOException((char) code + " 0x" + Integer.toHexString(code) + " is an unknown Hessian message code."); ++ } ++ } ++ ++ public AbstractHessianInput open(InputStream is) ++ throws IOException ++ { ++ int code = is.read(); ++ ++ int major = is.read(); ++ int minor = is.read(); ++ ++ switch (code) { ++ case 'c': ++ case 'C': ++ case 'r': ++ case 'R': ++ if (major >= 2) { ++ return _factory.createHessian2Input(is); ++ } ++ else { ++ return _factory.createHessianInput(is); ++ } ++ ++ default: ++ throw new IOException((char) code + " is an unknown Hessian message code."); ++ } ++ } ++ ++ public enum HeaderType { ++ CALL_1_REPLY_1, ++ CALL_1_REPLY_2, ++ HESSIAN_2, ++ REPLY_1, ++ REPLY_2; ++ ++ public boolean isCall1() ++ { ++ switch (this) { ++ case CALL_1_REPLY_1: ++ case CALL_1_REPLY_2: ++ return true; ++ default: ++ return false; ++ } ++ } ++ ++ public boolean isCall2() ++ { ++ switch (this) { ++ case HESSIAN_2: ++ return true; ++ default: ++ return false; ++ } ++ } ++ ++ public boolean isReply1() ++ { ++ switch (this) { ++ case CALL_1_REPLY_1: ++ return true; ++ default: ++ return false; ++ } ++ } ++ ++ public boolean isReply2() ++ { ++ switch (this) { ++ case CALL_1_REPLY_2: ++ case HESSIAN_2: ++ return true; ++ default: ++ return false; ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianMethodSerializationException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianMethodSerializationException.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianMethodSerializationException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianMethodSerializationException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,88 +1,88 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroHessianInput. +- */ +-public class HessianMethodSerializationException extends HessianException { +- /** +- * Zero-arg constructor. +- */ +- public HessianMethodSerializationException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public HessianMethodSerializationException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public HessianMethodSerializationException(String message, Throwable cause) +- { +- super(message, cause); +- } +- +- /** +- * Create the exception. +- */ +- public HessianMethodSerializationException(Throwable cause) +- { +- super(cause); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroHessianInput. ++ */ ++public class HessianMethodSerializationException extends HessianException { ++ /** ++ * Zero-arg constructor. ++ */ ++ public HessianMethodSerializationException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianMethodSerializationException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianMethodSerializationException(String message, Throwable cause) ++ { ++ super(message, cause); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianMethodSerializationException(Throwable cause) ++ { ++ super(cause); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianOutput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,973 +1,973 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.OutputStream; +-import java.util.IdentityHashMap; +- +-/** +- * Output stream for Hessian requests, compatible with microedition +- * Java. It only uses classes and types available in JDK. +- * +- *

Since HessianOutput does not depend on any classes other than +- * in the JDK, it can be extracted independently into a smaller package. +- * +- *

HessianOutput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * OutputStream os = ...; // from http connection
+- * HessianOutput out = new HessianOutput(os);
+- * String value;
+- *
+- * out.startCall("hello");  // start hello call
+- * out.writeString("arg1"); // write a string argument
+- * out.completeCall();      // complete the call
+- * 
+- */ +-public class HessianOutput extends AbstractHessianOutput { +- // the output stream/ +- protected OutputStream os; +- // map of references +- private IdentityHashMap _refs; +- private int _version = 1; +- +- /** +- * Creates a new Hessian output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public HessianOutput(OutputStream os) +- { +- init(os); +- } +- +- /** +- * Creates an uninitialized Hessian output stream. +- */ +- public HessianOutput() +- { +- } +- +- /** +- * Initializes the output +- */ +- public void init(OutputStream os) +- { +- this.os = os; +- +- _refs = null; +- +- if (_serializerFactory == null) +- _serializerFactory = new SerializerFactory(); +- } +- +- /** +- * Sets the client's version. +- */ +- public void setVersion(int version) +- { +- _version = version; +- } +- +- /** +- * Writes a complete method call. +- */ +- public void call(String method, Object []args) +- throws IOException +- { +- int length = args != null ? args.length : 0; +- +- startCall(method, length); +- +- for (int i = 0; i < length; i++) +- writeObject(args[i]); +- +- completeCall(); +- } +- +- /** +- * Starts the method call. Clients would use startCall +- * instead of call if they wanted finer control over +- * writing the arguments, or needed to write headers. +- * +- *
+-   * c major minor
+-   * m b16 b8 method-name
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void startCall(String method, int length) +- throws IOException +- { +- os.write('c'); +- os.write(_version); +- os.write(0); +- +- os.write('m'); +- int len = method.length(); +- os.write(len >> 8); +- os.write(len); +- printString(method, 0, len); +- } +- +- /** +- * Writes the call tag. This would be followed by the +- * headers and the method tag. +- * +- *
+-   * c major minor
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void startCall() +- throws IOException +- { +- os.write('c'); +- os.write(0); +- os.write(1); +- } +- +- /** +- * Writes the method tag. +- * +- *
+-   * m b16 b8 method-name
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void writeMethod(String method) +- throws IOException +- { +- os.write('m'); +- int len = method.length(); +- os.write(len >> 8); +- os.write(len); +- printString(method, 0, len); +- } +- +- /** +- * Completes. +- * +- *
+-   * z
+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- os.write('z'); +- } +- +- /** +- * Starts the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * r
+-   * 
+- */ +- public void startReply() +- throws IOException +- { +- os.write('r'); +- os.write(1); +- os.write(0); +- } +- +- /** +- * Completes reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeReply() +- throws IOException +- { +- os.write('z'); +- } +- +- /** +- * Writes a header name. The header value must immediately follow. +- * +- *
+-   * H b16 b8 foo value
+-   * 
+- */ +- public void writeHeader(String name) +- throws IOException +- { +- int len = name.length(); +- +- os.write('H'); +- os.write(len >> 8); +- os.write(len); +- +- printString(name); +- } +- +- /** +- * Writes a fault. The fault will be written +- * as a descriptive string followed by an object: +- * +- *
+-   * f
+-   * <string>code
+-   * <string>the fault code
+-   *
+-   * <string>message
+-   * <string>the fault mesage
+-   *
+-   * <string>detail
+-   * mt\x00\xnnjavax.ejb.FinderException
+-   *     ...
+-   * z
+-   * z
+-   * 
+- * +- * @param code the fault code, a three digit +- */ +- public void writeFault(String code, String message, Object detail) +- throws IOException +- { +- // hessian/3525 +- os.write('r'); +- os.write(1); +- os.write(0); +- +- os.write('f'); +- writeString("code"); +- writeString(code); +- +- writeString("message"); +- writeString(message); +- +- if (detail != null) { +- writeString("detail"); +- writeObject(detail); +- } +- os.write('z'); +- +- os.write('z'); +- } +- +- /** +- * Writes any object to the output stream. +- */ +- public void writeObject(Object object) +- throws IOException +- { +- if (object == null) { +- writeNull(); +- return; +- } +- +- Serializer serializer; +- +- serializer = _serializerFactory.getSerializer(object.getClass()); +- +- serializer.writeObject(object, this); +- } +- +- /** +- * Writes the list header to the stream. List writers will call +- * writeListBegin followed by the list contents and then +- * call writeListEnd. +- * +- *
+-   * V
+-   * t b16 b8 type
+-   * l b32 b24 b16 b8
+-   * 
+- */ +- public boolean writeListBegin(int length, String type) +- throws IOException +- { +- os.write('V'); +- +- if (type != null) { +- os.write('t'); +- printLenString(type); +- } +- +- if (length >= 0) { +- os.write('l'); +- os.write(length >> 24); +- os.write(length >> 16); +- os.write(length >> 8); +- os.write(length); +- } +- +- return true; +- } +- +- /** +- * Writes the tail of the list to the stream. +- */ +- public void writeListEnd() +- throws IOException +- { +- os.write('z'); +- } +- +- /** +- * Writes the map header to the stream. Map writers will call +- * writeMapBegin followed by the map contents and then +- * call writeMapEnd. +- * +- *
+-   * Mt b16 b8 ( )z
+-   * 
+- */ +- public void writeMapBegin(String type) +- throws IOException +- { +- os.write('M'); +- os.write('t'); +- printLenString(type); +- } +- +- /** +- * Writes the tail of the map to the stream. +- */ +- public void writeMapEnd() +- throws IOException +- { +- os.write('z'); +- } +- +- /** +- * Writes a remote object reference to the stream. The type is the +- * type of the remote interface. +- * +- *
+-   * 'r' 't' b16 b8 type url
+-   * 
+- */ +- public void writeRemote(String type, String url) +- throws IOException +- { +- os.write('r'); +- os.write('t'); +- printLenString(type); +- os.write('S'); +- printLenString(url); +- } +- +- /** +- * Writes a boolean value to the stream. The boolean will be written +- * with the following syntax: +- * +- *
+-   * T
+-   * F
+-   * 
+- * +- * @param value the boolean value to write. +- */ +- public void writeBoolean(boolean value) +- throws IOException +- { +- if (value) +- os.write('T'); +- else +- os.write('F'); +- } +- +- /** +- * Writes an integer value to the stream. The integer will be written +- * with the following syntax: +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeInt(int value) +- throws IOException +- { +- os.write('I'); +- os.write(value >> 24); +- os.write(value >> 16); +- os.write(value >> 8); +- os.write(value); +- } +- +- /** +- * Writes a long value to the stream. The long will be written +- * with the following syntax: +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param value the long value to write. +- */ +- public void writeLong(long value) +- throws IOException +- { +- os.write('L'); +- os.write((byte) (value >> 56)); +- os.write((byte) (value >> 48)); +- os.write((byte) (value >> 40)); +- os.write((byte) (value >> 32)); +- os.write((byte) (value >> 24)); +- os.write((byte) (value >> 16)); +- os.write((byte) (value >> 8)); +- os.write((byte) (value)); +- } +- +- /** +- * Writes a double value to the stream. The double will be written +- * with the following syntax: +- * +- *
+-   * D b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param value the double value to write. +- */ +- public void writeDouble(double value) +- throws IOException +- { +- long bits = Double.doubleToLongBits(value); +- +- os.write('D'); +- os.write((byte) (bits >> 56)); +- os.write((byte) (bits >> 48)); +- os.write((byte) (bits >> 40)); +- os.write((byte) (bits >> 32)); +- os.write((byte) (bits >> 24)); +- os.write((byte) (bits >> 16)); +- os.write((byte) (bits >> 8)); +- os.write((byte) (bits)); +- } +- +- /** +- * Writes a date to the stream. +- * +- *
+-   * T  b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param time the date in milliseconds from the epoch in UTC +- */ +- public void writeUTCDate(long time) +- throws IOException +- { +- os.write('d'); +- os.write((byte) (time >> 56)); +- os.write((byte) (time >> 48)); +- os.write((byte) (time >> 40)); +- os.write((byte) (time >> 32)); +- os.write((byte) (time >> 24)); +- os.write((byte) (time >> 16)); +- os.write((byte) (time >> 8)); +- os.write((byte) (time)); +- } +- +- /** +- * Writes a null value to the stream. +- * The null will be written with the following syntax +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeNull() +- throws IOException +- { +- os.write('N'); +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(String value) +- throws IOException +- { +- if (value == null) { +- os.write('N'); +- } +- else { +- int length = value.length(); +- int offset = 0; +- +- while (length > 0x8000) { +- int sublen = 0x8000; +- +- // chunk can't end in high surrogate +- char tail = value.charAt(offset + sublen - 1); +- +- if (0xd800 <= tail && tail <= 0xdbff) +- sublen--; +- +- os.write('s'); +- os.write(sublen >> 8); +- os.write(sublen); +- +- printString(value, offset, sublen); +- +- length -= sublen; +- offset += sublen; +- } +- +- os.write('S'); +- os.write(length >> 8); +- os.write(length); +- +- printString(value, offset, length); +- } +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(char []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- os.write('N'); +- } +- else { +- while (length > 0x8000) { +- int sublen = 0x8000; +- +- // chunk can't end in high surrogate +- char tail = buffer[offset + sublen - 1]; +- +- if (0xd800 <= tail && tail <= 0xdbff) +- sublen--; +- +- os.write('s'); +- os.write(sublen >> 8); +- os.write(sublen); +- +- printString(buffer, offset, sublen); +- +- length -= sublen; +- offset += sublen; +- } +- +- os.write('S'); +- os.write(length >> 8); +- os.write(length); +- +- printString(buffer, offset, length); +- } +- } +- +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer) +- throws IOException +- { +- if (buffer == null) +- os.write('N'); +- else +- writeBytes(buffer, 0, buffer.length); +- } +- +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- os.write('N'); +- } +- else { +- while (length > 0x8000) { +- int sublen = 0x8000; +- +- os.write('b'); +- os.write(sublen >> 8); +- os.write(sublen); +- +- os.write(buffer, offset, sublen); +- +- length -= sublen; +- offset += sublen; +- } +- +- os.write('B'); +- os.write(length >> 8); +- os.write(length); +- os.write(buffer, offset, length); +- } +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * 
+- */ +- public void writeByteBufferStart() +- throws IOException +- { +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- */ +- public void writeByteBufferPart(byte []buffer, int offset, int length) +- throws IOException +- { +- while (length > 0) { +- int sublen = length; +- +- if (0x8000 < sublen) +- sublen = 0x8000; +- +- os.write('b'); +- os.write(sublen >> 8); +- os.write(sublen); +- +- os.write(buffer, offset, sublen); +- +- length -= sublen; +- offset += sublen; +- } +- } +- +- /** +- * Writes a byte buffer to the stream. +- * +- *
+-   * b b16 b18 bytes
+-   * 
+- */ +- public void writeByteBufferEnd(byte []buffer, int offset, int length) +- throws IOException +- { +- writeBytes(buffer, offset, length); +- } +- +- /** +- * Writes a reference. +- * +- *
+-   * R b32 b24 b16 b8
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeRef(int value) +- throws IOException +- { +- os.write('R'); +- os.write(value >> 24); +- os.write(value >> 16); +- os.write(value >> 8); +- os.write(value); +- } +- +- /** +- * Writes a placeholder. +- * +- *
+-   * P
+-   * 
+- */ +- public void writePlaceholder() +- throws IOException +- { +- os.write('P'); +- } +- +- /** +- * If the object has already been written, just write its ref. +- * +- * @return true if we're writing a ref. +- */ +- public boolean addRef(Object object) +- throws IOException +- { +- if (_refs == null) +- _refs = new IdentityHashMap(); +- +- Integer ref = (Integer) _refs.get(object); +- +- if (ref != null) { +- int value = ref.intValue(); +- +- writeRef(value); +- return true; +- } +- else { +- _refs.put(object, new Integer(_refs.size())); +- +- return false; +- } +- } +- +- @Override +- public int getRef(Object obj) +- { +- Integer value; +- +- if (_refs == null) +- return -1; +- +- value = (Integer) _refs.get(obj); +- +- if (value == null) +- return -1; +- else +- return value; +- } +- +- /** +- * Resets the references for streaming. +- */ +- public void resetReferences() +- { +- if (_refs != null) +- _refs.clear(); +- } +- +- /** +- * Removes a reference. +- */ +- public boolean removeRef(Object obj) +- throws IOException +- { +- if (_refs != null) { +- _refs.remove(obj); +- +- return true; +- } +- else +- return false; +- } +- +- /** +- * Replaces a reference from one object to another. +- */ +- public boolean replaceRef(Object oldRef, Object newRef) +- throws IOException +- { +- Integer value = (Integer) _refs.remove(oldRef); +- +- if (value != null) { +- _refs.put(newRef, value); +- +- return true; +- } +- else +- return false; +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 with preceeding length +- * +- * @param v the string to print. +- */ +- public void printLenString(String v) +- throws IOException +- { +- if (v == null) { +- os.write(0); +- os.write(0); +- } +- else { +- int len = v.length(); +- os.write(len >> 8); +- os.write(len); +- +- printString(v, 0, len); +- } +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v) +- throws IOException +- { +- printString(v, 0, v.length()); +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v, int offset, int length) +- throws IOException +- { +- for (int i = 0; i < length; i++) { +- char ch = v.charAt(i + offset); +- +- if (ch < 0x80) +- os.write(ch); +- else if (ch < 0x800) { +- os.write(0xc0 + ((ch >> 6) & 0x1f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- else { +- os.write(0xe0 + ((ch >> 12) & 0xf)); +- os.write(0x80 + ((ch >> 6) & 0x3f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- } +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(char []v, int offset, int length) +- throws IOException +- { +- for (int i = 0; i < length; i++) { +- char ch = v[i + offset]; +- +- if (ch < 0x80) +- os.write(ch); +- else if (ch < 0x800) { +- os.write(0xc0 + ((ch >> 6) & 0x1f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- else { +- os.write(0xe0 + ((ch >> 12) & 0xf)); +- os.write(0x80 + ((ch >> 6) & 0x3f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- } +- } +- +- public void flush() +- throws IOException +- { +- if (this.os != null) +- this.os.flush(); +- } +- +- public void close() +- throws IOException +- { +- if (this.os != null) +- this.os.flush(); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++import java.util.IdentityHashMap; ++ ++/** ++ * Output stream for Hessian requests, compatible with microedition ++ * Java. It only uses classes and types available in JDK. ++ * ++ *

Since HessianOutput does not depend on any classes other than ++ * in the JDK, it can be extracted independently into a smaller package. ++ * ++ *

HessianOutput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * OutputStream os = ...; // from http connection
++ * HessianOutput out = new HessianOutput(os);
++ * String value;
++ *
++ * out.startCall("hello");  // start hello call
++ * out.writeString("arg1"); // write a string argument
++ * out.completeCall();      // complete the call
++ * 
++ */ ++public class HessianOutput extends AbstractHessianOutput { ++ // the output stream/ ++ protected OutputStream os; ++ // map of references ++ private IdentityHashMap _refs; ++ private int _version = 1; ++ ++ /** ++ * Creates a new Hessian output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public HessianOutput(OutputStream os) ++ { ++ init(os); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian output stream. ++ */ ++ public HessianOutput() ++ { ++ } ++ ++ /** ++ * Initializes the output ++ */ ++ public void init(OutputStream os) ++ { ++ this.os = os; ++ ++ _refs = null; ++ ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(); ++ } ++ ++ /** ++ * Sets the client's version. ++ */ ++ public void setVersion(int version) ++ { ++ _version = version; ++ } ++ ++ /** ++ * Writes a complete method call. ++ */ ++ public void call(String method, Object []args) ++ throws IOException ++ { ++ int length = args != null ? args.length : 0; ++ ++ startCall(method, length); ++ ++ for (int i = 0; i < length; i++) ++ writeObject(args[i]); ++ ++ completeCall(); ++ } ++ ++ /** ++ * Starts the method call. Clients would use startCall ++ * instead of call if they wanted finer control over ++ * writing the arguments, or needed to write headers. ++ * ++ *
++   * c major minor
++   * m b16 b8 method-name
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void startCall(String method, int length) ++ throws IOException ++ { ++ os.write('c'); ++ os.write(_version); ++ os.write(0); ++ ++ os.write('m'); ++ int len = method.length(); ++ os.write(len >> 8); ++ os.write(len); ++ printString(method, 0, len); ++ } ++ ++ /** ++ * Writes the call tag. This would be followed by the ++ * headers and the method tag. ++ * ++ *
++   * c major minor
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void startCall() ++ throws IOException ++ { ++ os.write('c'); ++ os.write(0); ++ os.write(1); ++ } ++ ++ /** ++ * Writes the method tag. ++ * ++ *
++   * m b16 b8 method-name
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void writeMethod(String method) ++ throws IOException ++ { ++ os.write('m'); ++ int len = method.length(); ++ os.write(len >> 8); ++ os.write(len); ++ printString(method, 0, len); ++ } ++ ++ /** ++ * Completes. ++ * ++ *
++   * z
++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ os.write('z'); ++ } ++ ++ /** ++ * Starts the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * r
++   * 
++ */ ++ public void startReply() ++ throws IOException ++ { ++ os.write('r'); ++ os.write(1); ++ os.write(0); ++ } ++ ++ /** ++ * Completes reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeReply() ++ throws IOException ++ { ++ os.write('z'); ++ } ++ ++ /** ++ * Writes a header name. The header value must immediately follow. ++ * ++ *
++   * H b16 b8 foo value
++   * 
++ */ ++ public void writeHeader(String name) ++ throws IOException ++ { ++ int len = name.length(); ++ ++ os.write('H'); ++ os.write(len >> 8); ++ os.write(len); ++ ++ printString(name); ++ } ++ ++ /** ++ * Writes a fault. The fault will be written ++ * as a descriptive string followed by an object: ++ * ++ *
++   * f
++   * <string>code
++   * <string>the fault code
++   *
++   * <string>message
++   * <string>the fault mesage
++   *
++   * <string>detail
++   * mt\x00\xnnjavax.ejb.FinderException
++   *     ...
++   * z
++   * z
++   * 
++ * ++ * @param code the fault code, a three digit ++ */ ++ public void writeFault(String code, String message, Object detail) ++ throws IOException ++ { ++ // hessian/3525 ++ os.write('r'); ++ os.write(1); ++ os.write(0); ++ ++ os.write('f'); ++ writeString("code"); ++ writeString(code); ++ ++ writeString("message"); ++ writeString(message); ++ ++ if (detail != null) { ++ writeString("detail"); ++ writeObject(detail); ++ } ++ os.write('z'); ++ ++ os.write('z'); ++ } ++ ++ /** ++ * Writes any object to the output stream. ++ */ ++ public void writeObject(Object object) ++ throws IOException ++ { ++ if (object == null) { ++ writeNull(); ++ return; ++ } ++ ++ Serializer serializer; ++ ++ serializer = _serializerFactory.getSerializer(object.getClass()); ++ ++ serializer.writeObject(object, this); ++ } ++ ++ /** ++ * Writes the list header to the stream. List writers will call ++ * writeListBegin followed by the list contents and then ++ * call writeListEnd. ++ * ++ *
++   * V
++   * t b16 b8 type
++   * l b32 b24 b16 b8
++   * 
++ */ ++ public boolean writeListBegin(int length, String type) ++ throws IOException ++ { ++ os.write('V'); ++ ++ if (type != null) { ++ os.write('t'); ++ printLenString(type); ++ } ++ ++ if (length >= 0) { ++ os.write('l'); ++ os.write(length >> 24); ++ os.write(length >> 16); ++ os.write(length >> 8); ++ os.write(length); ++ } ++ ++ return true; ++ } ++ ++ /** ++ * Writes the tail of the list to the stream. ++ */ ++ public void writeListEnd() ++ throws IOException ++ { ++ os.write('z'); ++ } ++ ++ /** ++ * Writes the map header to the stream. Map writers will call ++ * writeMapBegin followed by the map contents and then ++ * call writeMapEnd. ++ * ++ *
++   * Mt b16 b8 ( )z
++   * 
++ */ ++ public void writeMapBegin(String type) ++ throws IOException ++ { ++ os.write('M'); ++ os.write('t'); ++ printLenString(type); ++ } ++ ++ /** ++ * Writes the tail of the map to the stream. ++ */ ++ public void writeMapEnd() ++ throws IOException ++ { ++ os.write('z'); ++ } ++ ++ /** ++ * Writes a remote object reference to the stream. The type is the ++ * type of the remote interface. ++ * ++ *
++   * 'r' 't' b16 b8 type url
++   * 
++ */ ++ public void writeRemote(String type, String url) ++ throws IOException ++ { ++ os.write('r'); ++ os.write('t'); ++ printLenString(type); ++ os.write('S'); ++ printLenString(url); ++ } ++ ++ /** ++ * Writes a boolean value to the stream. The boolean will be written ++ * with the following syntax: ++ * ++ *
++   * T
++   * F
++   * 
++ * ++ * @param value the boolean value to write. ++ */ ++ public void writeBoolean(boolean value) ++ throws IOException ++ { ++ if (value) ++ os.write('T'); ++ else ++ os.write('F'); ++ } ++ ++ /** ++ * Writes an integer value to the stream. The integer will be written ++ * with the following syntax: ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeInt(int value) ++ throws IOException ++ { ++ os.write('I'); ++ os.write(value >> 24); ++ os.write(value >> 16); ++ os.write(value >> 8); ++ os.write(value); ++ } ++ ++ /** ++ * Writes a long value to the stream. The long will be written ++ * with the following syntax: ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param value the long value to write. ++ */ ++ public void writeLong(long value) ++ throws IOException ++ { ++ os.write('L'); ++ os.write((byte) (value >> 56)); ++ os.write((byte) (value >> 48)); ++ os.write((byte) (value >> 40)); ++ os.write((byte) (value >> 32)); ++ os.write((byte) (value >> 24)); ++ os.write((byte) (value >> 16)); ++ os.write((byte) (value >> 8)); ++ os.write((byte) (value)); ++ } ++ ++ /** ++ * Writes a double value to the stream. The double will be written ++ * with the following syntax: ++ * ++ *
++   * D b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param value the double value to write. ++ */ ++ public void writeDouble(double value) ++ throws IOException ++ { ++ long bits = Double.doubleToLongBits(value); ++ ++ os.write('D'); ++ os.write((byte) (bits >> 56)); ++ os.write((byte) (bits >> 48)); ++ os.write((byte) (bits >> 40)); ++ os.write((byte) (bits >> 32)); ++ os.write((byte) (bits >> 24)); ++ os.write((byte) (bits >> 16)); ++ os.write((byte) (bits >> 8)); ++ os.write((byte) (bits)); ++ } ++ ++ /** ++ * Writes a date to the stream. ++ * ++ *
++   * T  b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param time the date in milliseconds from the epoch in UTC ++ */ ++ public void writeUTCDate(long time) ++ throws IOException ++ { ++ os.write('d'); ++ os.write((byte) (time >> 56)); ++ os.write((byte) (time >> 48)); ++ os.write((byte) (time >> 40)); ++ os.write((byte) (time >> 32)); ++ os.write((byte) (time >> 24)); ++ os.write((byte) (time >> 16)); ++ os.write((byte) (time >> 8)); ++ os.write((byte) (time)); ++ } ++ ++ /** ++ * Writes a null value to the stream. ++ * The null will be written with the following syntax ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeNull() ++ throws IOException ++ { ++ os.write('N'); ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(String value) ++ throws IOException ++ { ++ if (value == null) { ++ os.write('N'); ++ } ++ else { ++ int length = value.length(); ++ int offset = 0; ++ ++ while (length > 0x8000) { ++ int sublen = 0x8000; ++ ++ // chunk can't end in high surrogate ++ char tail = value.charAt(offset + sublen - 1); ++ ++ if (0xd800 <= tail && tail <= 0xdbff) ++ sublen--; ++ ++ os.write('s'); ++ os.write(sublen >> 8); ++ os.write(sublen); ++ ++ printString(value, offset, sublen); ++ ++ length -= sublen; ++ offset += sublen; ++ } ++ ++ os.write('S'); ++ os.write(length >> 8); ++ os.write(length); ++ ++ printString(value, offset, length); ++ } ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(char []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ os.write('N'); ++ } ++ else { ++ while (length > 0x8000) { ++ int sublen = 0x8000; ++ ++ // chunk can't end in high surrogate ++ char tail = buffer[offset + sublen - 1]; ++ ++ if (0xd800 <= tail && tail <= 0xdbff) ++ sublen--; ++ ++ os.write('s'); ++ os.write(sublen >> 8); ++ os.write(sublen); ++ ++ printString(buffer, offset, sublen); ++ ++ length -= sublen; ++ offset += sublen; ++ } ++ ++ os.write('S'); ++ os.write(length >> 8); ++ os.write(length); ++ ++ printString(buffer, offset, length); ++ } ++ } ++ ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer) ++ throws IOException ++ { ++ if (buffer == null) ++ os.write('N'); ++ else ++ writeBytes(buffer, 0, buffer.length); ++ } ++ ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ os.write('N'); ++ } ++ else { ++ while (length > 0x8000) { ++ int sublen = 0x8000; ++ ++ os.write('b'); ++ os.write(sublen >> 8); ++ os.write(sublen); ++ ++ os.write(buffer, offset, sublen); ++ ++ length -= sublen; ++ offset += sublen; ++ } ++ ++ os.write('B'); ++ os.write(length >> 8); ++ os.write(length); ++ os.write(buffer, offset, length); ++ } ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * 
++ */ ++ public void writeByteBufferStart() ++ throws IOException ++ { ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ */ ++ public void writeByteBufferPart(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ while (length > 0) { ++ int sublen = length; ++ ++ if (0x8000 < sublen) ++ sublen = 0x8000; ++ ++ os.write('b'); ++ os.write(sublen >> 8); ++ os.write(sublen); ++ ++ os.write(buffer, offset, sublen); ++ ++ length -= sublen; ++ offset += sublen; ++ } ++ } ++ ++ /** ++ * Writes a byte buffer to the stream. ++ * ++ *
++   * b b16 b18 bytes
++   * 
++ */ ++ public void writeByteBufferEnd(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ writeBytes(buffer, offset, length); ++ } ++ ++ /** ++ * Writes a reference. ++ * ++ *
++   * R b32 b24 b16 b8
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeRef(int value) ++ throws IOException ++ { ++ os.write('R'); ++ os.write(value >> 24); ++ os.write(value >> 16); ++ os.write(value >> 8); ++ os.write(value); ++ } ++ ++ /** ++ * Writes a placeholder. ++ * ++ *
++   * P
++   * 
++ */ ++ public void writePlaceholder() ++ throws IOException ++ { ++ os.write('P'); ++ } ++ ++ /** ++ * If the object has already been written, just write its ref. ++ * ++ * @return true if we're writing a ref. ++ */ ++ public boolean addRef(Object object) ++ throws IOException ++ { ++ if (_refs == null) ++ _refs = new IdentityHashMap(); ++ ++ Integer ref = (Integer) _refs.get(object); ++ ++ if (ref != null) { ++ int value = ref.intValue(); ++ ++ writeRef(value); ++ return true; ++ } ++ else { ++ _refs.put(object, new Integer(_refs.size())); ++ ++ return false; ++ } ++ } ++ ++ @Override ++ public int getRef(Object obj) ++ { ++ Integer value; ++ ++ if (_refs == null) ++ return -1; ++ ++ value = (Integer) _refs.get(obj); ++ ++ if (value == null) ++ return -1; ++ else ++ return value; ++ } ++ ++ /** ++ * Resets the references for streaming. ++ */ ++ public void resetReferences() ++ { ++ if (_refs != null) ++ _refs.clear(); ++ } ++ ++ /** ++ * Removes a reference. ++ */ ++ public boolean removeRef(Object obj) ++ throws IOException ++ { ++ if (_refs != null) { ++ _refs.remove(obj); ++ ++ return true; ++ } ++ else ++ return false; ++ } ++ ++ /** ++ * Replaces a reference from one object to another. ++ */ ++ public boolean replaceRef(Object oldRef, Object newRef) ++ throws IOException ++ { ++ Integer value = (Integer) _refs.remove(oldRef); ++ ++ if (value != null) { ++ _refs.put(newRef, value); ++ ++ return true; ++ } ++ else ++ return false; ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 with preceeding length ++ * ++ * @param v the string to print. ++ */ ++ public void printLenString(String v) ++ throws IOException ++ { ++ if (v == null) { ++ os.write(0); ++ os.write(0); ++ } ++ else { ++ int len = v.length(); ++ os.write(len >> 8); ++ os.write(len); ++ ++ printString(v, 0, len); ++ } ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v) ++ throws IOException ++ { ++ printString(v, 0, v.length()); ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v, int offset, int length) ++ throws IOException ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = v.charAt(i + offset); ++ ++ if (ch < 0x80) ++ os.write(ch); ++ else if (ch < 0x800) { ++ os.write(0xc0 + ((ch >> 6) & 0x1f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ else { ++ os.write(0xe0 + ((ch >> 12) & 0xf)); ++ os.write(0x80 + ((ch >> 6) & 0x3f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ } ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(char []v, int offset, int length) ++ throws IOException ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = v[i + offset]; ++ ++ if (ch < 0x80) ++ os.write(ch); ++ else if (ch < 0x800) { ++ os.write(0xc0 + ((ch >> 6) & 0x1f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ else { ++ os.write(0xe0 + ((ch >> 12) & 0xf)); ++ os.write(0x80 + ((ch >> 6) & 0x3f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ } ++ } ++ ++ public void flush() ++ throws IOException ++ { ++ if (this.os != null) ++ this.os.flush(); ++ } ++ ++ public void close() ++ throws IOException ++ { ++ if (this.os != null) ++ this.os.flush(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianProtocolException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianProtocolException.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianProtocolException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianProtocolException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,110 +1,110 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroHessianInput. +- */ +-public class HessianProtocolException extends IOException { +- private Throwable rootCause; +- +- /** +- * Zero-arg constructor. +- */ +- public HessianProtocolException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public HessianProtocolException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public HessianProtocolException(String message, Throwable rootCause) +- { +- super(message); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Create the exception. +- */ +- public HessianProtocolException(Throwable rootCause) +- { +- super(String.valueOf(rootCause)); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getRootCause() +- { +- return rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getCause() +- { +- return getRootCause(); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroHessianInput. ++ */ ++public class HessianProtocolException extends IOException { ++ private Throwable rootCause; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public HessianProtocolException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianProtocolException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianProtocolException(String message, Throwable rootCause) ++ { ++ super(message); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianProtocolException(Throwable rootCause) ++ { ++ super(String.valueOf(rootCause)); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getRootCause() ++ { ++ return rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getCause() ++ { ++ return getRootCause(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianRemote.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemote.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianRemote.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemote.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,130 +1,130 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-/** +- * Encapsulates a remote address when no stub is available, e.g. for +- * Java MicroEdition. +- */ +-public class HessianRemote implements java.io.Serializable { +- private String type; +- private String url; +- +- /** +- * Creates a new Hessian remote object. +- * +- * @param type the remote stub interface +- * @param url the remote url +- */ +- public HessianRemote(String type, String url) +- { +- this.type = type; +- this.url = url; +- } +- +- /** +- * Creates an uninitialized Hessian remote. +- */ +- public HessianRemote() +- { +- } +- +- /** +- * Returns the remote api class name. +- */ +- public String getType() +- { +- return type; +- } +- +- /** +- * Returns the remote URL. +- */ +- public String getURL() +- { +- return url; +- } +- +- /** +- * Sets the remote URL. +- */ +- public void setURL(String url) +- { +- this.url = url; +- } +- +- /** +- * Defines the hashcode. +- */ +- public int hashCode() +- { +- return url.hashCode(); +- } +- +- /** +- * Defines equality +- */ +- public boolean equals(Object obj) +- { +- if (! (obj instanceof HessianRemote)) +- return false; +- +- HessianRemote remote = (HessianRemote) obj; +- +- return url.equals(remote.url); +- } +- +- /** +- * Readable version of the remote. +- */ +- public String toString() +- { +- return "HessianRemote[" + url + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++/** ++ * Encapsulates a remote address when no stub is available, e.g. for ++ * Java MicroEdition. ++ */ ++public class HessianRemote implements java.io.Serializable { ++ private String type; ++ private String url; ++ ++ /** ++ * Creates a new Hessian remote object. ++ * ++ * @param type the remote stub interface ++ * @param url the remote url ++ */ ++ public HessianRemote(String type, String url) ++ { ++ this.type = type; ++ this.url = url; ++ } ++ ++ /** ++ * Creates an uninitialized Hessian remote. ++ */ ++ public HessianRemote() ++ { ++ } ++ ++ /** ++ * Returns the remote api class name. ++ */ ++ public String getType() ++ { ++ return type; ++ } ++ ++ /** ++ * Returns the remote URL. ++ */ ++ public String getURL() ++ { ++ return url; ++ } ++ ++ /** ++ * Sets the remote URL. ++ */ ++ public void setURL(String url) ++ { ++ this.url = url; ++ } ++ ++ /** ++ * Defines the hashcode. ++ */ ++ public int hashCode() ++ { ++ return url.hashCode(); ++ } ++ ++ /** ++ * Defines equality ++ */ ++ public boolean equals(Object obj) ++ { ++ if (! (obj instanceof HessianRemote)) ++ return false; ++ ++ HessianRemote remote = (HessianRemote) obj; ++ ++ return url.equals(remote.url); ++ } ++ ++ /** ++ * Readable version of the remote. ++ */ ++ public String toString() ++ { ++ return "HessianRemote[" + url + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteObject.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteObject.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteObject.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteObject.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,57 +1,57 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-/** +- * Interface for any hessian remote object. +- */ +-public interface HessianRemoteObject { +- public String getHessianType(); +- public String getHessianURL(); +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++/** ++ * Interface for any hessian remote object. ++ */ ++public interface HessianRemoteObject { ++ public String getHessianType(); ++ public String getHessianURL(); ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteResolver.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteResolver.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteResolver.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteResolver.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,62 +1,62 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Looks up remote objects. The default just returns a HessianRemote object. +- */ +-public interface HessianRemoteResolver { +- /** +- * Looks up a proxy object. +- */ +- public Object lookup(String type, String url) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Looks up remote objects. The default just returns a HessianRemote object. ++ */ ++public interface HessianRemoteResolver { ++ /** ++ * Looks up a proxy object. ++ */ ++ public Object lookup(String type, String url) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerInput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerInput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,184 +1,184 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.ArrayList; +-import java.util.HashMap; +- +-/** +- * Input stream for Hessian requests, deserializing objects using the +- * java.io.Serialization protocol. +- * +- *

HessianSerializerInput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

Serialization

+- * +- *
+- * InputStream is = new FileInputStream("test.xml");
+- * HessianOutput in = new HessianSerializerOutput(is);
+- *
+- * Object obj = in.readObject();
+- * is.close();
+- * 
+- * +- *

Parsing a Hessian reply

+- * +- *
+- * InputStream is = ...; // from http connection
+- * HessianInput in = new HessianSerializerInput(is);
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-public class HessianSerializerInput extends Hessian2Input { +- /** +- * Creates a new Hessian input stream, initialized with an +- * underlying input stream. +- * +- * @param is the underlying input stream. +- */ +- public HessianSerializerInput(InputStream is) +- { +- super(is); +- } +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public HessianSerializerInput() +- { +- super(null); +- } +- +- /** +- * Reads an object from the input stream. cl is known not to be +- * a Map. +- */ +- protected Object readObjectImpl(Class cl) +- throws IOException +- { +- try { +- Object obj = cl.newInstance(); +- +- if (_refs == null) +- _refs = new ArrayList(); +- _refs.add(obj); +- +- HashMap fieldMap = getFieldMap(cl); +- +- int code = read(); +- for (; code >= 0 && code != 'z'; code = read()) { +- unread(); +- +- Object key = readObject(); +- +- Field field = (Field) fieldMap.get(key); +- +- if (field != null) { +- Object value = readObject(field.getType()); +- field.set(obj, value); +- } +- else { +- Object value = readObject(); +- } +- } +- +- if (code != 'z') +- throw expect("map", code); +- +- // if there's a readResolve method, call it +- try { +- Method method = cl.getMethod("readResolve", new Class[0]); +- return method.invoke(obj, new Object[0]); +- } catch (Exception e) { +- } +- +- return obj; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- protected HashMap getFieldMap(Class cl) +- { +- HashMap fieldMap = new HashMap(); +- +- for (; cl != null; cl = cl.getSuperclass()) { +- Field []fields = cl.getDeclaredFields(); +- for (int i = 0; i < fields.length; i++) { +- Field field = fields[i]; +- +- if (Modifier.isTransient(field.getModifiers()) || +- Modifier.isStatic(field.getModifiers())) +- continue; +- +- // XXX: could parameterize the handler to only deal with public +- field.setAccessible(true); +- +- fieldMap.put(field.getName(), field); +- } +- } +- +- return fieldMap; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.HashMap; ++ ++/** ++ * Input stream for Hessian requests, deserializing objects using the ++ * java.io.Serialization protocol. ++ * ++ *

HessianSerializerInput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

Serialization

++ * ++ *
++ * InputStream is = new FileInputStream("test.xml");
++ * HessianOutput in = new HessianSerializerOutput(is);
++ *
++ * Object obj = in.readObject();
++ * is.close();
++ * 
++ * ++ *

Parsing a Hessian reply

++ * ++ *
++ * InputStream is = ...; // from http connection
++ * HessianInput in = new HessianSerializerInput(is);
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++public class HessianSerializerInput extends Hessian2Input { ++ /** ++ * Creates a new Hessian input stream, initialized with an ++ * underlying input stream. ++ * ++ * @param is the underlying input stream. ++ */ ++ public HessianSerializerInput(InputStream is) ++ { ++ super(is); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public HessianSerializerInput() ++ { ++ super(null); ++ } ++ ++ /** ++ * Reads an object from the input stream. cl is known not to be ++ * a Map. ++ */ ++ protected Object readObjectImpl(Class cl) ++ throws IOException ++ { ++ try { ++ Object obj = cl.newInstance(); ++ ++ if (_refs == null) ++ _refs = new ArrayList(); ++ _refs.add(obj); ++ ++ HashMap fieldMap = getFieldMap(cl); ++ ++ int code = read(); ++ for (; code >= 0 && code != 'z'; code = read()) { ++ unread(); ++ ++ Object key = readObject(); ++ ++ Field field = (Field) fieldMap.get(key); ++ ++ if (field != null) { ++ Object value = readObject(field.getType()); ++ field.set(obj, value); ++ } ++ else { ++ Object value = readObject(); ++ } ++ } ++ ++ if (code != 'z') ++ throw expect("map", code); ++ ++ // if there's a readResolve method, call it ++ try { ++ Method method = cl.getMethod("readResolve", new Class[0]); ++ return method.invoke(obj, new Object[0]); ++ } catch (Exception e) { ++ } ++ ++ return obj; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected HashMap getFieldMap(Class cl) ++ { ++ HashMap fieldMap = new HashMap(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isTransient(field.getModifiers()) || ++ Modifier.isStatic(field.getModifiers())) ++ continue; ++ ++ // XXX: could parameterize the handler to only deal with public ++ field.setAccessible(true); ++ ++ fieldMap.put(field.getName(), field); ++ } ++ } ++ ++ return fieldMap; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerOutput.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,147 +1,147 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.OutputStream; +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +- +-/** +- * Output stream for Hessian requests. +- * +- *

HessianOutput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

Serialization

+- * +- *
+- * OutputStream os = new FileOutputStream("test.xml");
+- * HessianOutput out = new HessianSerializerOutput(os);
+- *
+- * out.writeObject(obj);
+- * os.close();
+- * 
+- * +- *

Writing an RPC Call

+- * +- *
+- * OutputStream os = ...; // from http connection
+- * HessianOutput out = new HessianSerializerOutput(os);
+- * String value;
+- *
+- * out.startCall("hello");  // start hello call
+- * out.writeString("arg1"); // write a string argument
+- * out.completeCall();      // complete the call
+- * 
+- */ +-public class HessianSerializerOutput extends Hessian2Output { +- /** +- * Creates a new Hessian output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public HessianSerializerOutput(OutputStream os) +- { +- super(os); +- } +- +- /** +- * Creates an uninitialized Hessian output stream. +- */ +- public HessianSerializerOutput() +- { +- super(null); +- } +- +- /** +- * Applications which override this can do custom serialization. +- * +- * @param object the object to write. +- */ +- public void writeObjectImpl(Object obj) +- throws IOException +- { +- Class cl = obj.getClass(); +- +- try { +- Method method = cl.getMethod("writeReplace", new Class[0]); +- Object repl = method.invoke(obj, new Object[0]); +- +- writeObject(repl); +- return; +- } catch (Exception e) { +- } +- +- try { +- writeMapBegin(cl.getName()); +- for (; cl != null; cl = cl.getSuperclass()) { +- Field []fields = cl.getDeclaredFields(); +- for (int i = 0; i < fields.length; i++) { +- Field field = fields[i]; +- +- if (Modifier.isTransient(field.getModifiers()) || +- Modifier.isStatic(field.getModifiers())) +- continue; +- +- // XXX: could parameterize the handler to only deal with public +- field.setAccessible(true); +- +- writeString(field.getName()); +- writeObject(field.get(obj)); +- } +- } +- writeMapEnd(); +- } catch (IllegalAccessException e) { +- throw new IOExceptionWrapper(e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++ ++/** ++ * Output stream for Hessian requests. ++ * ++ *

HessianOutput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

Serialization

++ * ++ *
++ * OutputStream os = new FileOutputStream("test.xml");
++ * HessianOutput out = new HessianSerializerOutput(os);
++ *
++ * out.writeObject(obj);
++ * os.close();
++ * 
++ * ++ *

Writing an RPC Call

++ * ++ *
++ * OutputStream os = ...; // from http connection
++ * HessianOutput out = new HessianSerializerOutput(os);
++ * String value;
++ *
++ * out.startCall("hello");  // start hello call
++ * out.writeString("arg1"); // write a string argument
++ * out.completeCall();      // complete the call
++ * 
++ */ ++public class HessianSerializerOutput extends Hessian2Output { ++ /** ++ * Creates a new Hessian output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public HessianSerializerOutput(OutputStream os) ++ { ++ super(os); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian output stream. ++ */ ++ public HessianSerializerOutput() ++ { ++ super(null); ++ } ++ ++ /** ++ * Applications which override this can do custom serialization. ++ * ++ * @param object the object to write. ++ */ ++ public void writeObjectImpl(Object obj) ++ throws IOException ++ { ++ Class cl = obj.getClass(); ++ ++ try { ++ Method method = cl.getMethod("writeReplace", new Class[0]); ++ Object repl = method.invoke(obj, new Object[0]); ++ ++ writeObject(repl); ++ return; ++ } catch (Exception e) { ++ } ++ ++ try { ++ writeMapBegin(cl.getName()); ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isTransient(field.getModifiers()) || ++ Modifier.isStatic(field.getModifiers())) ++ continue; ++ ++ // XXX: could parameterize the handler to only deal with public ++ field.setAccessible(true); ++ ++ writeString(field.getName()); ++ writeObject(field.get(obj)); ++ } ++ } ++ writeMapEnd(); ++ } catch (IllegalAccessException e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianServiceException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianServiceException.java +--- hessian-4.0.65-src/com/caucho/hessian/io/HessianServiceException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianServiceException.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,91 +1,91 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroHessianInput. +- */ +-public class HessianServiceException extends Exception { +- private String code; +- private Object detail; +- +- /** +- * Zero-arg constructor. +- */ +- public HessianServiceException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public HessianServiceException(String message, String code, Object detail) +- { +- super(message); +- this.code = code; +- this.detail = detail; +- } +- +- /** +- * Returns the code. +- */ +- public String getCode() +- { +- return code; +- } +- +- /** +- * Returns the detail. +- */ +- public Object getDetail() +- { +- return detail; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroHessianInput. ++ */ ++public class HessianServiceException extends Exception { ++ private String code; ++ private Object detail; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public HessianServiceException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public HessianServiceException(String message, String code, Object detail) ++ { ++ super(message); ++ this.code = code; ++ this.detail = detail; ++ } ++ ++ /** ++ * Returns the code. ++ */ ++ public String getCode() ++ { ++ return code; ++ } ++ ++ /** ++ * Returns the detail. ++ */ ++ public Object getDetail() ++ { ++ return detail; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/IOExceptionWrapper.java hessian-4.0.65-fix/com/caucho/hessian/io/IOExceptionWrapper.java +--- hessian-4.0.65-src/com/caucho/hessian/io/IOExceptionWrapper.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/IOExceptionWrapper.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,77 +1,77 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Exception wrapper for IO. +- */ +-public class IOExceptionWrapper extends IOException { +- private Throwable _cause; +- +- public IOExceptionWrapper(Throwable cause) +- { +- super(cause.toString()); +- +- _cause = cause; +- } +- +- public IOExceptionWrapper(String msg, Throwable cause) +- { +- super(msg); +- +- _cause = cause; +- } +- +- public Throwable getCause() +- { +- return _cause; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Exception wrapper for IO. ++ */ ++public class IOExceptionWrapper extends IOException { ++ private Throwable _cause; ++ ++ public IOExceptionWrapper(Throwable cause) ++ { ++ super(cause.toString()); ++ ++ _cause = cause; ++ } ++ ++ public IOExceptionWrapper(String msg, Throwable cause) ++ { ++ super(msg); ++ ++ _cause = cause; ++ } ++ ++ public Throwable getCause() ++ { ++ return _cause; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InetAddressHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressHandle.java +--- hessian-4.0.65-src/com/caucho/hessian/io/InetAddressHandle.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressHandle.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,81 +1,81 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.net.InetAddress; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-/** +- * Handle for an InetAddress object. +- */ +-public class InetAddressHandle implements java.io.Serializable, HessianHandle +-{ +- private static final Logger log = Logger.getLogger(InetAddressHandle.class.getName()); +- +- private String hostName; +- private byte []address; +- +- public InetAddressHandle(String hostName, byte []address) +- { +- this.hostName = hostName; +- this.address = address; +- } +- +- private Object readResolve() +- { +- try { +- return InetAddress.getByAddress(this.hostName, this.address); +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- +- return null; +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.net.InetAddress; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++/** ++ * Handle for an InetAddress object. ++ */ ++public class InetAddressHandle implements java.io.Serializable, HessianHandle ++{ ++ private static final Logger log = Logger.getLogger(InetAddressHandle.class.getName()); ++ ++ private String hostName; ++ private byte []address; ++ ++ public InetAddressHandle(String hostName, byte []address) ++ { ++ this.hostName = hostName; ++ this.address = address; ++ } ++ ++ private Object readResolve() ++ { ++ try { ++ return InetAddress.getByAddress(this.hostName, this.address); ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ ++ return null; ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InetAddressSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/InetAddressSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,77 +1,77 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.net.InetAddress; +- +-/** +- * Serializing a locale. +- */ +-public class InetAddressSerializer extends AbstractSerializer { +- private static InetAddressSerializer SERIALIZER = new InetAddressSerializer(); +- +- public static InetAddressSerializer create() +- { +- return SERIALIZER; +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (obj == null) +- out.writeNull(); +- else { +- InetAddress addr = (InetAddress) obj; +- out.writeObject(new InetAddressHandle(addr.getHostName(), +- addr.getAddress())); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.net.InetAddress; ++ ++/** ++ * Serializing a locale. ++ */ ++public class InetAddressSerializer extends AbstractSerializer { ++ private static InetAddressSerializer SERIALIZER = new InetAddressSerializer(); ++ ++ public static InetAddressSerializer create() ++ { ++ return SERIALIZER; ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (obj == null) ++ out.writeNull(); ++ else { ++ InetAddress addr = (InetAddress) obj; ++ out.writeObject(new InetAddressHandle(addr.getHostName(), ++ addr.getAddress())); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InputStreamDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/InputStreamDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,70 +1,70 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +- +-/** +- * Serializing a stream object. +- */ +-public class InputStreamDeserializer extends AbstractDeserializer { +- public static final InputStreamDeserializer DESER +- = new InputStreamDeserializer(); +- +- public InputStreamDeserializer() +- { +- } +- +- public Object readObject(AbstractHessianInput in) +- throws IOException +- { +- return in.readInputStream(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++ ++/** ++ * Serializing a stream object. ++ */ ++public class InputStreamDeserializer extends AbstractDeserializer { ++ public static final InputStreamDeserializer DESER ++ = new InputStreamDeserializer(); ++ ++ public InputStreamDeserializer() ++ { ++ } ++ ++ public Object readObject(AbstractHessianInput in) ++ throws IOException ++ { ++ return in.readInputStream(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InputStreamSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/InputStreamSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,73 +1,73 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +- +-/** +- * Serializing a stream object. +- */ +-public class InputStreamSerializer extends AbstractSerializer { +- public InputStreamSerializer() +- { +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- InputStream is = (InputStream) obj; +- +- if (is == null) +- out.writeNull(); +- else { +- out.writeByteStream(is); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++ ++/** ++ * Serializing a stream object. ++ */ ++public class InputStreamSerializer extends AbstractSerializer { ++ public InputStreamSerializer() ++ { ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ InputStream is = (InputStream) obj; ++ ++ if (is == null) ++ out.writeNull(); ++ else { ++ out.writeByteStream(is); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/IteratorDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/IteratorDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/IteratorDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/IteratorDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,85 +1,85 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.ArrayList; +- +-/** +- * Deserializing a JDK 1.2 Collection. +- */ +-public class IteratorDeserializer extends AbstractListDeserializer { +- private static IteratorDeserializer _deserializer; +- +- public static IteratorDeserializer create() +- { +- if (_deserializer == null) +- _deserializer = new IteratorDeserializer(); +- +- return _deserializer; +- } +- +- @Override +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- ArrayList list = new ArrayList(); +- +- in.addRef(list); +- +- while (! in.isEnd()) +- list.add(in.readObject()); +- +- in.readEnd(); +- +- return list.iterator(); +- } +-} +- +- ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.ArrayList; ++ ++/** ++ * Deserializing a JDK 1.2 Collection. ++ */ ++public class IteratorDeserializer extends AbstractListDeserializer { ++ private static IteratorDeserializer _deserializer; ++ ++ public static IteratorDeserializer create() ++ { ++ if (_deserializer == null) ++ _deserializer = new IteratorDeserializer(); ++ ++ return _deserializer; ++ } ++ ++ @Override ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ ArrayList list = new ArrayList(); ++ ++ in.addRef(list); ++ ++ while (! in.isEnd()) ++ list.add(in.readObject()); ++ ++ in.readEnd(); ++ ++ return list.iterator(); ++ } ++} ++ ++ +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/IteratorSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/IteratorSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/IteratorSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/IteratorSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,84 +1,84 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.Iterator; +- +-/** +- * Serializing a JDK 1.2 Iterator. +- */ +-public class IteratorSerializer extends AbstractSerializer { +- private static IteratorSerializer _serializer; +- +- public static IteratorSerializer create() +- { +- if (_serializer == null) +- _serializer = new IteratorSerializer(); +- +- return _serializer; +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- Iterator iter = (Iterator) obj; +- +- boolean hasEnd = out.writeListBegin(-1, null); +- +- while (iter.hasNext()) { +- Object value = iter.next(); +- +- out.writeObject(value); +- } +- +- if (hasEnd) +- out.writeListEnd(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.Iterator; ++ ++/** ++ * Serializing a JDK 1.2 Iterator. ++ */ ++public class IteratorSerializer extends AbstractSerializer { ++ private static IteratorSerializer _serializer; ++ ++ public static IteratorSerializer create() ++ { ++ if (_serializer == null) ++ _serializer = new IteratorSerializer(); ++ ++ return _serializer; ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ Iterator iter = (Iterator) obj; ++ ++ boolean hasEnd = out.writeListBegin(-1, null); ++ ++ while (iter.hasNext()) { ++ Object value = iter.next(); ++ ++ out.writeObject(value); ++ } ++ ++ if (hasEnd) ++ out.writeListEnd(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/JavaDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/JavaDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/JavaDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/JavaDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,448 +1,448 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Constructor; +-import java.lang.reflect.Field; +-import java.lang.reflect.InvocationTargetException; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.HashMap; +- +-import com.caucho.hessian.io.FieldDeserializer2Factory.NullFieldDeserializer; +- +-/** +- * Serializing an object for known object types. +- */ +-public class JavaDeserializer extends AbstractMapDeserializer { +- private Class _type; +- private HashMap _fieldMap; +- private Method _readResolve; +- private Constructor _constructor; +- private Object []_constructorArgs; +- +- public JavaDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) +- { +- _type = cl; +- _fieldMap = getFieldMap(cl, fieldFactory); +- +- _readResolve = getReadResolve(cl); +- +- if (_readResolve != null) { +- _readResolve.setAccessible(true); +- } +- +- _constructor = getConstructor(cl); +- _constructorArgs = getConstructorArgs(_constructor); +- } +- +- protected Constructor getConstructor(Class cl) +- { +- Constructor []constructors = cl.getDeclaredConstructors(); +- long bestCost = Long.MAX_VALUE; +- +- Constructor constructor = null; +- +- for (int i = 0; i < constructors.length; i++) { +- Class []param = constructors[i].getParameterTypes(); +- long cost = 0; +- +- for (int j = 0; j < param.length; j++) { +- cost = 4 * cost; +- +- if (Object.class.equals(param[j])) +- cost += 1; +- else if (String.class.equals(param[j])) +- cost += 2; +- else if (int.class.equals(param[j])) +- cost += 3; +- else if (long.class.equals(param[j])) +- cost += 4; +- else if (param[j].isPrimitive()) +- cost += 5; +- else +- cost += 6; +- } +- +- if (cost < 0 || cost > (1 << 48)) +- cost = 1 << 48; +- +- cost += (long) param.length << 48; +- +- if (cost < bestCost) { +- constructor = constructors[i]; +- bestCost = cost; +- } +- } +- +- if (constructor != null) { +- constructor.setAccessible(true); +- } +- +- return constructor; +- } +- +- protected Object []getConstructorArgs(Constructor constructor) +- { +- Object []constructorArgs = null; +- +- if (constructor != null) { +- Class []params = constructor.getParameterTypes(); +- constructorArgs = new Object[params.length]; +- for (int i = 0; i < params.length; i++) { +- constructorArgs[i] = getParamArg(params[i]); +- } +- } +- +- return constructorArgs; +- } +- +- @Override +- public Class getType() +- { +- return _type; +- } +- +- @Override +- public boolean isReadResolve() +- { +- return _readResolve != null; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- try { +- Object obj = instantiate(); +- +- return readMap(in, obj); +- } catch (IOException e) { +- throw e; +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); +- } +- } +- +- @Override +- public Object []createFields(int len) +- { +- return new FieldDeserializer2[len]; +- } +- +- @Override +- public Object createField(String name) +- { +- Object reader = _fieldMap.get(name); +- +- if (reader == null) +- reader = NullFieldDeserializer.DESER; +- +- return reader; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException +- { +- try { +- Object obj = instantiate(); +- +- return readObject(in, obj, (FieldDeserializer2 []) fields); +- } catch (IOException e) { +- throw e; +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); +- } +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, +- String []fieldNames) +- throws IOException +- { +- try { +- Object obj = instantiate(); +- +- return readObject(in, obj, fieldNames); +- } catch (IOException e) { +- throw e; +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); +- } +- } +- +- /** +- * Returns the readResolve method +- */ +- protected Method getReadResolve(Class cl) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (method.getName().equals("readResolve") +- && method.getParameterTypes().length == 0) +- return method; +- } +- } +- +- return null; +- } +- +- public Object readMap(AbstractHessianInput in, Object obj) +- throws IOException +- { +- try { +- int ref = in.addRef(obj); +- +- while (! in.isEnd()) { +- Object key = in.readObject(); +- +- FieldDeserializer2 deser = _fieldMap.get(key); +- +- if (deser != null) +- deser.deserialize(in, obj); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- Object resolve = resolve(in, obj); +- +- if (obj != resolve) +- in.setRef(ref, resolve); +- +- return resolve; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- private Object readObject(AbstractHessianInput in, +- Object obj, +- FieldDeserializer2 []fields) +- throws IOException +- { +- try { +- int ref = in.addRef(obj); +- +- for (FieldDeserializer2 reader : fields) { +- reader.deserialize(in, obj); +- } +- +- Object resolve = resolve(in, obj); +- +- if (obj != resolve) +- in.setRef(ref, resolve); +- +- return resolve; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); +- } +- } +- +- public Object readObject(AbstractHessianInput in, +- Object obj, +- String []fieldNames) +- throws IOException +- { +- try { +- int ref = in.addRef(obj); +- +- for (String fieldName : fieldNames) { +- FieldDeserializer2 reader = _fieldMap.get(fieldName); +- +- if (reader != null) +- reader.deserialize(in, obj); +- else +- in.readObject(); +- } +- +- Object resolve = resolve(in, obj); +- +- if (obj != resolve) +- in.setRef(ref, resolve); +- +- return resolve; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); +- } +- } +- +- protected Object resolve(AbstractHessianInput in, Object obj) +- throws Exception +- { +- // if there's a readResolve method, call it +- try { +- if (_readResolve != null) +- return _readResolve.invoke(obj, new Object[0]); +- } catch (InvocationTargetException e) { +- if (e.getCause() instanceof Exception) +- throw (Exception) e.getCause(); +- else +- throw e; +- } +- +- return obj; +- } +- +- protected Object instantiate() +- throws Exception +- { +- try { +- if (_constructor != null) +- return _constructor.newInstance(_constructorArgs); +- else +- return _type.newInstance(); +- } catch (Exception e) { +- throw new HessianProtocolException("'" + _type.getName() + "' could not be instantiated", e); +- } +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- protected HashMap +- getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) +- { +- HashMap fieldMap +- = new HashMap(); +- +- for (; cl != null; cl = cl.getSuperclass()) { +- Field []fields = cl.getDeclaredFields(); +- for (int i = 0; i < fields.length; i++) { +- Field field = fields[i]; +- +- if (Modifier.isTransient(field.getModifiers()) +- || Modifier.isStatic(field.getModifiers())) +- continue; +- else if (fieldMap.get(field.getName()) != null) +- continue; +- +- /* +- // XXX: could parameterize the handler to only deal with public +- try { +- field.setAccessible(true); +- } catch (Throwable e) { +- e.printStackTrace(); +- } +- */ +- +- FieldDeserializer2 deser = fieldFactory.create(field); +- +- fieldMap.put(field.getName(), deser); +- } +- } +- +- return fieldMap; +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- protected static Object getParamArg(Class cl) +- { +- if (! cl.isPrimitive()) +- return null; +- else if (boolean.class.equals(cl)) +- return Boolean.FALSE; +- else if (byte.class.equals(cl)) +- return new Byte((byte) 0); +- else if (short.class.equals(cl)) +- return new Short((short) 0); +- else if (char.class.equals(cl)) +- return new Character((char) 0); +- else if (int.class.equals(cl)) +- return Integer.valueOf(0); +- else if (long.class.equals(cl)) +- return Long.valueOf(0); +- else if (float.class.equals(cl)) +- return Float.valueOf(0); +- else if (double.class.equals(cl)) +- return Double.valueOf(0); +- else +- throw new UnsupportedOperationException(); +- } +- +- static void logDeserializeError(Field field, Object obj, Object value, +- Throwable e) +- throws IOException +- { +- String fieldName = (field.getDeclaringClass().getName() +- + "." + field.getName()); +- +- if (e instanceof HessianFieldException) +- throw (HessianFieldException) e; +- else if (e instanceof IOException) +- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); +- +- if (value != null) +- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" +- + " cannot be assigned to '" + field.getType().getName() + "'", e); +- else +- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Constructor; ++import java.lang.reflect.Field; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.HashMap; ++ ++import com.caucho.hessian.io.FieldDeserializer2Factory.NullFieldDeserializer; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class JavaDeserializer extends AbstractMapDeserializer { ++ private Class _type; ++ private HashMap _fieldMap; ++ private Method _readResolve; ++ private Constructor _constructor; ++ private Object []_constructorArgs; ++ ++ public JavaDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) ++ { ++ _type = cl; ++ _fieldMap = getFieldMap(cl, fieldFactory); ++ ++ _readResolve = getReadResolve(cl); ++ ++ if (_readResolve != null) { ++ _readResolve.setAccessible(true); ++ } ++ ++ _constructor = getConstructor(cl); ++ _constructorArgs = getConstructorArgs(_constructor); ++ } ++ ++ protected Constructor getConstructor(Class cl) ++ { ++ Constructor []constructors = cl.getDeclaredConstructors(); ++ long bestCost = Long.MAX_VALUE; ++ ++ Constructor constructor = null; ++ ++ for (int i = 0; i < constructors.length; i++) { ++ Class []param = constructors[i].getParameterTypes(); ++ long cost = 0; ++ ++ for (int j = 0; j < param.length; j++) { ++ cost = 4 * cost; ++ ++ if (Object.class.equals(param[j])) ++ cost += 1; ++ else if (String.class.equals(param[j])) ++ cost += 2; ++ else if (int.class.equals(param[j])) ++ cost += 3; ++ else if (long.class.equals(param[j])) ++ cost += 4; ++ else if (param[j].isPrimitive()) ++ cost += 5; ++ else ++ cost += 6; ++ } ++ ++ if (cost < 0 || cost > (1 << 48)) ++ cost = 1 << 48; ++ ++ cost += (long) param.length << 48; ++ ++ if (cost < bestCost) { ++ constructor = constructors[i]; ++ bestCost = cost; ++ } ++ } ++ ++ if (constructor != null) { ++ constructor.setAccessible(true); ++ } ++ ++ return constructor; ++ } ++ ++ protected Object []getConstructorArgs(Constructor constructor) ++ { ++ Object []constructorArgs = null; ++ ++ if (constructor != null) { ++ Class []params = constructor.getParameterTypes(); ++ constructorArgs = new Object[params.length]; ++ for (int i = 0; i < params.length; i++) { ++ constructorArgs[i] = getParamArg(params[i]); ++ } ++ } ++ ++ return constructorArgs; ++ } ++ ++ @Override ++ public Class getType() ++ { ++ return _type; ++ } ++ ++ @Override ++ public boolean isReadResolve() ++ { ++ return _readResolve != null; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readMap(in, obj); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object []createFields(int len) ++ { ++ return new FieldDeserializer2[len]; ++ } ++ ++ @Override ++ public Object createField(String name) ++ { ++ Object reader = _fieldMap.get(name); ++ ++ if (reader == null) ++ reader = NullFieldDeserializer.DESER; ++ ++ return reader; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, (FieldDeserializer2 []) fields); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, fieldNames); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ /** ++ * Returns the readResolve method ++ */ ++ protected Method getReadResolve(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("readResolve") ++ && method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ public Object readMap(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ while (! in.isEnd()) { ++ Object key = in.readObject(); ++ ++ FieldDeserializer2 deser = _fieldMap.get(key); ++ ++ if (deser != null) ++ deser.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ private Object readObject(AbstractHessianInput in, ++ Object obj, ++ FieldDeserializer2 []fields) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (FieldDeserializer2 reader : fields) { ++ reader.deserialize(in, obj); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object obj, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (String fieldName : fieldNames) { ++ FieldDeserializer2 reader = _fieldMap.get(fieldName); ++ ++ if (reader != null) ++ reader.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ protected Object resolve(AbstractHessianInput in, Object obj) ++ throws Exception ++ { ++ // if there's a readResolve method, call it ++ try { ++ if (_readResolve != null) ++ return _readResolve.invoke(obj, new Object[0]); ++ } catch (InvocationTargetException e) { ++ if (e.getCause() instanceof Exception) ++ throw (Exception) e.getCause(); ++ else ++ throw e; ++ } ++ ++ return obj; ++ } ++ ++ protected Object instantiate() ++ throws Exception ++ { ++ try { ++ if (_constructor != null) ++ return _constructor.newInstance(_constructorArgs); ++ else ++ return _type.newInstance(); ++ } catch (Exception e) { ++ throw new HessianProtocolException("'" + _type.getName() + "' could not be instantiated", e); ++ } ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected HashMap ++ getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) ++ { ++ HashMap fieldMap ++ = new HashMap(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isTransient(field.getModifiers()) ++ || Modifier.isStatic(field.getModifiers())) ++ continue; ++ else if (fieldMap.get(field.getName()) != null) ++ continue; ++ ++ /* ++ // XXX: could parameterize the handler to only deal with public ++ try { ++ field.setAccessible(true); ++ } catch (Throwable e) { ++ e.printStackTrace(); ++ } ++ */ ++ ++ FieldDeserializer2 deser = fieldFactory.create(field); ++ ++ fieldMap.put(field.getName(), deser); ++ } ++ } ++ ++ return fieldMap; ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected static Object getParamArg(Class cl) ++ { ++ if (! cl.isPrimitive()) ++ return null; ++ else if (boolean.class.equals(cl)) ++ return Boolean.FALSE; ++ else if (byte.class.equals(cl)) ++ return new Byte((byte) 0); ++ else if (short.class.equals(cl)) ++ return new Short((short) 0); ++ else if (char.class.equals(cl)) ++ return new Character((char) 0); ++ else if (int.class.equals(cl)) ++ return Integer.valueOf(0); ++ else if (long.class.equals(cl)) ++ return Long.valueOf(0); ++ else if (float.class.equals(cl)) ++ return Float.valueOf(0); ++ else if (double.class.equals(cl)) ++ return Double.valueOf(0); ++ else ++ throw new UnsupportedOperationException(); ++ } ++ ++ static void logDeserializeError(Field field, Object obj, Object value, ++ Throwable e) ++ throws IOException ++ { ++ String fieldName = (field.getDeclaringClass().getName() ++ + "." + field.getName()); ++ ++ if (e instanceof HessianFieldException) ++ throw (HessianFieldException) e; ++ else if (e instanceof IOException) ++ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); ++ ++ if (value != null) ++ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" ++ + " cannot be assigned to '" + field.getType().getName() + "'", e); ++ else ++ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/JavaSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/JavaSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/JavaSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/JavaSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,477 +1,477 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.ref.SoftReference; +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.ArrayList; +-import java.util.WeakHashMap; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import com.caucho.hessian.HessianUnshared; +- +-/** +- * Serializing an object for known object types. +- */ +-public class JavaSerializer extends AbstractSerializer +-{ +- private static final Logger log +- = Logger.getLogger(JavaSerializer.class.getName()); +- +- private static final WeakHashMap,SoftReference> _serializerMap +- = new WeakHashMap,SoftReference>(); +- +- private Field []_fields; +- private FieldSerializer []_fieldSerializers; +- +- private Object _writeReplaceFactory; +- private Method _writeReplace; +- +- public JavaSerializer(Class cl) +- { +- introspect(cl); +- +- _writeReplace = getWriteReplace(cl); +- +- if (_writeReplace != null) +- _writeReplace.setAccessible(true); +- } +- +- public static Serializer create(Class cl) +- { +- synchronized (_serializerMap) { +- SoftReference baseRef +- = _serializerMap.get(cl); +- +- JavaSerializer base = baseRef != null ? baseRef.get() : null; +- +- if (base == null) { +- if (cl.isAnnotationPresent(HessianUnshared.class)) +- base = new JavaUnsharedSerializer(cl); +- else +- base = new JavaSerializer(cl); +- +- baseRef = new SoftReference(base); +- _serializerMap.put(cl, baseRef); +- } +- +- return base; +- } +- } +- +- protected void introspect(Class cl) +- { +- if (_writeReplace != null) +- _writeReplace.setAccessible(true); +- +- ArrayList primitiveFields = new ArrayList(); +- ArrayList compoundFields = new ArrayList(); +- +- for (; cl != null; cl = cl.getSuperclass()) { +- Field []fields = cl.getDeclaredFields(); +- for (int i = 0; i < fields.length; i++) { +- Field field = fields[i]; +- +- if (Modifier.isTransient(field.getModifiers()) +- || Modifier.isStatic(field.getModifiers())) +- continue; +- +- // XXX: could parameterize the handler to only deal with public +- field.setAccessible(true); +- +- if (field.getType().isPrimitive() +- || (field.getType().getName().startsWith("java.lang.") +- && ! field.getType().equals(Object.class))) +- primitiveFields.add(field); +- else +- compoundFields.add(field); +- } +- } +- +- ArrayList fields = new ArrayList(); +- fields.addAll(primitiveFields); +- fields.addAll(compoundFields); +- +- _fields = new Field[fields.size()]; +- fields.toArray(_fields); +- +- _fieldSerializers = new FieldSerializer[_fields.length]; +- +- for (int i = 0; i < _fields.length; i++) { +- _fieldSerializers[i] = getFieldSerializer(_fields[i].getType()); +- } +- } +- +- /** +- * Returns the writeReplace method +- */ +- protected static Method getWriteReplace(Class cl) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (method.getName().equals("writeReplace") +- && method.getParameterTypes().length == 0) +- return method; +- } +- } +- +- return null; +- } +- +- /** +- * Returns the writeReplace method +- */ +- protected Method getWriteReplace(Class cl, Class param) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- for (Method method : cl.getDeclaredMethods()) { +- if (method.getName().equals("writeReplace") +- && method.getParameterTypes().length == 1 +- && param.equals(method.getParameterTypes()[0])) +- return method; +- } +- } +- +- return null; +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) { +- return; +- } +- +- Class cl = obj.getClass(); +- +- try { +- if (_writeReplace != null) { +- Object repl; +- +- if (_writeReplaceFactory != null) +- repl = _writeReplace.invoke(_writeReplaceFactory, obj); +- else +- repl = _writeReplace.invoke(obj); +- +- // out.removeRef(obj); +- +- /* +- out.writeObject(repl); +- +- out.replaceRef(repl, obj); +- */ +- +- //hessian/3a5a +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref < -1) { +- writeObject10(repl, out); +- } else { +- if (ref == -1) { +- writeDefinition20(out); +- out.writeObjectBegin(cl.getName()); +- } +- +- writeInstance(repl, out); +- } +- +- return; +- } +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- // log.log(Level.FINE, e.toString(), e); +- throw new RuntimeException(e); +- } +- +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref < -1) { +- writeObject10(obj, out); +- } +- else { +- if (ref == -1) { +- writeDefinition20(out); +- out.writeObjectBegin(cl.getName()); +- } +- +- writeInstance(obj, out); +- } +- } +- +- protected void writeObject10(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- for (int i = 0; i < _fields.length; i++) { +- Field field = _fields[i]; +- +- out.writeString(field.getName()); +- +- _fieldSerializers[i].serialize(out, obj, field); +- } +- +- out.writeMapEnd(); +- } +- +- private void writeDefinition20(AbstractHessianOutput out) +- throws IOException +- { +- out.writeClassFieldLength(_fields.length); +- +- for (int i = 0; i < _fields.length; i++) { +- Field field = _fields[i]; +- +- out.writeString(field.getName()); +- } +- } +- +- @Override +- public void writeInstance(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- try { +- for (int i = 0; i < _fields.length; i++) { +- Field field = _fields[i]; +- +- _fieldSerializers[i].serialize(out, obj, field); +- } +- } catch (RuntimeException e) { +- throw new RuntimeException(e.getMessage() + "\n class: " +- + obj.getClass().getName() +- + " (object=" + obj + ")", +- e); +- } catch (IOException e) { +- throw new IOExceptionWrapper(e.getMessage() + "\n class: " +- + obj.getClass().getName() +- + " (object=" + obj + ")", +- e); +- } +- } +- +- private static FieldSerializer getFieldSerializer(Class type) +- { +- if (int.class.equals(type) +- || byte.class.equals(type) +- || short.class.equals(type) +- || int.class.equals(type)) { +- return IntFieldSerializer.SER; +- } +- else if (long.class.equals(type)) { +- return LongFieldSerializer.SER; +- } +- else if (double.class.equals(type) || +- float.class.equals(type)) { +- return DoubleFieldSerializer.SER; +- } +- else if (boolean.class.equals(type)) { +- return BooleanFieldSerializer.SER; +- } +- else if (String.class.equals(type)) { +- return StringFieldSerializer.SER; +- } +- else if (java.util.Date.class.equals(type) +- || java.sql.Date.class.equals(type) +- || java.sql.Timestamp.class.equals(type) +- || java.sql.Time.class.equals(type)) { +- return DateFieldSerializer.SER; +- } +- else +- return FieldSerializer.SER; +- } +- +- static class FieldSerializer { +- static final FieldSerializer SER = new FieldSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Field field) +- throws IOException +- { +- Object value = null; +- +- try { +- value = field.get(obj); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- try { +- out.writeObject(value); +- } catch (RuntimeException e) { +- throw new RuntimeException(e.getMessage() + "\n field: " +- + field.getDeclaringClass().getName() +- + '.' + field.getName(), +- e); +- } catch (IOException e) { +- throw new IOExceptionWrapper(e.getMessage() + "\n field: " +- + field.getDeclaringClass().getName() +- + '.' + field.getName(), +- e); +- } +- } +- } +- +- static class BooleanFieldSerializer extends FieldSerializer { +- static final FieldSerializer SER = new BooleanFieldSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Field field) +- throws IOException +- { +- boolean value = false; +- +- try { +- value = field.getBoolean(obj); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeBoolean(value); +- } +- } +- +- static class IntFieldSerializer extends FieldSerializer { +- static final FieldSerializer SER = new IntFieldSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Field field) +- throws IOException +- { +- int value = 0; +- +- try { +- value = field.getInt(obj); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeInt(value); +- } +- } +- +- static class LongFieldSerializer extends FieldSerializer { +- static final FieldSerializer SER = new LongFieldSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Field field) +- throws IOException +- { +- long value = 0; +- +- try { +- value = field.getLong(obj); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeLong(value); +- } +- } +- +- static class DoubleFieldSerializer extends FieldSerializer { +- static final FieldSerializer SER = new DoubleFieldSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Field field) +- throws IOException +- { +- double value = 0; +- +- try { +- value = field.getDouble(obj); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeDouble(value); +- } +- } +- +- static class StringFieldSerializer extends FieldSerializer { +- static final FieldSerializer SER = new StringFieldSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Field field) +- throws IOException +- { +- String value = null; +- +- try { +- value = (String) field.get(obj); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- out.writeString(value); +- } +- } +- +- static class DateFieldSerializer extends FieldSerializer { +- static final FieldSerializer SER = new DateFieldSerializer(); +- +- void serialize(AbstractHessianOutput out, Object obj, Field field) +- throws IOException +- { +- java.util.Date value = null; +- +- try { +- value = (java.util.Date) field.get(obj); +- } catch (IllegalAccessException e) { +- log.log(Level.FINE, e.toString(), e); +- } +- +- if (value == null) +- out.writeNull(); +- else +- out.writeUTCDate(value.getTime()); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.ref.SoftReference; ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.WeakHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import com.caucho.hessian.HessianUnshared; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class JavaSerializer extends AbstractSerializer ++{ ++ private static final Logger log ++ = Logger.getLogger(JavaSerializer.class.getName()); ++ ++ private static final WeakHashMap,SoftReference> _serializerMap ++ = new WeakHashMap,SoftReference>(); ++ ++ private Field []_fields; ++ private FieldSerializer []_fieldSerializers; ++ ++ private Object _writeReplaceFactory; ++ private Method _writeReplace; ++ ++ public JavaSerializer(Class cl) ++ { ++ introspect(cl); ++ ++ _writeReplace = getWriteReplace(cl); ++ ++ if (_writeReplace != null) ++ _writeReplace.setAccessible(true); ++ } ++ ++ public static Serializer create(Class cl) ++ { ++ synchronized (_serializerMap) { ++ SoftReference baseRef ++ = _serializerMap.get(cl); ++ ++ JavaSerializer base = baseRef != null ? baseRef.get() : null; ++ ++ if (base == null) { ++ if (cl.isAnnotationPresent(HessianUnshared.class)) ++ base = new JavaUnsharedSerializer(cl); ++ else ++ base = new JavaSerializer(cl); ++ ++ baseRef = new SoftReference(base); ++ _serializerMap.put(cl, baseRef); ++ } ++ ++ return base; ++ } ++ } ++ ++ protected void introspect(Class cl) ++ { ++ if (_writeReplace != null) ++ _writeReplace.setAccessible(true); ++ ++ ArrayList primitiveFields = new ArrayList(); ++ ArrayList compoundFields = new ArrayList(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isTransient(field.getModifiers()) ++ || Modifier.isStatic(field.getModifiers())) ++ continue; ++ ++ // XXX: could parameterize the handler to only deal with public ++ field.setAccessible(true); ++ ++ if (field.getType().isPrimitive() ++ || (field.getType().getName().startsWith("java.lang.") ++ && ! field.getType().equals(Object.class))) ++ primitiveFields.add(field); ++ else ++ compoundFields.add(field); ++ } ++ } ++ ++ ArrayList fields = new ArrayList(); ++ fields.addAll(primitiveFields); ++ fields.addAll(compoundFields); ++ ++ _fields = new Field[fields.size()]; ++ fields.toArray(_fields); ++ ++ _fieldSerializers = new FieldSerializer[_fields.length]; ++ ++ for (int i = 0; i < _fields.length; i++) { ++ _fieldSerializers[i] = getFieldSerializer(_fields[i].getType()); ++ } ++ } ++ ++ /** ++ * Returns the writeReplace method ++ */ ++ protected static Method getWriteReplace(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("writeReplace") ++ && method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ /** ++ * Returns the writeReplace method ++ */ ++ protected Method getWriteReplace(Class cl, Class param) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ for (Method method : cl.getDeclaredMethods()) { ++ if (method.getName().equals("writeReplace") ++ && method.getParameterTypes().length == 1 ++ && param.equals(method.getParameterTypes()[0])) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) { ++ return; ++ } ++ ++ Class cl = obj.getClass(); ++ ++ try { ++ if (_writeReplace != null) { ++ Object repl; ++ ++ if (_writeReplaceFactory != null) ++ repl = _writeReplace.invoke(_writeReplaceFactory, obj); ++ else ++ repl = _writeReplace.invoke(obj); ++ ++ // out.removeRef(obj); ++ ++ /* ++ out.writeObject(repl); ++ ++ out.replaceRef(repl, obj); ++ */ ++ ++ //hessian/3a5a ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref < -1) { ++ writeObject10(repl, out); ++ } else { ++ if (ref == -1) { ++ writeDefinition20(out); ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ writeInstance(repl, out); ++ } ++ ++ return; ++ } ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ // log.log(Level.FINE, e.toString(), e); ++ throw new RuntimeException(e); ++ } ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref < -1) { ++ writeObject10(obj, out); ++ } ++ else { ++ if (ref == -1) { ++ writeDefinition20(out); ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ writeInstance(obj, out); ++ } ++ } ++ ++ protected void writeObject10(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ ++ _fieldSerializers[i].serialize(out, obj, field); ++ } ++ ++ out.writeMapEnd(); ++ } ++ ++ private void writeDefinition20(AbstractHessianOutput out) ++ throws IOException ++ { ++ out.writeClassFieldLength(_fields.length); ++ ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ } ++ } ++ ++ @Override ++ public void writeInstance(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ try { ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ _fieldSerializers[i].serialize(out, obj, field); ++ } ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } ++ } ++ ++ private static FieldSerializer getFieldSerializer(Class type) ++ { ++ if (int.class.equals(type) ++ || byte.class.equals(type) ++ || short.class.equals(type) ++ || int.class.equals(type)) { ++ return IntFieldSerializer.SER; ++ } ++ else if (long.class.equals(type)) { ++ return LongFieldSerializer.SER; ++ } ++ else if (double.class.equals(type) || ++ float.class.equals(type)) { ++ return DoubleFieldSerializer.SER; ++ } ++ else if (boolean.class.equals(type)) { ++ return BooleanFieldSerializer.SER; ++ } ++ else if (String.class.equals(type)) { ++ return StringFieldSerializer.SER; ++ } ++ else if (java.util.Date.class.equals(type) ++ || java.sql.Date.class.equals(type) ++ || java.sql.Timestamp.class.equals(type) ++ || java.sql.Time.class.equals(type)) { ++ return DateFieldSerializer.SER; ++ } ++ else ++ return FieldSerializer.SER; ++ } ++ ++ static class FieldSerializer { ++ static final FieldSerializer SER = new FieldSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Field field) ++ throws IOException ++ { ++ Object value = null; ++ ++ try { ++ value = field.get(obj); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ try { ++ out.writeObject(value); ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n field: " ++ + field.getDeclaringClass().getName() ++ + '.' + field.getName(), ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n field: " ++ + field.getDeclaringClass().getName() ++ + '.' + field.getName(), ++ e); ++ } ++ } ++ } ++ ++ static class BooleanFieldSerializer extends FieldSerializer { ++ static final FieldSerializer SER = new BooleanFieldSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Field field) ++ throws IOException ++ { ++ boolean value = false; ++ ++ try { ++ value = field.getBoolean(obj); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeBoolean(value); ++ } ++ } ++ ++ static class IntFieldSerializer extends FieldSerializer { ++ static final FieldSerializer SER = new IntFieldSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Field field) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = field.getInt(obj); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeInt(value); ++ } ++ } ++ ++ static class LongFieldSerializer extends FieldSerializer { ++ static final FieldSerializer SER = new LongFieldSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Field field) ++ throws IOException ++ { ++ long value = 0; ++ ++ try { ++ value = field.getLong(obj); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeLong(value); ++ } ++ } ++ ++ static class DoubleFieldSerializer extends FieldSerializer { ++ static final FieldSerializer SER = new DoubleFieldSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Field field) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = field.getDouble(obj); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ static class StringFieldSerializer extends FieldSerializer { ++ static final FieldSerializer SER = new StringFieldSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Field field) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = (String) field.get(obj); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ out.writeString(value); ++ } ++ } ++ ++ static class DateFieldSerializer extends FieldSerializer { ++ static final FieldSerializer SER = new DateFieldSerializer(); ++ ++ void serialize(AbstractHessianOutput out, Object obj, Field field) ++ throws IOException ++ { ++ java.util.Date value = null; ++ ++ try { ++ value = (java.util.Date) field.get(obj); ++ } catch (IllegalAccessException e) { ++ log.log(Level.FINE, e.toString(), e); ++ } ++ ++ if (value == null) ++ out.writeNull(); ++ else ++ out.writeUTCDate(value.getTime()); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/JavaUnsharedSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/JavaUnsharedSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/JavaUnsharedSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/JavaUnsharedSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,86 +1,86 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.ref.SoftReference; +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.ArrayList; +-import java.util.WeakHashMap; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-/** +- * Serializing an object for known object types. +- */ +-public class JavaUnsharedSerializer extends JavaSerializer +-{ +- private static final Logger log +- = Logger.getLogger(JavaUnsharedSerializer.class.getName()); +- +- public JavaUnsharedSerializer(Class cl) +- { +- super(cl); +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- boolean oldUnshared = out.setUnshared(true); +- +- try { +- super.writeObject(obj, out); +- } finally { +- out.setUnshared(oldUnshared); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.ref.SoftReference; ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.WeakHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class JavaUnsharedSerializer extends JavaSerializer ++{ ++ private static final Logger log ++ = Logger.getLogger(JavaUnsharedSerializer.class.getName()); ++ ++ public JavaUnsharedSerializer(Class cl) ++ { ++ super(cl); ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ boolean oldUnshared = out.setUnshared(true); ++ ++ try { ++ super.writeObject(obj, out); ++ } finally { ++ out.setUnshared(oldUnshared); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHandle.java +--- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHandle.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHandle.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,119 +1,119 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.Locale; +- +-/** +- * Handle for a locale object. +- */ +-public class LocaleHandle implements java.io.Serializable, HessianHandle { +- private String value; +- +- public LocaleHandle(String locale) +- { +- this.value = locale; +- } +- +- private Object readResolve() +- { +- String s = this.value; +- +- if (s == null) +- return null; +- +- int len = s.length(); +- char ch = ' '; +- +- int i = 0; +- for (; +- i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' +- || 'A' <= ch && ch <= 'Z' +- || '0' <= ch && ch <= '9'); +- i++) { +- } +- +- String language = s.substring(0, i); +- String country = null; +- String var = null; +- +- if (ch == '-' || ch == '_') { +- int head = ++i; +- +- for (; +- i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' +- || 'A' <= ch && ch <= 'Z' +- || '0' <= ch && ch <= '9'); +- i++) { +- } +- +- country = s.substring(head, i); +- } +- +- if (ch == '-' || ch == '_') { +- int head = ++i; +- +- for (; +- i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' +- || 'A' <= ch && ch <= 'Z' +- || '0' <= ch && ch <= '9'); +- i++) { +- } +- +- var = s.substring(head, i); +- } +- +- if (var != null) +- return new Locale(language, country, var); +- else if (country != null) +- return new Locale(language, country); +- else +- return new Locale(language); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.Locale; ++ ++/** ++ * Handle for a locale object. ++ */ ++public class LocaleHandle implements java.io.Serializable, HessianHandle { ++ private String value; ++ ++ public LocaleHandle(String locale) ++ { ++ this.value = locale; ++ } ++ ++ private Object readResolve() ++ { ++ String s = this.value; ++ ++ if (s == null) ++ return null; ++ ++ int len = s.length(); ++ char ch = ' '; ++ ++ int i = 0; ++ for (; ++ i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' ++ || 'A' <= ch && ch <= 'Z' ++ || '0' <= ch && ch <= '9'); ++ i++) { ++ } ++ ++ String language = s.substring(0, i); ++ String country = null; ++ String var = null; ++ ++ if (ch == '-' || ch == '_') { ++ int head = ++i; ++ ++ for (; ++ i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' ++ || 'A' <= ch && ch <= 'Z' ++ || '0' <= ch && ch <= '9'); ++ i++) { ++ } ++ ++ country = s.substring(head, i); ++ } ++ ++ if (ch == '-' || ch == '_') { ++ int head = ++i; ++ ++ for (; ++ i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' ++ || 'A' <= ch && ch <= 'Z' ++ || '0' <= ch && ch <= '9'); ++ i++) { ++ } ++ ++ var = s.substring(head, i); ++ } ++ ++ if (var != null) ++ return new Locale(language, country, var); ++ else if (country != null) ++ return new Locale(language, country); ++ else ++ return new Locale(language); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianDeserializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,85 @@ ++package com.caucho.hessian.io; ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import java.io.IOException; ++import java.util.Locale; ++ ++public class LocaleHessianDeserializer extends AbstractDeserializer { ++ ++ public Class getType() { ++ return Locale.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException { ++ int ref = in.addRef(null); ++ ++ String languageValue = null; ++ String countryValue = null; ++ String variantValue = null; ++ ++ while (!in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("language")) ++ languageValue = in.readString(); ++ else if (key.equals("country")) ++ countryValue = in.readString(); ++ else if (key.equals("variant")) ++ variantValue = in.readString(); ++ else ++ in.readString(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object value = getObject(languageValue, countryValue, variantValue); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, Object[] fields) throws IOException { ++ int ref = in.addRef(null); ++ ++ String languageValue = null; ++ String countryValue = null; ++ String variantValue = null; ++ ++ for (Object key : fields) { ++ if (key.equals("language")) ++ languageValue = in.readString(); ++ else if (key.equals("country")) ++ countryValue = in.readString(); ++ else if (key.equals("variant")) ++ variantValue = in.readString(); ++ else ++ in.readObject(); ++ ++ } ++ ++ Object value = getObject(languageValue, countryValue, variantValue); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ private Object getObject(String languageValue, String countryValue, String variantValue) { ++ Object value = null; ++ if (languageValue != null && countryValue != null && variantValue != null) { ++ value = new Locale(languageValue, countryValue, variantValue); ++ } else if (languageValue != null && countryValue != null) { ++ value = new Locale(languageValue, countryValue); ++ } else if (languageValue != null) { ++ value = new Locale(languageValue); ++ } else { ++ value = Locale.getDefault(); ++ } ++ return value; ++ } ++ ++} +\ No newline at end of file +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianSerializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,64 @@ ++package com.caucho.hessian.io; ++import com.caucho.hessian.io.AbstractHessianOutput; ++import com.caucho.hessian.io.AbstractSerializer; ++ ++import java.io.IOException; ++import java.util.Locale; ++ ++public class LocaleHessianSerializer extends AbstractSerializer ++{ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ ++ if (obj == null) ++ out.writeNull(); ++ else ++ { ++ Class cl = obj.getClass(); ++ ++ if (out.addRef(obj)) ++ return; ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ Locale loc = (Locale) obj; ++ ++ if (ref < -1) ++ { ++ if (loc.getLanguage() != null) ++ { ++ out.writeString("language"); ++ out.writeString(loc.getLanguage()); ++ } ++ if (loc.getCountry() != null) ++ { ++ out.writeString("country"); ++ out.writeString(loc.getCountry()); ++ } ++ if (loc.getVariant() != null) ++ { ++ out.writeString("variant"); ++ out.writeString(loc.getVariant()); ++ } ++ ++ out.writeMapEnd(); ++ } ++ else ++ { ++ if (ref == -1) ++ { ++ out.writeInt(3); ++ out.writeString("language"); ++ out.writeString("country"); ++ out.writeString("variant"); ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ out.writeString(loc.getLanguage()); ++ out.writeString(loc.getCountry()); ++ out.writeString(loc.getVariant()); ++ } ++ } ++ } ++} +\ No newline at end of file +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/LocaleSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,76 +1,76 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.Locale; +- +-/** +- * Serializing a locale. +- */ +-public class LocaleSerializer extends AbstractSerializer { +- private static LocaleSerializer SERIALIZER = new LocaleSerializer(); +- +- public static LocaleSerializer create() +- { +- return SERIALIZER; +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (obj == null) +- out.writeNull(); +- else { +- Locale locale = (Locale) obj; +- +- out.writeObject(new LocaleHandle(locale.toString())); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.Locale; ++ ++/** ++ * Serializing a locale. ++ */ ++public class LocaleSerializer extends AbstractSerializer { ++ private static LocaleSerializer SERIALIZER = new LocaleSerializer(); ++ ++ public static LocaleSerializer create() ++ { ++ return SERIALIZER; ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (obj == null) ++ out.writeNull(); ++ else { ++ Locale locale = (Locale) obj; ++ ++ out.writeObject(new LocaleHandle(locale.toString())); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/MapDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/MapDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/MapDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/MapDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,159 +1,159 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.*; +-import java.lang.reflect.*; +- +-/** +- * Deserializing a JDK 1.2 Map. +- */ +-public class MapDeserializer extends AbstractMapDeserializer { +- private Class _type; +- private Constructor _ctor; +- +- public MapDeserializer(Class type) +- { +- if (type == null) +- type = HashMap.class; +- +- _type = type; +- +- Constructor []ctors = type.getConstructors(); +- for (int i = 0; i < ctors.length; i++) { +- if (ctors[i].getParameterTypes().length == 0) +- _ctor = ctors[i]; +- } +- +- if (_ctor == null) { +- try { +- _ctor = HashMap.class.getConstructor(new Class[0]); +- } catch (Exception e) { +- throw new IllegalStateException(e); +- } +- } +- } +- +- public Class getType() +- { +- if (_type != null) +- return _type; +- else +- return HashMap.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- Map map; +- +- if (_type == null) +- map = new HashMap(); +- else if (_type.equals(Map.class)) +- map = new HashMap(); +- else if (_type.equals(SortedMap.class)) +- map = new TreeMap(); +- else { +- try { +- map = (Map) _ctor.newInstance(); +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- in.addRef(map); +- +- while (! in.isEnd()) { +- map.put(in.readObject(), in.readObject()); +- } +- +- in.readEnd(); +- +- return map; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException +- { +- String []fieldNames = (String []) fields; +- Map map = createMap(); +- +- int ref = in.addRef(map); +- +- for (int i = 0; i < fieldNames.length; i++) { +- String name = fieldNames[i]; +- +- map.put(name, in.readObject()); +- } +- +- return map; +- } +- +- private Map createMap() +- throws IOException +- { +- +- if (_type == null) +- return new HashMap(); +- else if (_type.equals(Map.class)) +- return new HashMap(); +- else if (_type.equals(SortedMap.class)) +- return new TreeMap(); +- else { +- try { +- return (Map) _ctor.newInstance(); +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.*; ++import java.lang.reflect.*; ++ ++/** ++ * Deserializing a JDK 1.2 Map. ++ */ ++public class MapDeserializer extends AbstractMapDeserializer { ++ private Class _type; ++ private Constructor _ctor; ++ ++ public MapDeserializer(Class type) ++ { ++ if (type == null) ++ type = HashMap.class; ++ ++ _type = type; ++ ++ Constructor []ctors = type.getConstructors(); ++ for (int i = 0; i < ctors.length; i++) { ++ if (ctors[i].getParameterTypes().length == 0) ++ _ctor = ctors[i]; ++ } ++ ++ if (_ctor == null) { ++ try { ++ _ctor = HashMap.class.getConstructor(new Class[0]); ++ } catch (Exception e) { ++ throw new IllegalStateException(e); ++ } ++ } ++ } ++ ++ public Class getType() ++ { ++ if (_type != null) ++ return _type; ++ else ++ return HashMap.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ Map map; ++ ++ if (_type == null) ++ map = new HashMap(); ++ else if (_type.equals(Map.class)) ++ map = new HashMap(); ++ else if (_type.equals(SortedMap.class)) ++ map = new TreeMap(); ++ else { ++ try { ++ map = (Map) _ctor.newInstance(); ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ in.addRef(map); ++ ++ while (! in.isEnd()) { ++ map.put(in.readObject(), in.readObject()); ++ } ++ ++ in.readEnd(); ++ ++ return map; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ String []fieldNames = (String []) fields; ++ Map map = createMap(); ++ ++ int ref = in.addRef(map); ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ String name = fieldNames[i]; ++ ++ map.put(name, in.readObject()); ++ } ++ ++ return map; ++ } ++ ++ private Map createMap() ++ throws IOException ++ { ++ ++ if (_type == null) ++ return new HashMap(); ++ else if (_type.equals(Map.class)) ++ return new HashMap(); ++ else if (_type.equals(SortedMap.class)) ++ return new TreeMap(); ++ else { ++ try { ++ return (Map) _ctor.newInstance(); ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/MapSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/MapSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/MapSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/MapSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,120 +1,120 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.HashMap; +-import java.util.Iterator; +-import java.util.Map; +- +-/** +- * Serializing a JDK 1.2 java.util.Map. +- */ +-public class MapSerializer extends AbstractSerializer { +- private boolean _isSendJavaType = true; +- +- /** +- * Set true if the java type of the collection should be sent. +- */ +- public void setSendJavaType(boolean sendJavaType) +- { +- _isSendJavaType = sendJavaType; +- } +- +- /** +- * Return true if the java type of the collection should be sent. +- */ +- public boolean getSendJavaType() +- { +- return _isSendJavaType; +- } +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) +- return; +- +- Map map = (Map) obj; +- +- Class cl = obj.getClass(); +- +- if (cl.equals(HashMap.class) +- || ! (obj instanceof java.io.Serializable)) +- out.writeMapBegin(null); +- else if (! _isSendJavaType) { +- // hessian/3a19 +- for (; cl != null; cl = cl.getSuperclass()) { +- if (cl.equals(HashMap.class)) { +- out.writeMapBegin(null); +- break; +- } +- else if (cl.getName().startsWith("java.")) { +- out.writeMapBegin(cl.getName()); +- break; +- } +- } +- +- if (cl == null) +- out.writeMapBegin(null); +- } +- else { +- out.writeMapBegin(cl.getName()); +- } +- +- Iterator iter = map.entrySet().iterator(); +- while (iter.hasNext()) { +- Map.Entry entry = (Map.Entry) iter.next(); +- +- out.writeObject(entry.getKey()); +- out.writeObject(entry.getValue()); +- } +- out.writeMapEnd(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.HashMap; ++import java.util.Iterator; ++import java.util.Map; ++ ++/** ++ * Serializing a JDK 1.2 java.util.Map. ++ */ ++public class MapSerializer extends AbstractSerializer { ++ private boolean _isSendJavaType = true; ++ ++ /** ++ * Set true if the java type of the collection should be sent. ++ */ ++ public void setSendJavaType(boolean sendJavaType) ++ { ++ _isSendJavaType = sendJavaType; ++ } ++ ++ /** ++ * Return true if the java type of the collection should be sent. ++ */ ++ public boolean getSendJavaType() ++ { ++ return _isSendJavaType; ++ } ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) ++ return; ++ ++ Map map = (Map) obj; ++ ++ Class cl = obj.getClass(); ++ ++ if (cl.equals(HashMap.class) ++ || ! (obj instanceof java.io.Serializable)) ++ out.writeMapBegin(null); ++ else if (! _isSendJavaType) { ++ // hessian/3a19 ++ for (; cl != null; cl = cl.getSuperclass()) { ++ if (cl.equals(HashMap.class)) { ++ out.writeMapBegin(null); ++ break; ++ } ++ else if (cl.getName().startsWith("java.")) { ++ out.writeMapBegin(cl.getName()); ++ break; ++ } ++ } ++ ++ if (cl == null) ++ out.writeMapBegin(null); ++ } ++ else { ++ out.writeMapBegin(cl.getName()); ++ } ++ ++ Iterator iter = map.entrySet().iterator(); ++ while (iter.hasNext()) { ++ Map.Entry entry = (Map.Entry) iter.next(); ++ ++ out.writeObject(entry.getKey()); ++ out.writeObject(entry.getValue()); ++ } ++ out.writeMapEnd(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,755 @@ ++/** ++ * ++ */ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Field; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.HashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import sun.misc.Unsafe; ++ ++/** ++ * @author l65882 ++ * ++ */ ++public class NonTransientUnsafeDeserializer extends AbstractMapDeserializer { ++ private static final Logger log ++ = Logger.getLogger(JavaDeserializer.class.getName()); ++ ++ private static boolean _isEnabled; ++ @SuppressWarnings("restriction") ++ private static Unsafe _unsafe; ++ ++ private Class _type; ++ private HashMap _fieldMap; ++ private Method _readResolve; ++ ++ public NonTransientUnsafeDeserializer(Class cl) ++ { ++ _type = cl; ++ _fieldMap = getFieldMap(cl); ++ ++ _readResolve = getReadResolve(cl); ++ ++ if (_readResolve != null) { ++ _readResolve.setAccessible(true); ++ } ++ } ++ ++ public static boolean isEnabled() ++ { ++ return _isEnabled; ++ } ++ ++ @Override ++ public Class getType() ++ { ++ return _type; ++ } ++ ++ @Override ++ public boolean isReadResolve() ++ { ++ return _readResolve != null; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readMap(in, obj); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object []createFields(int len) ++ { ++ return new FieldDeserializer[len]; ++ } ++ ++ public Object createField(String name) ++ { ++ Object reader = _fieldMap.get(name); ++ ++ if (reader == null) ++ reader = NullFieldDeserializer.DESER; ++ ++ return reader; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, (FieldDeserializer []) fields); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, fieldNames); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ /** ++ * Returns the readResolve method ++ */ ++ protected Method getReadResolve(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("readResolve") ++ && method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ public Object readMap(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ while (! in.isEnd()) { ++ Object key = in.readObject(); ++ ++ FieldDeserializer deser = (FieldDeserializer) _fieldMap.get(key); ++ ++ if (deser != null) ++ deser.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object obj, ++ FieldDeserializer []fields) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (FieldDeserializer reader : fields) { ++ reader.deserialize(in, obj); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object obj, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (String fieldName : fieldNames) { ++ FieldDeserializer reader = _fieldMap.get(fieldName); ++ ++ if (reader != null) ++ reader.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ protected Object resolve(AbstractHessianInput in, Object obj) ++ throws Exception ++ { ++ // if there's a readResolve method, call it ++ try { ++ if (_readResolve != null) ++ return _readResolve.invoke(obj, new Object[0]); ++ } catch (InvocationTargetException e) { ++ if (e.getCause() instanceof Exception) ++ throw (Exception) e.getCause(); ++ else ++ throw e; ++ } ++ ++ return obj; ++ } ++ ++ @SuppressWarnings("restriction") ++ protected Object instantiate() ++ throws Exception ++ { ++ return _unsafe.allocateInstance(_type); ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected HashMap getFieldMap(Class cl) ++ { ++ HashMap fieldMap ++ = new HashMap(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isStatic(field.getModifiers())) ++ continue; ++ else if (fieldMap.get(field.getName()) != null) ++ continue; ++ // XXX: could parameterize the handler to only deal with public ++ try { ++ field.setAccessible(true); ++ } catch (Throwable e) { ++ e.printStackTrace(); ++ } ++ ++ Class type = field.getType(); ++ FieldDeserializer deser; ++ ++ if (String.class.equals(type)) { ++ deser = new StringFieldDeserializer(field); ++ } ++ else if (byte.class.equals(type)) { ++ deser = new ByteFieldDeserializer(field); ++ } ++ else if (char.class.equals(type)) { ++ deser = new CharFieldDeserializer(field); ++ } ++ else if (short.class.equals(type)) { ++ deser = new ShortFieldDeserializer(field); ++ } ++ else if (int.class.equals(type)) { ++ deser = new IntFieldDeserializer(field); ++ } ++ else if (long.class.equals(type)) { ++ deser = new LongFieldDeserializer(field); ++ } ++ else if (float.class.equals(type)) { ++ deser = new FloatFieldDeserializer(field); ++ } ++ else if (double.class.equals(type)) { ++ deser = new DoubleFieldDeserializer(field); ++ } ++ else if (boolean.class.equals(type)) { ++ deser = new BooleanFieldDeserializer(field); ++ } ++ else if (java.sql.Date.class.equals(type)) { ++ deser = new SqlDateFieldDeserializer(field); ++ } ++ else if (java.sql.Timestamp.class.equals(type)) { ++ deser = new SqlTimestampFieldDeserializer(field); ++ } ++ else if (java.sql.Time.class.equals(type)) { ++ deser = new SqlTimeFieldDeserializer(field); ++ } ++ else { ++ deser = new ObjectFieldDeserializer(field); ++ } ++ ++ fieldMap.put(field.getName(), deser); ++ } ++ } ++ ++ return fieldMap; ++ } ++ ++ abstract static class FieldDeserializer { ++ abstract void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException; ++ } ++ ++ static class NullFieldDeserializer extends FieldDeserializer { ++ static NullFieldDeserializer DESER = new NullFieldDeserializer(); ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ in.readObject(); ++ } ++ } ++ ++ static class ObjectFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ObjectFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ Object value = null; ++ ++ try { ++ value = in.readObject(_field.getType()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class BooleanFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ BooleanFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ boolean value = false; ++ ++ try { ++ value = in.readBoolean(); ++ ++ _unsafe.putBoolean(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ByteFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ByteFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putByte(obj, _offset, (byte) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class CharFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ CharFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = in.readString(); ++ ++ char ch; ++ ++ if (value != null && value.length() > 0) ++ ch = value.charAt(0); ++ else ++ ch = 0; ++ ++ _unsafe.putChar(obj, _offset, ch); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ShortFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ShortFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putShort(obj, _offset, (short) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class IntFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ IntFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putInt(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class LongFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ LongFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ long value = 0; ++ ++ try { ++ value = in.readLong(); ++ ++ _unsafe.putLong(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class FloatFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ FloatFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _unsafe.putFloat(obj, _offset, (float) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class DoubleFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DoubleFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _unsafe.putDouble(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class StringFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ StringFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = in.readString(); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlDateFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlDateFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Date value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ value = new java.sql.Date(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimestampFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlTimestampFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Timestamp value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ value = new java.sql.Timestamp(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimeFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlTimeFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Time value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ value = new java.sql.Time(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static void logDeserializeError(Field field, Object obj, Object value, ++ Throwable e) ++ throws IOException ++ { ++ String fieldName = (field.getDeclaringClass().getName() ++ + "." + field.getName()); ++ ++ if (e instanceof HessianFieldException) ++ throw (HessianFieldException) e; ++ else if (e instanceof IOException) ++ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); ++ ++ if (value != null) ++ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" ++ + " cannot be assigned to '" + field.getType().getName() + "'", e); ++ else ++ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); ++ } ++ ++ static { ++ boolean isEnabled = false; ++ ++ try { ++ Class unsafe = Class.forName("sun.misc.Unsafe"); ++ Field theUnsafe = null; ++ for (Field field : unsafe.getDeclaredFields()) { ++ if (field.getName().equals("theUnsafe")) ++ theUnsafe = field; ++ } ++ ++ if (theUnsafe != null) { ++ theUnsafe.setAccessible(true); ++ _unsafe = (Unsafe) theUnsafe.get(null); ++ } ++ ++ isEnabled = _unsafe != null; ++ ++ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); ++ ++ if ("false".equals(unsafeProp)) ++ isEnabled = false; ++ } catch (Throwable e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _isEnabled = isEnabled; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeSerializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,518 @@ ++/** ++ * ++ */ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.ref.SoftReference; ++import java.lang.reflect.Field; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.WeakHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import sun.misc.Unsafe; ++ ++ ++ ++/** ++ * @author l65882 ++ * ++ */ ++public class NonTransientUnsafeSerializer extends AbstractSerializer { ++ ++ private static final Logger log ++ = Logger.getLogger(NonTransientUnsafeSerializer.class.getName()); ++ ++ private static boolean _isEnabled; ++ private static Unsafe _unsafe; ++ ++ private static final WeakHashMap,SoftReference> _serializerMap ++ = new WeakHashMap,SoftReference>(); ++ ++ private static Object []NULL_ARGS = new Object[0]; ++ ++ private Field []_fields; ++ private FieldSerializer []_fieldSerializers; ++ ++ public static boolean isEnabled() ++ { ++ return _isEnabled; ++ } ++ ++ public NonTransientUnsafeSerializer(Class cl) ++ { ++ introspect(cl); ++ } ++ ++ public static NonTransientUnsafeSerializer create(Class cl) ++ { ++ ClassLoader loader = cl.getClassLoader(); ++ ++ synchronized (_serializerMap) { ++ SoftReference baseRef ++ = _serializerMap.get(cl); ++ ++ NonTransientUnsafeSerializer base = baseRef != null ? baseRef.get() : null; ++ ++ if (base == null) { ++ base = new NonTransientUnsafeSerializer(cl); ++ baseRef = new SoftReference(base); ++ _serializerMap.put(cl, baseRef); ++ } ++ ++ return base; ++ } ++ } ++ ++ protected void introspect(Class cl) ++ { ++ ArrayList primitiveFields = new ArrayList(); ++ ArrayList compoundFields = new ArrayList(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isStatic(field.getModifiers())) ++ continue; ++ ++ // XXX: could parameterize the handler to only deal with public ++ field.setAccessible(true); ++ ++ if (field.getType().isPrimitive() ++ || (field.getType().getName().startsWith("java.lang.") ++ && ! field.getType().equals(Object.class))) ++ primitiveFields.add(field); ++ else ++ compoundFields.add(field); ++ } ++ } ++ ++ ArrayList fields = new ArrayList(); ++ fields.addAll(primitiveFields); ++ fields.addAll(compoundFields); ++ ++ _fields = new Field[fields.size()]; ++ fields.toArray(_fields); ++ ++ _fieldSerializers = new FieldSerializer[_fields.length]; ++ ++ for (int i = 0; i < _fields.length; i++) { ++ _fieldSerializers[i] = getFieldSerializer(_fields[i]); ++ } ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) { ++ return; ++ } ++ ++ Class cl = obj.getClass(); ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref >= 0) { ++ writeInstance(obj, out); ++ } ++ else if (ref == -1) { ++ writeDefinition20(out); ++ out.writeObjectBegin(cl.getName()); ++ writeInstance(obj, out); ++ } ++ else { ++ writeObject10(obj, out); ++ } ++ } ++ ++ protected void writeObject10(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ ++ _fieldSerializers[i].serialize(out, obj); ++ } ++ ++ out.writeMapEnd(); ++ } ++ ++ private void writeDefinition20(AbstractHessianOutput out) ++ throws IOException ++ { ++ out.writeClassFieldLength(_fields.length); ++ ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ } ++ } ++ ++ final public void writeInstance(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ try { ++ FieldSerializer []fieldSerializers = _fieldSerializers; ++ int length = fieldSerializers.length; ++ ++ for (int i = 0; i < length; i++) { ++ fieldSerializers[i].serialize(out, obj); ++ } ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } ++ } ++ ++ private static FieldSerializer getFieldSerializer(Field field) ++ { ++ Class type = field.getType(); ++ ++ if (boolean.class.equals(type)) { ++ return new BooleanFieldSerializer(field); ++ } ++ else if (byte.class.equals(type)) { ++ return new ByteFieldSerializer(field); ++ } ++ else if (char.class.equals(type)) { ++ return new CharFieldSerializer(field); ++ } ++ else if (short.class.equals(type)) { ++ return new ShortFieldSerializer(field); ++ } ++ else if (int.class.equals(type)) { ++ return new IntFieldSerializer(field); ++ } ++ else if (long.class.equals(type)) { ++ return new LongFieldSerializer(field); ++ } ++ else if (double.class.equals(type)) { ++ return new DoubleFieldSerializer(field); ++ } ++ else if (float.class.equals(type)) { ++ return new FloatFieldSerializer(field); ++ } ++ else if (String.class.equals(type)) { ++ return new StringFieldSerializer(field); ++ } ++ else if (java.util.Date.class.equals(type) ++ || java.sql.Date.class.equals(type) ++ || java.sql.Timestamp.class.equals(type) ++ || java.sql.Time.class.equals(type)) { ++ return new DateFieldSerializer(field); ++ } ++ else ++ return new ObjectFieldSerializer(field); ++ } ++ ++ abstract static class FieldSerializer { ++ abstract void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException; ++ } ++ ++ final static class ObjectFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ObjectFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ try { ++ Object value = _unsafe.getObject(obj, _offset); ++ ++ out.writeObject(value); ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n field: " ++ + _field.getDeclaringClass().getName() ++ + '.' + _field.getName(), ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n field: " ++ + _field.getDeclaringClass().getName() ++ + '.' + _field.getName(), ++ e); ++ } ++ } ++ } ++ ++ final static class BooleanFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ BooleanFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ boolean value = _unsafe.getBoolean(obj, _offset); ++ ++ out.writeBoolean(value); ++ } ++ } ++ ++ final static class ByteFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ByteFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getByte(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class CharFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ CharFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ char value = _unsafe.getChar(obj, _offset); ++ ++ out.writeString(String.valueOf(value)); ++ } ++ } ++ ++ final static class ShortFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ShortFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getShort(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class IntFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ IntFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getInt(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class LongFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ LongFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ long value = _unsafe.getLong(obj, _offset); ++ ++ out.writeLong(value); ++ } ++ } ++ ++ final static class FloatFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ FloatFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ double value = _unsafe.getFloat(obj, _offset); ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ final static class DoubleFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DoubleFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ double value = _unsafe.getDouble(obj, _offset); ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ final static class StringFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ StringFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ String value = (String) _unsafe.getObject(obj, _offset); ++ ++ out.writeString(value); ++ } ++ } ++ ++ final static class DateFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DateFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ java.util.Date value ++ = (java.util.Date) _unsafe.getObject(obj, _offset); ++ ++ if (value == null) ++ out.writeNull(); ++ else ++ out.writeUTCDate(value.getTime()); ++ } ++ } ++ ++ static { ++ boolean isEnabled = false; ++ ++ try { ++ Class unsafe = Class.forName("sun.misc.Unsafe"); ++ Field theUnsafe = null; ++ for (Field field : unsafe.getDeclaredFields()) { ++ if (field.getName().equals("theUnsafe")) ++ theUnsafe = field; ++ } ++ ++ if (theUnsafe != null) { ++ theUnsafe.setAccessible(true); ++ _unsafe = (Unsafe) theUnsafe.get(null); ++ } ++ ++ isEnabled = _unsafe != null; ++ ++ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); ++ ++ if ("false".equals(unsafeProp)) ++ isEnabled = false; ++ } catch (Throwable e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _isEnabled = isEnabled; ++ } ++ ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ObjectDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,102 +1,102 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing an object for known object types. +- */ +-public class ObjectDeserializer extends AbstractDeserializer { +- private Class _cl; +- +- public ObjectDeserializer(Class cl) +- { +- _cl = cl; +- } +- +- public Class getType() +- { +- return _cl; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in) +- throws IOException +- { +- return in.readObject(); +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, Object []fields) +- throws IOException +- { +- throw new UnsupportedOperationException(String.valueOf(this)); +- } +- +- @Override +- public Object readList(AbstractHessianInput in, int length) +- throws IOException +- { +- throw new UnsupportedOperationException(String.valueOf(this)); +- } +- +- @Override +- public Object readLengthList(AbstractHessianInput in, int length) +- throws IOException +- { +- throw new UnsupportedOperationException(String.valueOf(this)); +- } +- +- @Override +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _cl + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class ObjectDeserializer extends AbstractDeserializer { ++ private Class _cl; ++ ++ public ObjectDeserializer(Class cl) ++ { ++ _cl = cl; ++ } ++ ++ public Class getType() ++ { ++ return _cl; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in) ++ throws IOException ++ { ++ return in.readObject(); ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, Object []fields) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(String.valueOf(this)); ++ } ++ ++ @Override ++ public Object readList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(String.valueOf(this)); ++ } ++ ++ @Override ++ public Object readLengthList(AbstractHessianInput in, int length) ++ throws IOException ++ { ++ throw new UnsupportedOperationException(String.valueOf(this)); ++ } ++ ++ @Override ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _cl + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectHandleSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectHandleSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ObjectHandleSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectHandleSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,81 +1,81 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing a remote object. +- */ +-public class ObjectHandleSerializer extends AbstractSerializer { +- public static final Serializer SER = new ObjectHandleSerializer(); +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (obj == null) +- out.writeNull(); +- else { +- if (out.addRef(obj)) +- return; +- +- int ref = out.writeObjectBegin("object"); +- +- if (ref < -1) { +- out.writeMapEnd(); +- } +- else { +- if (ref == -1) { +- out.writeInt(0); +- out.writeObjectBegin("object"); +- } +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing a remote object. ++ */ ++public class ObjectHandleSerializer extends AbstractSerializer { ++ public static final Serializer SER = new ObjectHandleSerializer(); ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (obj == null) ++ out.writeNull(); ++ else { ++ if (out.addRef(obj)) ++ return; ++ ++ int ref = out.writeObjectBegin("object"); ++ ++ if (ref < -1) { ++ out.writeMapEnd(); ++ } ++ else { ++ if (ref == -1) { ++ out.writeInt(0); ++ out.writeObjectBegin("object"); ++ } ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectNameDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectNameDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ObjectNameDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectNameDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,76 +1,76 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import javax.management.ObjectName; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Deserializing an ObjectName +- */ +-public class ObjectNameDeserializer extends AbstractStringValueDeserializer { +- @Override +- public Class getType() +- { +- return ObjectName.class; +- } +- +- @Override +- protected Object create(String value) +- { +- try { +- return new ObjectName(value); +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new HessianException(e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import javax.management.ObjectName; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Deserializing an ObjectName ++ */ ++public class ObjectNameDeserializer extends AbstractStringValueDeserializer { ++ @Override ++ public Class getType() ++ { ++ return ObjectName.class; ++ } ++ ++ @Override ++ protected Object create(String value) ++ { ++ try { ++ return new ObjectName(value); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new HessianException(e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ObjectSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,58 +1,58 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing an object. +- */ +-public interface ObjectSerializer { +- public Serializer getObjectSerializer(); +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing an object. ++ */ ++public interface ObjectSerializer { ++ public Serializer getObjectSerializer(); ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/RemoteDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/RemoteDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/RemoteDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/RemoteDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,88 +1,88 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.util.logging.Logger; +- +-/** +- * Serializing an object for known object types. +- */ +-public class RemoteDeserializer extends JavaDeserializer { +- private static final Logger log +- = Logger.getLogger(RemoteDeserializer.class.getName()); +- +- public static final Deserializer DESER = new RemoteDeserializer(); +- +- public RemoteDeserializer() +- { +- super(HessianRemote.class, FieldDeserializer2Factory.create()); +- } +- +- @Override +- public boolean isReadResolve() +- { +- return true; +- } +- +- @Override +- protected Object resolve(AbstractHessianInput in, Object obj) +- throws Exception +- { +- HessianRemote remote = (HessianRemote) obj; +- HessianRemoteResolver resolver = in.getRemoteResolver(); +- +- if (resolver != null) { +- Object proxy = resolver.lookup(remote.getType(), remote.getURL()); +- +- return proxy; +- } +- else +- return remote; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.util.logging.Logger; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class RemoteDeserializer extends JavaDeserializer { ++ private static final Logger log ++ = Logger.getLogger(RemoteDeserializer.class.getName()); ++ ++ public static final Deserializer DESER = new RemoteDeserializer(); ++ ++ public RemoteDeserializer() ++ { ++ super(HessianRemote.class, FieldDeserializer2Factory.create()); ++ } ++ ++ @Override ++ public boolean isReadResolve() ++ { ++ return true; ++ } ++ ++ @Override ++ protected Object resolve(AbstractHessianInput in, Object obj) ++ throws Exception ++ { ++ HessianRemote remote = (HessianRemote) obj; ++ HessianRemoteResolver resolver = in.getRemoteResolver(); ++ ++ if (resolver != null) { ++ Object proxy = resolver.lookup(remote.getType(), remote.getURL()); ++ ++ return proxy; ++ } ++ else ++ return remote; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/RemoteSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/RemoteSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/RemoteSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/RemoteSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,67 +1,67 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import com.caucho.burlap.io.BurlapRemoteObject; +- +-import java.io.IOException; +- +-/** +- * Serializing a remote object. +- */ +-public class RemoteSerializer extends AbstractSerializer { +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- HessianRemoteObject remoteObject = (HessianRemoteObject) obj; +- +- out.writeObject(new HessianRemote(remoteObject.getHessianType(), +- remoteObject.getHessianURL())); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import com.caucho.burlap.io.BurlapRemoteObject; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing a remote object. ++ */ ++public class RemoteSerializer extends AbstractSerializer { ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ HessianRemoteObject remoteObject = (HessianRemoteObject) obj; ++ ++ out.writeObject(new HessianRemote(remoteObject.getHessianType(), ++ remoteObject.getHessianURL())); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Serializer.java hessian-4.0.65-fix/com/caucho/hessian/io/Serializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/Serializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/Serializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,59 +1,59 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing an object. +- */ +-public interface Serializer { +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing an object. ++ */ ++public interface Serializer { ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/SerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/SerializerFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/io/SerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/SerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,804 +1,810 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.Serializable; +-import java.lang.annotation.Annotation; +-import java.lang.ref.SoftReference; +-import java.lang.ref.WeakReference; +-import java.net.InetAddress; +-import java.util.ArrayList; +-import java.util.Calendar; +-import java.util.Collection; +-import java.util.Enumeration; +-import java.util.HashMap; +-import java.util.Iterator; +-import java.util.Map; +-import java.util.WeakHashMap; +-import java.util.concurrent.ConcurrentHashMap; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import com.caucho.burlap.io.BurlapRemoteObject; +- +-/** +- * Factory for returning serialization methods. +- */ +-public class SerializerFactory extends AbstractSerializerFactory +-{ +- private static final Logger log +- = Logger.getLogger(SerializerFactory.class.getName()); +- +- private static final Deserializer OBJECT_DESERIALIZER +- = new BasicDeserializer(BasicDeserializer.OBJECT); +- +- private static final ClassLoader _systemClassLoader; +- +- private static final HashMap _staticTypeMap; +- +- private static final +- WeakHashMap> +- _defaultFactoryRefMap +- = new WeakHashMap>(); +- +- private ContextSerializerFactory _contextFactory; +- private WeakReference _loaderRef; +- +- protected Serializer _defaultSerializer; +- +- // Additional factories +- protected ArrayList _factories = new ArrayList(); +- +- protected CollectionSerializer _collectionSerializer; +- protected MapSerializer _mapSerializer; +- +- private Deserializer _hashMapDeserializer; +- private Deserializer _arrayListDeserializer; +- private Map _cachedSerializerMap; +- private Map _cachedDeserializerMap; +- private HashMap _cachedTypeDeserializerMap; +- +- private boolean _isAllowNonSerializable; +- private boolean _isEnableUnsafeSerializer +- = (UnsafeSerializer.isEnabled() +- && UnsafeDeserializer.isEnabled()); +- +- private FieldDeserializer2Factory _fieldDeserializerFactory; +- +- private ClassFactory _classFactory; +- +- public SerializerFactory() +- { +- this(Thread.currentThread().getContextClassLoader()); +- } +- +- public SerializerFactory(ClassLoader loader) +- { +- _loaderRef = new WeakReference(loader); +- +- _contextFactory = ContextSerializerFactory.create(loader); +- +- if (_isEnableUnsafeSerializer) { +- _fieldDeserializerFactory = new FieldDeserializer2FactoryUnsafe(); +- } +- else { +- _fieldDeserializerFactory = new FieldDeserializer2Factory(); +- } +- } +- +- public static SerializerFactory createDefault() +- { +- ClassLoader loader = Thread.currentThread().getContextClassLoader(); +- +- synchronized (_defaultFactoryRefMap) { +- SoftReference factoryRef +- = _defaultFactoryRefMap.get(loader); +- +- SerializerFactory factory = null; +- +- if (factoryRef != null) +- factory = factoryRef.get(); +- +- if (factory == null) { +- factory = new SerializerFactory(); +- +- factoryRef = new SoftReference(factory); +- +- _defaultFactoryRefMap.put(loader, factoryRef); +- } +- +- return factory; +- } +- } +- +- public ClassLoader getClassLoader() +- { +- return _loaderRef.get(); +- } +- +- /** +- * Set true if the collection serializer should send the java type. +- */ +- public void setSendCollectionType(boolean isSendType) +- { +- if (_collectionSerializer == null) +- _collectionSerializer = new CollectionSerializer(); +- +- _collectionSerializer.setSendJavaType(isSendType); +- +- if (_mapSerializer == null) +- _mapSerializer = new MapSerializer(); +- +- _mapSerializer.setSendJavaType(isSendType); +- } +- +- /** +- * Adds a factory. +- */ +- public void addFactory(AbstractSerializerFactory factory) +- { +- _factories.add(factory); +- } +- +- /** +- * If true, non-serializable objects are allowed. +- */ +- public void setAllowNonSerializable(boolean allow) +- { +- _isAllowNonSerializable = allow; +- } +- +- /** +- * If true, non-serializable objects are allowed. +- */ +- public boolean isAllowNonSerializable() +- { +- return _isAllowNonSerializable; +- } +- +- /** +- * Returns the serializer for a class. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- public Serializer getObjectSerializer(Class cl) +- throws HessianProtocolException +- { +- Serializer serializer = getSerializer(cl); +- +- if (serializer instanceof ObjectSerializer) +- return ((ObjectSerializer) serializer).getObjectSerializer(); +- else +- return serializer; +- } +- +- public Class loadSerializedClass(String className) +- throws ClassNotFoundException +- { +- return getClassFactory().load(className); +- } +- +- public ClassFactory getClassFactory() +- { +- synchronized (this) { +- if (_classFactory == null) { +- _classFactory = new ClassFactory(getClassLoader()); +- } +- +- return _classFactory; +- } +- } +- +- public FieldDeserializer2Factory getFieldDeserializerFactory() +- { +- return _fieldDeserializerFactory; +- } +- +- /** +- * Returns the serializer for a class. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- public Serializer getSerializer(Class cl) +- throws HessianProtocolException +- { +- Serializer serializer; +- +- if (_cachedSerializerMap != null) { +- serializer = (Serializer) _cachedSerializerMap.get(cl); +- +- if (serializer != null) { +- return serializer; +- } +- } +- +- serializer = loadSerializer(cl); +- +- if (_cachedSerializerMap == null) +- _cachedSerializerMap = new ConcurrentHashMap(8); +- +- _cachedSerializerMap.put(cl, serializer); +- +- return serializer; +- } +- +- protected Serializer loadSerializer(Class cl) +- throws HessianProtocolException +- { +- Serializer serializer = null; +- +- for (int i = 0; +- _factories != null && i < _factories.size(); +- i++) { +- AbstractSerializerFactory factory; +- +- factory = (AbstractSerializerFactory) _factories.get(i); +- +- serializer = factory.getSerializer(cl); +- +- if (serializer != null) +- return serializer; +- } +- +- serializer = _contextFactory.getSerializer(cl.getName()); +- +- if (serializer != null) +- return serializer; +- +- ClassLoader loader = cl.getClassLoader(); +- +- if (loader == null) +- loader = _systemClassLoader; +- +- ContextSerializerFactory factory = null; +- +- factory = ContextSerializerFactory.create(loader); +- +- serializer = factory.getCustomSerializer(cl); +- +- if (serializer != null) { +- return serializer; +- } +- +- if (HessianRemoteObject.class.isAssignableFrom(cl)) { +- return new RemoteSerializer(); +- } +- else if (BurlapRemoteObject.class.isAssignableFrom(cl)) { +- return new RemoteSerializer(); +- } +- else if (InetAddress.class.isAssignableFrom(cl)) { +- return InetAddressSerializer.create(); +- } +- else if (JavaSerializer.getWriteReplace(cl) != null) { +- Serializer baseSerializer = getDefaultSerializer(cl); +- +- return new WriteReplaceSerializer(cl, getClassLoader(), baseSerializer); +- } +- else if (Map.class.isAssignableFrom(cl)) { +- if (_mapSerializer == null) +- _mapSerializer = new MapSerializer(); +- +- return _mapSerializer; +- } +- else if (Collection.class.isAssignableFrom(cl)) { +- if (_collectionSerializer == null) { +- _collectionSerializer = new CollectionSerializer(); +- } +- +- return _collectionSerializer; +- } +- +- else if (cl.isArray()) { +- return new ArraySerializer(); +- } +- +- else if (Throwable.class.isAssignableFrom(cl)) +- return new ThrowableSerializer(getDefaultSerializer(cl)); +- +- else if (InputStream.class.isAssignableFrom(cl)) +- return new InputStreamSerializer(); +- +- else if (Iterator.class.isAssignableFrom(cl)) +- return IteratorSerializer.create(); +- +- else if (Calendar.class.isAssignableFrom(cl)) +- return CalendarSerializer.SER; +- +- else if (Enumeration.class.isAssignableFrom(cl)) +- return EnumerationSerializer.create(); +- +- else if (Enum.class.isAssignableFrom(cl)) +- return new EnumSerializer(cl); +- +- else if (Annotation.class.isAssignableFrom(cl)) +- return new AnnotationSerializer(cl); +- +- return getDefaultSerializer(cl); +- } +- +- /** +- * Returns the default serializer for a class that isn't matched +- * directly. Application can override this method to produce +- * bean-style serialization instead of field serialization. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- protected Serializer getDefaultSerializer(Class cl) +- { +- if (_defaultSerializer != null) +- return _defaultSerializer; +- +- if (! Serializable.class.isAssignableFrom(cl) +- && ! _isAllowNonSerializable) { +- throw new IllegalStateException("Serialized class " + cl.getName() + " must implement java.io.Serializable"); +- } +- +- if (_isEnableUnsafeSerializer +- && JavaSerializer.getWriteReplace(cl) == null) { +- return UnsafeSerializer.create(cl); +- } +- else +- return JavaSerializer.create(cl); +- } +- +- /** +- * Returns the deserializer for a class. +- * +- * @param cl the class of the object that needs to be deserialized. +- * +- * @return a deserializer object for the serialization. +- */ +- public Deserializer getDeserializer(Class cl) +- throws HessianProtocolException +- { +- Deserializer deserializer; +- +- if (_cachedDeserializerMap != null) { +- deserializer = (Deserializer) _cachedDeserializerMap.get(cl); +- +- if (deserializer != null) +- return deserializer; +- } +- +- deserializer = loadDeserializer(cl); +- +- if (_cachedDeserializerMap == null) +- _cachedDeserializerMap = new ConcurrentHashMap(8); +- +- _cachedDeserializerMap.put(cl, deserializer); +- +- return deserializer; +- } +- +- protected Deserializer loadDeserializer(Class cl) +- throws HessianProtocolException +- { +- Deserializer deserializer = null; +- +- for (int i = 0; +- deserializer == null && _factories != null && i < _factories.size(); +- i++) { +- AbstractSerializerFactory factory; +- factory = (AbstractSerializerFactory) _factories.get(i); +- +- deserializer = factory.getDeserializer(cl); +- } +- +- if (deserializer != null) +- return deserializer; +- +- // XXX: need test +- deserializer = _contextFactory.getDeserializer(cl.getName()); +- +- if (deserializer != null) +- return deserializer; +- +- ContextSerializerFactory factory = null; +- +- if (cl.getClassLoader() != null) +- factory = ContextSerializerFactory.create(cl.getClassLoader()); +- else +- factory = ContextSerializerFactory.create(_systemClassLoader); +- +- deserializer = factory.getDeserializer(cl.getName()); +- +- if (deserializer != null) +- return deserializer; +- +- deserializer = factory.getCustomDeserializer(cl); +- +- if (deserializer != null) +- return deserializer; +- +- if (Collection.class.isAssignableFrom(cl)) +- deserializer = new CollectionDeserializer(cl); +- +- else if (Map.class.isAssignableFrom(cl)) { +- deserializer = new MapDeserializer(cl); +- } +- else if (Iterator.class.isAssignableFrom(cl)) { +- deserializer = IteratorDeserializer.create(); +- } +- else if (Annotation.class.isAssignableFrom(cl)) { +- deserializer = new AnnotationDeserializer(cl); +- } +- else if (cl.isInterface()) { +- deserializer = new ObjectDeserializer(cl); +- } +- else if (cl.isArray()) { +- deserializer = new ArrayDeserializer(cl.getComponentType()); +- } +- else if (Enumeration.class.isAssignableFrom(cl)) { +- deserializer = EnumerationDeserializer.create(); +- } +- else if (Enum.class.isAssignableFrom(cl)) +- deserializer = new EnumDeserializer(cl); +- +- else if (Class.class.equals(cl)) +- deserializer = new ClassDeserializer(getClassLoader()); +- +- else +- deserializer = getDefaultDeserializer(cl); +- +- return deserializer; +- } +- +- /** +- * Returns a custom serializer the class +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- protected Deserializer getCustomDeserializer(Class cl) +- { +- try { +- Class serClass = Class.forName(cl.getName() + "HessianDeserializer", +- false, cl.getClassLoader()); +- +- Deserializer ser = (Deserializer) serClass.newInstance(); +- +- return ser; +- } catch (ClassNotFoundException e) { +- log.log(Level.FINEST, e.toString(), e); +- +- return null; +- } catch (Exception e) { +- log.log(Level.FINE, e.toString(), e); +- +- return null; +- } +- } +- +- /** +- * Returns the default serializer for a class that isn't matched +- * directly. Application can override this method to produce +- * bean-style serialization instead of field serialization. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- protected Deserializer getDefaultDeserializer(Class cl) +- { +- if (InputStream.class.equals(cl)) +- return InputStreamDeserializer.DESER; +- +- if (_isEnableUnsafeSerializer) { +- return new UnsafeDeserializer(cl, _fieldDeserializerFactory); +- } +- else +- return new JavaDeserializer(cl, _fieldDeserializerFactory); +- } +- +- /** +- * Reads the object as a list. +- */ +- public Object readList(AbstractHessianInput in, int length, String type) +- throws HessianProtocolException, IOException +- { +- Deserializer deserializer = getDeserializer(type); +- +- if (deserializer != null) +- return deserializer.readList(in, length); +- else +- return new CollectionDeserializer(ArrayList.class).readList(in, length); +- } +- +- /** +- * Reads the object as a map. +- */ +- public Object readMap(AbstractHessianInput in, String type) +- throws HessianProtocolException, IOException +- { +- Deserializer deserializer = getDeserializer(type); +- +- if (deserializer != null) +- return deserializer.readMap(in); +- else if (_hashMapDeserializer != null) +- return _hashMapDeserializer.readMap(in); +- else { +- _hashMapDeserializer = new MapDeserializer(HashMap.class); +- +- return _hashMapDeserializer.readMap(in); +- } +- } +- +- /** +- * Reads the object as a map. +- */ +- public Object readObject(AbstractHessianInput in, +- String type, +- String []fieldNames) +- throws HessianProtocolException, IOException +- { +- Deserializer deserializer = getDeserializer(type); +- +- if (deserializer != null) +- return deserializer.readObject(in, fieldNames); +- else if (_hashMapDeserializer != null) +- return _hashMapDeserializer.readObject(in, fieldNames); +- else { +- _hashMapDeserializer = new MapDeserializer(HashMap.class); +- +- return _hashMapDeserializer.readObject(in, fieldNames); +- } +- } +- +- /** +- * Reads the object as a map. +- */ +- public Deserializer getObjectDeserializer(String type, Class cl) +- throws HessianProtocolException +- { +- Deserializer reader = getObjectDeserializer(type); +- +- if (cl == null +- || cl.equals(reader.getType()) +- || cl.isAssignableFrom(reader.getType()) +- || reader.isReadResolve() +- || HessianHandle.class.isAssignableFrom(reader.getType())) { +- return reader; +- } +- +- if (log.isLoggable(Level.FINE)) { +- log.fine("hessian: expected deserializer '" + cl.getName() + "' at '" + type + "' (" +- + reader.getType().getName() + ")"); +- } +- +- return getDeserializer(cl); +- } +- +- /** +- * Reads the object as a map. +- */ +- public Deserializer getObjectDeserializer(String type) +- throws HessianProtocolException +- { +- Deserializer deserializer = getDeserializer(type); +- +- if (deserializer != null) +- return deserializer; +- else if (_hashMapDeserializer != null) +- return _hashMapDeserializer; +- else { +- _hashMapDeserializer = new MapDeserializer(HashMap.class); +- +- return _hashMapDeserializer; +- } +- } +- +- /** +- * Reads the object as a map. +- */ +- public Deserializer getListDeserializer(String type, Class cl) +- throws HessianProtocolException +- { +- Deserializer reader = getListDeserializer(type); +- +- if (cl == null +- || cl.equals(reader.getType()) +- || cl.isAssignableFrom(reader.getType())) { +- return reader; +- } +- +- if (log.isLoggable(Level.FINE)) { +- log.fine("hessian: expected '" + cl.getName() + "' at '" + type + "' (" +- + reader.getType().getName() + ")"); +- } +- +- return getDeserializer(cl); +- } +- +- /** +- * Reads the object as a map. +- */ +- public Deserializer getListDeserializer(String type) +- throws HessianProtocolException +- { +- Deserializer deserializer = getDeserializer(type); +- +- if (deserializer != null) +- return deserializer; +- else if (_arrayListDeserializer != null) +- return _arrayListDeserializer; +- else { +- _arrayListDeserializer = new CollectionDeserializer(ArrayList.class); +- +- return _arrayListDeserializer; +- } +- } +- +- /** +- * Returns a deserializer based on a string type. +- */ +- public Deserializer getDeserializer(String type) +- throws HessianProtocolException +- { +- if (type == null || type.equals("")) +- return null; +- +- Deserializer deserializer; +- +- if (_cachedTypeDeserializerMap != null) { +- synchronized (_cachedTypeDeserializerMap) { +- deserializer = (Deserializer) _cachedTypeDeserializerMap.get(type); +- } +- +- if (deserializer != null) +- return deserializer; +- } +- +- +- deserializer = (Deserializer) _staticTypeMap.get(type); +- if (deserializer != null) +- return deserializer; +- +- if (type.startsWith("[")) { +- Deserializer subDeserializer = getDeserializer(type.substring(1)); +- +- if (subDeserializer != null) +- deserializer = new ArrayDeserializer(subDeserializer.getType()); +- else +- deserializer = new ArrayDeserializer(Object.class); +- } +- else { +- try { +- //Class cl = Class.forName(type, false, getClassLoader()); +- +- Class cl = loadSerializedClass(type); +- +- deserializer = getDeserializer(cl); +- } catch (Exception e) { +- log.warning("Hessian/Burlap: '" + type + "' is an unknown class in " + getClassLoader() + ":\n" + e); +- +- log.log(Level.FINER, e.toString(), e); +- } +- } +- +- if (deserializer != null) { +- if (_cachedTypeDeserializerMap == null) +- _cachedTypeDeserializerMap = new HashMap(8); +- +- synchronized (_cachedTypeDeserializerMap) { +- _cachedTypeDeserializerMap.put(type, deserializer); +- } +- } +- +- return deserializer; +- } +- +- private static void addBasic(Class cl, String typeName, int type) +- { +- Deserializer deserializer = new BasicDeserializer(type); +- +- _staticTypeMap.put(typeName, deserializer); +- } +- +- static { +- _staticTypeMap = new HashMap(); +- +- addBasic(void.class, "void", BasicSerializer.NULL); +- +- addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); +- addBasic(Byte.class, "byte", BasicSerializer.BYTE); +- addBasic(Short.class, "short", BasicSerializer.SHORT); +- addBasic(Integer.class, "int", BasicSerializer.INTEGER); +- addBasic(Long.class, "long", BasicSerializer.LONG); +- addBasic(Float.class, "float", BasicSerializer.FLOAT); +- addBasic(Double.class, "double", BasicSerializer.DOUBLE); +- addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); +- addBasic(String.class, "string", BasicSerializer.STRING); +- addBasic(StringBuilder.class, "string", BasicSerializer.STRING_BUILDER); +- addBasic(Object.class, "object", BasicSerializer.OBJECT); +- addBasic(java.util.Date.class, "date", BasicSerializer.DATE); +- +- addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); +- addBasic(byte.class, "byte", BasicSerializer.BYTE); +- addBasic(short.class, "short", BasicSerializer.SHORT); +- addBasic(int.class, "int", BasicSerializer.INTEGER); +- addBasic(long.class, "long", BasicSerializer.LONG); +- addBasic(float.class, "float", BasicSerializer.FLOAT); +- addBasic(double.class, "double", BasicSerializer.DOUBLE); +- addBasic(char.class, "char", BasicSerializer.CHARACTER); +- +- addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); +- addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); +- addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); +- addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); +- addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); +- addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); +- addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); +- addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); +- addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); +- addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); +- +- Deserializer objectDeserializer = new JavaDeserializer(Object.class, new FieldDeserializer2Factory()); +- _staticTypeMap.put("object", objectDeserializer); +- _staticTypeMap.put(HessianRemote.class.getName(), +- RemoteDeserializer.DESER); +- +- +- ClassLoader systemClassLoader = null; +- try { +- systemClassLoader = ClassLoader.getSystemClassLoader(); +- } catch (Exception e) { +- } +- +- _systemClassLoader = systemClassLoader; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.Serializable; ++import java.lang.annotation.Annotation; ++import java.lang.ref.SoftReference; ++import java.lang.ref.WeakReference; ++import java.net.InetAddress; ++import java.math.BigDecimal; ++import java.util.ArrayList; ++import java.util.Calendar; ++import java.util.Collection; ++import java.util.Enumeration; ++import java.util.HashMap; ++import java.util.Iterator; ++import java.util.Map; ++import java.util.WeakHashMap; ++import java.util.concurrent.ConcurrentHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import com.caucho.burlap.io.BurlapRemoteObject; ++ ++/** ++ * Factory for returning serialization methods. ++ */ ++public class SerializerFactory extends AbstractSerializerFactory ++{ ++ private static final Logger log ++ = Logger.getLogger(SerializerFactory.class.getName()); ++ ++ private static final Deserializer OBJECT_DESERIALIZER ++ = new BasicDeserializer(BasicDeserializer.OBJECT); ++ ++ private static final ClassLoader _systemClassLoader; ++ ++ private static final HashMap _staticTypeMap; ++ ++ private static final ++ WeakHashMap> ++ _defaultFactoryRefMap ++ = new WeakHashMap>(); ++ ++ private ContextSerializerFactory _contextFactory; ++ private WeakReference _loaderRef; ++ ++ protected Serializer _defaultSerializer; ++ ++ // Additional factories ++ protected ArrayList _factories = new ArrayList(); ++ ++ protected CollectionSerializer _collectionSerializer; ++ protected MapSerializer _mapSerializer; ++ ++ private Deserializer _hashMapDeserializer; ++ private Deserializer _arrayListDeserializer; ++ private Map _cachedSerializerMap; ++ private Map _cachedDeserializerMap; ++ private HashMap _cachedTypeDeserializerMap; ++ ++ private boolean _isAllowNonSerializable; ++ private boolean _isEnableUnsafeSerializer ++ = (UnsafeSerializer.isEnabled() ++ && UnsafeDeserializer.isEnabled()); ++ ++ private FieldDeserializer2Factory _fieldDeserializerFactory; ++ ++ private ClassFactory _classFactory; ++ ++ public SerializerFactory() ++ { ++ this(Thread.currentThread().getContextClassLoader()); ++ } ++ ++ public SerializerFactory(ClassLoader loader) ++ { ++ _loaderRef = new WeakReference(loader); ++ ++ _contextFactory = ContextSerializerFactory.create(loader); ++ ++ if (_isEnableUnsafeSerializer) { ++ _fieldDeserializerFactory = new FieldDeserializer2FactoryUnsafe(); ++ } ++ else { ++ _fieldDeserializerFactory = new FieldDeserializer2Factory(); ++ } ++ } ++ ++ public static SerializerFactory createDefault() ++ { ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ synchronized (_defaultFactoryRefMap) { ++ SoftReference factoryRef ++ = _defaultFactoryRefMap.get(loader); ++ ++ SerializerFactory factory = null; ++ ++ if (factoryRef != null) ++ factory = factoryRef.get(); ++ ++ if (factory == null) { ++ factory = new SerializerFactory(); ++ ++ factoryRef = new SoftReference(factory); ++ ++ _defaultFactoryRefMap.put(loader, factoryRef); ++ } ++ ++ return factory; ++ } ++ } ++ ++ public ClassLoader getClassLoader() ++ { ++ return _loaderRef.get(); ++ } ++ ++ /** ++ * Set true if the collection serializer should send the java type. ++ */ ++ public void setSendCollectionType(boolean isSendType) ++ { ++ if (_collectionSerializer == null) ++ _collectionSerializer = new CollectionSerializer(); ++ ++ _collectionSerializer.setSendJavaType(isSendType); ++ ++ if (_mapSerializer == null) ++ _mapSerializer = new MapSerializer(); ++ ++ _mapSerializer.setSendJavaType(isSendType); ++ } ++ ++ /** ++ * Adds a factory. ++ */ ++ public void addFactory(AbstractSerializerFactory factory) ++ { ++ _factories.add(factory); ++ } ++ ++ /** ++ * If true, non-serializable objects are allowed. ++ */ ++ public void setAllowNonSerializable(boolean allow) ++ { ++ _isAllowNonSerializable = allow; ++ } ++ ++ /** ++ * If true, non-serializable objects are allowed. ++ */ ++ public boolean isAllowNonSerializable() ++ { ++ return _isAllowNonSerializable; ++ } ++ ++ /** ++ * Returns the serializer for a class. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ public Serializer getObjectSerializer(Class cl) ++ throws HessianProtocolException ++ { ++ Serializer serializer = getSerializer(cl); ++ ++ if (serializer instanceof ObjectSerializer) ++ return ((ObjectSerializer) serializer).getObjectSerializer(); ++ else ++ return serializer; ++ } ++ ++ public Class loadSerializedClass(String className) ++ throws ClassNotFoundException ++ { ++ return getClassFactory().load(className); ++ } ++ ++ public ClassFactory getClassFactory() ++ { ++ synchronized (this) { ++ if (_classFactory == null) { ++ _classFactory = new ClassFactory(getClassLoader()); ++ } ++ ++ return _classFactory; ++ } ++ } ++ ++ public FieldDeserializer2Factory getFieldDeserializerFactory() ++ { ++ return _fieldDeserializerFactory; ++ } ++ ++ /** ++ * Returns the serializer for a class. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ public Serializer getSerializer(Class cl) ++ throws HessianProtocolException ++ { ++ Serializer serializer; ++ ++ if (_cachedSerializerMap != null) { ++ serializer = (Serializer) _cachedSerializerMap.get(cl); ++ ++ if (serializer != null) { ++ return serializer; ++ } ++ } ++ ++ serializer = loadSerializer(cl); ++ ++ if (_cachedSerializerMap == null) ++ _cachedSerializerMap = new ConcurrentHashMap(8); ++ ++ _cachedSerializerMap.put(cl, serializer); ++ ++ return serializer; ++ } ++ ++ protected Serializer loadSerializer(Class cl) ++ throws HessianProtocolException ++ { ++ Serializer serializer = null; ++ ++ for (int i = 0; ++ _factories != null && i < _factories.size(); ++ i++) { ++ AbstractSerializerFactory factory; ++ ++ factory = (AbstractSerializerFactory) _factories.get(i); ++ ++ serializer = factory.getSerializer(cl); ++ ++ if (serializer != null) ++ return serializer; ++ } ++ ++ serializer = _contextFactory.getSerializer(cl.getName()); ++ ++ if (serializer != null) ++ return serializer; ++ ++ ClassLoader loader = cl.getClassLoader(); ++ ++ if (loader == null) ++ loader = _systemClassLoader; ++ ++ ContextSerializerFactory factory = null; ++ ++ factory = ContextSerializerFactory.create(loader); ++ ++ serializer = factory.getCustomSerializer(cl); ++ ++ if (serializer != null) { ++ return serializer; ++ } ++ ++ if (HessianRemoteObject.class.isAssignableFrom(cl)) { ++ return new RemoteSerializer(); ++ } ++ else if (BurlapRemoteObject.class.isAssignableFrom(cl)) { ++ return new RemoteSerializer(); ++ } ++ else if (InetAddress.class.isAssignableFrom(cl)) { ++ return InetAddressSerializer.create(); ++ } ++ else if (JavaSerializer.getWriteReplace(cl) != null) { ++ Serializer baseSerializer = getDefaultSerializer(cl); ++ ++ return new WriteReplaceSerializer(cl, getClassLoader(), baseSerializer); ++ } ++ else if (Map.class.isAssignableFrom(cl)) { ++ if (_mapSerializer == null) ++ _mapSerializer = new MapSerializer(); ++ ++ return _mapSerializer; ++ } ++ else if (Collection.class.isAssignableFrom(cl)) { ++ if (_collectionSerializer == null) { ++ _collectionSerializer = new CollectionSerializer(); ++ } ++ ++ return _collectionSerializer; ++ } ++ ++ else if (cl.isArray()) { ++ return new ArraySerializer(); ++ } ++ ++ else if (Throwable.class.isAssignableFrom(cl)) ++ return new ThrowableSerializer(getDefaultSerializer(cl)); ++ ++ else if (InputStream.class.isAssignableFrom(cl)) ++ return new InputStreamSerializer(); ++ ++ else if (Iterator.class.isAssignableFrom(cl)) ++ return IteratorSerializer.create(); ++ ++ else if (Calendar.class.isAssignableFrom(cl)) ++ return CalendarSerializer.SER; ++ ++ else if (Enumeration.class.isAssignableFrom(cl)) ++ return EnumerationSerializer.create(); ++ ++ else if (Enum.class.isAssignableFrom(cl)) ++ return new EnumSerializer(cl); ++ ++ else if (Annotation.class.isAssignableFrom(cl)) ++ return new AnnotationSerializer(cl); ++ ++ else if (BigDecimal.class.isAssignableFrom(cl)) ++ return new NonTransientUnsafeSerializer(cl); ++ else ++ return getDefaultSerializer(cl); ++ } ++ ++ /** ++ * Returns the default serializer for a class that isn't matched ++ * directly. Application can override this method to produce ++ * bean-style serialization instead of field serialization. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ protected Serializer getDefaultSerializer(Class cl) ++ { ++ if (_defaultSerializer != null) ++ return _defaultSerializer; ++ ++ if (! Serializable.class.isAssignableFrom(cl) ++ && ! _isAllowNonSerializable) { ++ throw new IllegalStateException("Serialized class " + cl.getName() + " must implement java.io.Serializable"); ++ } ++ ++ if (_isEnableUnsafeSerializer ++ && JavaSerializer.getWriteReplace(cl) == null) { ++ return UnsafeSerializer.create(cl); ++ } ++ else ++ return JavaSerializer.create(cl); ++ } ++ ++ /** ++ * Returns the deserializer for a class. ++ * ++ * @param cl the class of the object that needs to be deserialized. ++ * ++ * @return a deserializer object for the serialization. ++ */ ++ public Deserializer getDeserializer(Class cl) ++ throws HessianProtocolException ++ { ++ Deserializer deserializer; ++ ++ if (_cachedDeserializerMap != null) { ++ deserializer = (Deserializer) _cachedDeserializerMap.get(cl); ++ ++ if (deserializer != null) ++ return deserializer; ++ } ++ ++ deserializer = loadDeserializer(cl); ++ ++ if (_cachedDeserializerMap == null) ++ _cachedDeserializerMap = new ConcurrentHashMap(8); ++ ++ _cachedDeserializerMap.put(cl, deserializer); ++ ++ return deserializer; ++ } ++ ++ protected Deserializer loadDeserializer(Class cl) ++ throws HessianProtocolException ++ { ++ Deserializer deserializer = null; ++ ++ for (int i = 0; ++ deserializer == null && _factories != null && i < _factories.size(); ++ i++) { ++ AbstractSerializerFactory factory; ++ factory = (AbstractSerializerFactory) _factories.get(i); ++ ++ deserializer = factory.getDeserializer(cl); ++ } ++ ++ if (deserializer != null) ++ return deserializer; ++ ++ // XXX: need test ++ deserializer = _contextFactory.getDeserializer(cl.getName()); ++ ++ if (deserializer != null) ++ return deserializer; ++ ++ ContextSerializerFactory factory = null; ++ ++ if (cl.getClassLoader() != null) ++ factory = ContextSerializerFactory.create(cl.getClassLoader()); ++ else ++ factory = ContextSerializerFactory.create(_systemClassLoader); ++ ++ deserializer = factory.getDeserializer(cl.getName()); ++ ++ if (deserializer != null) ++ return deserializer; ++ ++ deserializer = factory.getCustomDeserializer(cl); ++ ++ if (deserializer != null) ++ return deserializer; ++ ++ if (Collection.class.isAssignableFrom(cl)) ++ deserializer = new CollectionDeserializer(cl); ++ ++ else if (Map.class.isAssignableFrom(cl)) { ++ deserializer = new MapDeserializer(cl); ++ } ++ else if (Iterator.class.isAssignableFrom(cl)) { ++ deserializer = IteratorDeserializer.create(); ++ } ++ else if (Annotation.class.isAssignableFrom(cl)) { ++ deserializer = new AnnotationDeserializer(cl); ++ } ++ else if (cl.isInterface()) { ++ deserializer = new ObjectDeserializer(cl); ++ } ++ else if (cl.isArray()) { ++ deserializer = new ArrayDeserializer(cl.getComponentType()); ++ } ++ else if (Enumeration.class.isAssignableFrom(cl)) { ++ deserializer = EnumerationDeserializer.create(); ++ } ++ else if (Enum.class.isAssignableFrom(cl)){ ++ deserializer = new EnumDeserializer(cl); ++ } ++ else if (Class.class.equals(cl)) ++ deserializer = new ClassDeserializer(getClassLoader()); ++ ++ else if (BigDecimal.class.equals(cl)) ++ deserializer = new NonTransientUnsafeDeserializer(cl); ++ else ++ deserializer = getDefaultDeserializer(cl); ++ ++ return deserializer; ++ } ++ ++ /** ++ * Returns a custom serializer the class ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ protected Deserializer getCustomDeserializer(Class cl) ++ { ++ try { ++ Class serClass = Class.forName(cl.getName() + "HessianDeserializer", ++ false, cl.getClassLoader()); ++ ++ Deserializer ser = (Deserializer) serClass.newInstance(); ++ ++ return ser; ++ } catch (ClassNotFoundException e) { ++ log.log(Level.FINEST, e.toString(), e); ++ ++ return null; ++ } catch (Exception e) { ++ log.log(Level.FINE, e.toString(), e); ++ ++ return null; ++ } ++ } ++ ++ /** ++ * Returns the default serializer for a class that isn't matched ++ * directly. Application can override this method to produce ++ * bean-style serialization instead of field serialization. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ protected Deserializer getDefaultDeserializer(Class cl) ++ { ++ if (InputStream.class.equals(cl)) ++ return InputStreamDeserializer.DESER; ++ ++ if (_isEnableUnsafeSerializer) { ++ return new UnsafeDeserializer(cl, _fieldDeserializerFactory); ++ } ++ else ++ return new JavaDeserializer(cl, _fieldDeserializerFactory); ++ } ++ ++ /** ++ * Reads the object as a list. ++ */ ++ public Object readList(AbstractHessianInput in, int length, String type) ++ throws HessianProtocolException, IOException ++ { ++ Deserializer deserializer = getDeserializer(type); ++ ++ if (deserializer != null) ++ return deserializer.readList(in, length); ++ else ++ return new CollectionDeserializer(ArrayList.class).readList(in, length); ++ } ++ ++ /** ++ * Reads the object as a map. ++ */ ++ public Object readMap(AbstractHessianInput in, String type) ++ throws HessianProtocolException, IOException ++ { ++ Deserializer deserializer = getDeserializer(type); ++ ++ if (deserializer != null) ++ return deserializer.readMap(in); ++ else if (_hashMapDeserializer != null) ++ return _hashMapDeserializer.readMap(in); ++ else { ++ _hashMapDeserializer = new MapDeserializer(HashMap.class); ++ ++ return _hashMapDeserializer.readMap(in); ++ } ++ } ++ ++ /** ++ * Reads the object as a map. ++ */ ++ public Object readObject(AbstractHessianInput in, ++ String type, ++ String []fieldNames) ++ throws HessianProtocolException, IOException ++ { ++ Deserializer deserializer = getDeserializer(type); ++ ++ if (deserializer != null) ++ return deserializer.readObject(in, fieldNames); ++ else if (_hashMapDeserializer != null) ++ return _hashMapDeserializer.readObject(in, fieldNames); ++ else { ++ _hashMapDeserializer = new MapDeserializer(HashMap.class); ++ ++ return _hashMapDeserializer.readObject(in, fieldNames); ++ } ++ } ++ ++ /** ++ * Reads the object as a map. ++ */ ++ public Deserializer getObjectDeserializer(String type, Class cl) ++ throws HessianProtocolException ++ { ++ Deserializer reader = getObjectDeserializer(type); ++ ++ if (cl == null ++ || cl.equals(reader.getType()) ++ || cl.isAssignableFrom(reader.getType()) ++ || reader.isReadResolve() ++ || HessianHandle.class.isAssignableFrom(reader.getType())) { ++ return reader; ++ } ++ ++ if (log.isLoggable(Level.FINE)) { ++ log.fine("hessian: expected deserializer '" + cl.getName() + "' at '" + type + "' (" ++ + reader.getType().getName() + ")"); ++ } ++ ++ return getDeserializer(cl); ++ } ++ ++ /** ++ * Reads the object as a map. ++ */ ++ public Deserializer getObjectDeserializer(String type) ++ throws HessianProtocolException ++ { ++ Deserializer deserializer = getDeserializer(type); ++ ++ if (deserializer != null) ++ return deserializer; ++ else if (_hashMapDeserializer != null) ++ return _hashMapDeserializer; ++ else { ++ _hashMapDeserializer = new MapDeserializer(HashMap.class); ++ ++ return _hashMapDeserializer; ++ } ++ } ++ ++ /** ++ * Reads the object as a map. ++ */ ++ public Deserializer getListDeserializer(String type, Class cl) ++ throws HessianProtocolException ++ { ++ Deserializer reader = getListDeserializer(type); ++ ++ if (cl == null ++ || cl.equals(reader.getType()) ++ || cl.isAssignableFrom(reader.getType())) { ++ return reader; ++ } ++ ++ if (log.isLoggable(Level.FINE)) { ++ log.fine("hessian: expected '" + cl.getName() + "' at '" + type + "' (" ++ + reader.getType().getName() + ")"); ++ } ++ ++ return getDeserializer(cl); ++ } ++ ++ /** ++ * Reads the object as a map. ++ */ ++ public Deserializer getListDeserializer(String type) ++ throws HessianProtocolException ++ { ++ Deserializer deserializer = getDeserializer(type); ++ ++ if (deserializer != null) ++ return deserializer; ++ else if (_arrayListDeserializer != null) ++ return _arrayListDeserializer; ++ else { ++ _arrayListDeserializer = new CollectionDeserializer(ArrayList.class); ++ ++ return _arrayListDeserializer; ++ } ++ } ++ ++ /** ++ * Returns a deserializer based on a string type. ++ */ ++ public Deserializer getDeserializer(String type) ++ throws HessianProtocolException ++ { ++ if (type == null || type.equals("")) ++ return null; ++ ++ Deserializer deserializer; ++ ++ if (_cachedTypeDeserializerMap != null) { ++ synchronized (_cachedTypeDeserializerMap) { ++ deserializer = (Deserializer) _cachedTypeDeserializerMap.get(type); ++ } ++ ++ if (deserializer != null) ++ return deserializer; ++ } ++ ++ ++ deserializer = (Deserializer) _staticTypeMap.get(type); ++ if (deserializer != null) ++ return deserializer; ++ ++ if (type.startsWith("[")) { ++ Deserializer subDeserializer = getDeserializer(type.substring(1)); ++ ++ if (subDeserializer != null) ++ deserializer = new ArrayDeserializer(subDeserializer.getType()); ++ else ++ deserializer = new ArrayDeserializer(Object.class); ++ } ++ else { ++ try { ++ //Class cl = Class.forName(type, false, getClassLoader()); ++ ++ Class cl = loadSerializedClass(type); ++ ++ deserializer = getDeserializer(cl); ++ } catch (Exception e) { ++ log.warning("Hessian/Burlap: '" + type + "' is an unknown class in " + getClassLoader() + ":\n" + e); ++ ++ log.log(Level.FINER, e.toString(), e); ++ } ++ } ++ ++ if (deserializer != null) { ++ if (_cachedTypeDeserializerMap == null) ++ _cachedTypeDeserializerMap = new HashMap(8); ++ ++ synchronized (_cachedTypeDeserializerMap) { ++ _cachedTypeDeserializerMap.put(type, deserializer); ++ } ++ } ++ ++ return deserializer; ++ } ++ ++ private static void addBasic(Class cl, String typeName, int type) ++ { ++ Deserializer deserializer = new BasicDeserializer(type); ++ ++ _staticTypeMap.put(typeName, deserializer); ++ } ++ ++ static { ++ _staticTypeMap = new HashMap(); ++ ++ addBasic(void.class, "void", BasicSerializer.NULL); ++ ++ addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); ++ addBasic(Byte.class, "byte", BasicSerializer.BYTE); ++ addBasic(Short.class, "short", BasicSerializer.SHORT); ++ addBasic(Integer.class, "int", BasicSerializer.INTEGER); ++ addBasic(Long.class, "long", BasicSerializer.LONG); ++ addBasic(Float.class, "float", BasicSerializer.FLOAT); ++ addBasic(Double.class, "double", BasicSerializer.DOUBLE); ++ addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); ++ addBasic(String.class, "string", BasicSerializer.STRING); ++ addBasic(StringBuilder.class, "string", BasicSerializer.STRING_BUILDER); ++ addBasic(Object.class, "object", BasicSerializer.OBJECT); ++ addBasic(java.util.Date.class, "date", BasicSerializer.DATE); ++ ++ addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); ++ addBasic(byte.class, "byte", BasicSerializer.BYTE); ++ addBasic(short.class, "short", BasicSerializer.SHORT); ++ addBasic(int.class, "int", BasicSerializer.INTEGER); ++ addBasic(long.class, "long", BasicSerializer.LONG); ++ addBasic(float.class, "float", BasicSerializer.FLOAT); ++ addBasic(double.class, "double", BasicSerializer.DOUBLE); ++ addBasic(char.class, "char", BasicSerializer.CHARACTER); ++ ++ addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); ++ addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); ++ addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); ++ addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); ++ addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); ++ addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); ++ addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); ++ addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); ++ addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); ++ addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); ++ ++ Deserializer objectDeserializer = new JavaDeserializer(Object.class, new FieldDeserializer2Factory()); ++ _staticTypeMap.put("object", objectDeserializer); ++ _staticTypeMap.put(HessianRemote.class.getName(), ++ RemoteDeserializer.DESER); ++ ++ ++ ClassLoader systemClassLoader = null; ++ try { ++ systemClassLoader = ClassLoader.getSystemClassLoader(); ++ } catch (Exception e) { ++ } ++ ++ _systemClassLoader = systemClassLoader; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ShortHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/ShortHandle.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ShortHandle.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ShortHandle.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,83 +1,83 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.net.URL; +-import java.io.Serializable; +- +-/** +- * Handle for Java Short objects. +- */ +-public class ShortHandle implements Serializable { +- private short _value; +- +- private ShortHandle() +- { +- } +- +- public ShortHandle(short value) +- { +- _value = value; +- } +- +- public short getValue() +- { +- return _value; +- } +- +- public Object readResolve() +- { +- return new Short(_value); +- } +- +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _value + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.net.URL; ++import java.io.Serializable; ++ ++/** ++ * Handle for Java Short objects. ++ */ ++public class ShortHandle implements Serializable { ++ private short _value; ++ ++ private ShortHandle() ++ { ++ } ++ ++ public ShortHandle(short value) ++ { ++ _value = value; ++ } ++ ++ public short getValue() ++ { ++ return _value; ++ } ++ ++ public Object readResolve() ++ { ++ return new Short(_value); ++ } ++ ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _value + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/SqlDateDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/SqlDateDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,141 +1,141 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Constructor; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Deserializing a string valued object +- */ +-public class SqlDateDeserializer extends AbstractDeserializer { +- private Class _cl; +- private Constructor _constructor; +- +- public SqlDateDeserializer(Class cl) +- { +- try { +- _cl = cl; +- _constructor = cl.getConstructor(new Class[] { long.class }); +- } catch (NoSuchMethodException e) { +- throw new HessianException(e); +- } +- } +- +- public Class getType() +- { +- return _cl; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- int ref = in.addRef(null); +- +- long initValue = Long.MIN_VALUE; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if (key.equals("value")) +- initValue = in.readUTCDate(); +- else +- in.readString(); +- } +- +- in.readMapEnd(); +- +- Object value = create(initValue); +- +- in.setRef(ref, value); +- +- return value; +- } +- +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException +- { +- String []fieldNames = (String []) fields; +- +- int ref = in.addRef(null); +- +- long initValue = Long.MIN_VALUE; +- +- for (int i = 0; i < fieldNames.length; i++) { +- String key = fieldNames[i]; +- +- if (key.equals("value")) +- initValue = in.readUTCDate(); +- else +- in.readObject(); +- } +- +- Object value = create(initValue); +- +- in.setRef(ref, value); +- +- return value; +- } +- +- private Object create(long initValue) +- throws IOException +- { +- if (initValue == Long.MIN_VALUE) +- throw new IOException(_cl.getName() + " expects name."); +- +- try { +- return _constructor.newInstance(new Object[] { new Long(initValue) }); +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Constructor; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Deserializing a string valued object ++ */ ++public class SqlDateDeserializer extends AbstractDeserializer { ++ private Class _cl; ++ private Constructor _constructor; ++ ++ public SqlDateDeserializer(Class cl) ++ { ++ try { ++ _cl = cl; ++ _constructor = cl.getConstructor(new Class[] { long.class }); ++ } catch (NoSuchMethodException e) { ++ throw new HessianException(e); ++ } ++ } ++ ++ public Class getType() ++ { ++ return _cl; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ int ref = in.addRef(null); ++ ++ long initValue = Long.MIN_VALUE; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("value")) ++ initValue = in.readUTCDate(); ++ else ++ in.readString(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object value = create(initValue); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ String []fieldNames = (String []) fields; ++ ++ int ref = in.addRef(null); ++ ++ long initValue = Long.MIN_VALUE; ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ String key = fieldNames[i]; ++ ++ if (key.equals("value")) ++ initValue = in.readUTCDate(); ++ else ++ in.readObject(); ++ } ++ ++ Object value = create(initValue); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ private Object create(long initValue) ++ throws IOException ++ { ++ if (initValue == Long.MIN_VALUE) ++ throw new IOException(_cl.getName() + " expects name."); ++ ++ try { ++ return _constructor.newInstance(new Object[] { new Long(initValue) }); ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/SqlDateSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/SqlDateSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,88 +1,88 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.util.Date; +- +-/** +- * Serializing a sql date object. +- */ +-public class SqlDateSerializer extends AbstractSerializer +-{ +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (obj == null) +- out.writeNull(); +- else { +- Class cl = obj.getClass(); +- +- if (out.addRef(obj)) +- return; +- +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref < -1) { +- out.writeString("value"); +- out.writeUTCDate(((Date) obj).getTime()); +- out.writeMapEnd(); +- } +- else { +- if (ref == -1) { +- out.writeInt(1); +- out.writeString("value"); +- out.writeObjectBegin(cl.getName()); +- } +- +- out.writeUTCDate(((Date) obj).getTime()); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.util.Date; ++ ++/** ++ * Serializing a sql date object. ++ */ ++public class SqlDateSerializer extends AbstractSerializer ++{ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (obj == null) ++ out.writeNull(); ++ else { ++ Class cl = obj.getClass(); ++ ++ if (out.addRef(obj)) ++ return; ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref < -1) { ++ out.writeString("value"); ++ out.writeUTCDate(((Date) obj).getTime()); ++ out.writeMapEnd(); ++ } ++ else { ++ if (ref == -1) { ++ out.writeInt(1); ++ out.writeString("value"); ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ out.writeUTCDate(((Date) obj).getTime()); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/StackTraceElementDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/StackTraceElementDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/StackTraceElementDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/StackTraceElementDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,74 +1,74 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.lang.reflect.Constructor; +- +-/** +- * Deserializing a JDK 1.4 StackTraceElement +- */ +-public class StackTraceElementDeserializer extends JavaDeserializer { +- public StackTraceElementDeserializer(FieldDeserializer2Factory fieldFactory) +- { +- super(StackTraceElement.class, fieldFactory); +- } +- +- @Override +- protected Constructor getConstructor(Class cl) +- { +- return null; +- } +- +- @Override +- protected Object instantiate() +- throws Exception +- { +- return new StackTraceElement("", "", "", 0); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.lang.reflect.Constructor; ++ ++/** ++ * Deserializing a JDK 1.4 StackTraceElement ++ */ ++public class StackTraceElementDeserializer extends JavaDeserializer { ++ public StackTraceElementDeserializer(FieldDeserializer2Factory fieldFactory) ++ { ++ super(StackTraceElement.class, fieldFactory); ++ } ++ ++ @Override ++ protected Constructor getConstructor(Class cl) ++ { ++ return null; ++ } ++ ++ @Override ++ protected Object instantiate() ++ throws Exception ++ { ++ return new StackTraceElement("", "", "", 0); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/StringValueDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/StringValueDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/StringValueDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/StringValueDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,93 +1,93 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Constructor; +- +-import com.caucho.hessian.HessianException; +- +-/** +- * Deserializing a string valued object +- */ +-public class StringValueDeserializer extends AbstractStringValueDeserializer { +- private Class _cl; +- private Constructor _constructor; +- +- public StringValueDeserializer(Class cl) +- { +- try { +- _cl = cl; +- _constructor = cl.getConstructor(new Class[] { String.class }); +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- @Override +- public Class getType() +- { +- return _cl; +- } +- +- @Override +- protected Object create(String value) +- throws IOException +- { +- if (value == null) +- throw new IOException(_cl.getName() + " expects name."); +- +- try { +- return _constructor.newInstance(new Object[] { value }); +- } catch (Exception e) { +- throw new HessianException(_cl.getName() + ": value=" + value + "\n" + e, +- e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Constructor; ++ ++import com.caucho.hessian.HessianException; ++ ++/** ++ * Deserializing a string valued object ++ */ ++public class StringValueDeserializer extends AbstractStringValueDeserializer { ++ private Class _cl; ++ private Constructor _constructor; ++ ++ public StringValueDeserializer(Class cl) ++ { ++ try { ++ _cl = cl; ++ _constructor = cl.getConstructor(new Class[] { String.class }); ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ @Override ++ public Class getType() ++ { ++ return _cl; ++ } ++ ++ @Override ++ protected Object create(String value) ++ throws IOException ++ { ++ if (value == null) ++ throw new IOException(_cl.getName() + " expects name."); ++ ++ try { ++ return _constructor.newInstance(new Object[] { value }); ++ } catch (Exception e) { ++ throw new HessianException(_cl.getName() + ": value=" + value + "\n" + e, ++ e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/StringValueSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/StringValueSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/StringValueSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/StringValueSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,88 +1,88 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing a remote object. +- */ +-public class StringValueSerializer extends AbstractSerializer { +- public static final Serializer SER = new StringValueSerializer(); +- +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (obj == null) +- out.writeNull(); +- else { +- if (out.addRef(obj)) +- return; +- +- Class cl = obj.getClass(); +- +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref < -1) { +- out.writeString("value"); +- out.writeString(obj.toString()); +- out.writeMapEnd(); +- } +- else { +- if (ref == -1) { +- out.writeInt(1); +- out.writeString("value"); +- out.writeObjectBegin(cl.getName()); +- } +- +- out.writeString(obj.toString()); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing a remote object. ++ */ ++public class StringValueSerializer extends AbstractSerializer { ++ public static final Serializer SER = new StringValueSerializer(); ++ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (obj == null) ++ out.writeNull(); ++ else { ++ if (out.addRef(obj)) ++ return; ++ ++ Class cl = obj.getClass(); ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref < -1) { ++ out.writeString("value"); ++ out.writeString(obj.toString()); ++ out.writeMapEnd(); ++ } ++ else { ++ if (ref == -1) { ++ out.writeInt(1); ++ out.writeString("value"); ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ out.writeString(obj.toString()); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ThrowableSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ThrowableSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ThrowableSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ThrowableSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,80 +1,80 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Serializing an object for known object types. +- */ +-public class ThrowableSerializer extends AbstractSerializerWrapper { +- private final Serializer _ser; +- +- public ThrowableSerializer(Serializer ser) +- { +- _ser = ser; +- } +- +- @Override +- protected Serializer getDelegate() +- { +- return _ser; +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- Throwable e = (Throwable) obj; +- +- e.getStackTrace(); +- +- _ser.writeObject(obj, out); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class ThrowableSerializer extends AbstractSerializerWrapper { ++ private final Serializer _ser; ++ ++ public ThrowableSerializer(Serializer ser) ++ { ++ _ser = ser; ++ } ++ ++ @Override ++ protected Serializer getDelegate() ++ { ++ return _ser; ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ Throwable e = (Throwable) obj; ++ ++ e.getStackTrace(); ++ ++ _ser.writeObject(obj, out); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/UnsafeDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/UnsafeDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,392 +1,392 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.Field; +-import java.lang.reflect.InvocationTargetException; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.HashMap; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import com.caucho.hessian.io.FieldDeserializer2FactoryUnsafe.NullFieldDeserializer; +- +-import sun.misc.Unsafe; +- +-/** +- * Serializing an object for known object types. +- */ +-public class UnsafeDeserializer extends AbstractMapDeserializer { +- private static final Logger log +- = Logger.getLogger(JavaDeserializer.class.getName()); +- +- private static boolean _isEnabled; +- @SuppressWarnings("restriction") +- private static Unsafe _unsafe; +- +- private Class _type; +- private HashMap _fieldMap; +- private Method _readResolve; +- +- public UnsafeDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) +- { +- _type = cl; +- _fieldMap = getFieldMap(cl, fieldFactory); +- +- _readResolve = getReadResolve(cl); +- +- if (_readResolve != null) { +- _readResolve.setAccessible(true); +- } +- } +- +- public static boolean isEnabled() +- { +- return _isEnabled; +- } +- +- @Override +- public Class getType() +- { +- return _type; +- } +- +- @Override +- public boolean isReadResolve() +- { +- return _readResolve != null; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- try { +- Object obj = instantiate(); +- +- return readMap(in, obj); +- } catch (IOException e) { +- throw e; +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); +- } +- } +- +- @Override +- public Object []createFields(int len) +- { +- return new FieldDeserializer2[len]; +- } +- +- public Object createField(String name) +- { +- Object reader = _fieldMap.get(name); +- +- if (reader == null) +- reader = NullFieldDeserializer.DESER; +- +- return reader; +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, +- Object []fields) +- throws IOException +- { +- try { +- Object obj = instantiate(); +- +- return readObject(in, obj, (FieldDeserializer2 []) fields); +- } catch (IOException e) { +- throw e; +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); +- } +- } +- +- @Override +- public Object readObject(AbstractHessianInput in, +- String []fieldNames) +- throws IOException +- { +- try { +- Object obj = instantiate(); +- +- return readObject(in, obj, fieldNames); +- } catch (IOException e) { +- throw e; +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); +- } +- } +- +- /** +- * Returns the readResolve method +- */ +- protected Method getReadResolve(Class cl) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (method.getName().equals("readResolve") +- && method.getParameterTypes().length == 0) +- return method; +- } +- } +- +- return null; +- } +- +- public Object readMap(AbstractHessianInput in, Object obj) +- throws IOException +- { +- try { +- int ref = in.addRef(obj); +- +- while (! in.isEnd()) { +- Object key = in.readObject(); +- +- FieldDeserializer2 deser = (FieldDeserializer2) _fieldMap.get(key); +- +- if (deser != null) +- deser.deserialize(in, obj); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- Object resolve = resolve(in, obj); +- +- if (obj != resolve) +- in.setRef(ref, resolve); +- +- return resolve; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(e); +- } +- } +- +- public Object readObject(AbstractHessianInput in, +- Object obj, +- FieldDeserializer2 []fields) +- throws IOException +- { +- try { +- int ref = in.addRef(obj); +- +- for (FieldDeserializer2 reader : fields) { +- reader.deserialize(in, obj); +- } +- +- Object resolve = resolve(in, obj); +- +- if (obj != resolve) +- in.setRef(ref, resolve); +- +- return resolve; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); +- } +- } +- +- public Object readObject(AbstractHessianInput in, +- Object obj, +- String []fieldNames) +- throws IOException +- { +- try { +- int ref = in.addRef(obj); +- +- for (String fieldName : fieldNames) { +- FieldDeserializer2 reader = _fieldMap.get(fieldName); +- +- if (reader != null) +- reader.deserialize(in, obj); +- else +- in.readObject(); +- } +- +- Object resolve = resolve(in, obj); +- +- if (obj != resolve) +- in.setRef(ref, resolve); +- +- return resolve; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); +- } +- } +- +- protected Object resolve(AbstractHessianInput in, Object obj) +- throws Exception +- { +- // if there's a readResolve method, call it +- try { +- if (_readResolve != null) +- return _readResolve.invoke(obj, new Object[0]); +- } catch (InvocationTargetException e) { +- if (e.getCause() instanceof Exception) +- throw (Exception) e.getCause(); +- else +- throw e; +- } +- +- return obj; +- } +- +- @SuppressWarnings("restriction") +- protected Object instantiate() +- throws Exception +- { +- return _unsafe.allocateInstance(_type); +- } +- +- /** +- * Creates a map of the classes fields. +- */ +- protected HashMap +- getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) +- { +- HashMap fieldMap +- = new HashMap(); +- +- for (; cl != null; cl = cl.getSuperclass()) { +- Field []fields = cl.getDeclaredFields(); +- for (int i = 0; i < fields.length; i++) { +- Field field = fields[i]; +- +- if (Modifier.isTransient(field.getModifiers()) +- || Modifier.isStatic(field.getModifiers())) +- continue; +- else if (fieldMap.get(field.getName()) != null) +- continue; +- +- /* +- // XXX: could parameterize the handler to only deal with public +- try { +- field.setAccessible(true); +- } catch (Throwable e) { +- e.printStackTrace(); +- } +- */ +- +- FieldDeserializer2 deser = fieldFactory.create(field); +- +- fieldMap.put(field.getName(), deser); +- } +- } +- +- return fieldMap; +- } +- +- static void logDeserializeError(Field field, Object obj, Object value, +- Throwable e) +- throws IOException +- { +- String fieldName = (field.getDeclaringClass().getName() +- + "." + field.getName()); +- +- if (e instanceof HessianFieldException) +- throw (HessianFieldException) e; +- else if (e instanceof IOException) +- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); +- +- if (value != null) +- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" +- + " cannot be assigned to '" + field.getType().getName() + "'", e); +- else +- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); +- } +- +- static { +- boolean isEnabled = false; +- +- try { +- Class unsafe = Class.forName("sun.misc.Unsafe"); +- Field theUnsafe = null; +- for (Field field : unsafe.getDeclaredFields()) { +- if (field.getName().equals("theUnsafe")) +- theUnsafe = field; +- } +- +- if (theUnsafe != null) { +- theUnsafe.setAccessible(true); +- _unsafe = (Unsafe) theUnsafe.get(null); +- } +- +- isEnabled = _unsafe != null; +- +- String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); +- +- if ("false".equals(unsafeProp)) +- isEnabled = false; +- } catch (Throwable e) { +- log.log(Level.FINER, e.toString(), e); +- } +- +- _isEnabled = isEnabled; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Field; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.HashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import com.caucho.hessian.io.FieldDeserializer2FactoryUnsafe.NullFieldDeserializer; ++ ++import sun.misc.Unsafe; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class UnsafeDeserializer extends AbstractMapDeserializer { ++ private static final Logger log ++ = Logger.getLogger(JavaDeserializer.class.getName()); ++ ++ private static boolean _isEnabled; ++ @SuppressWarnings("restriction") ++ private static Unsafe _unsafe; ++ ++ private Class _type; ++ private HashMap _fieldMap; ++ private Method _readResolve; ++ ++ public UnsafeDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) ++ { ++ _type = cl; ++ _fieldMap = getFieldMap(cl, fieldFactory); ++ ++ _readResolve = getReadResolve(cl); ++ ++ if (_readResolve != null) { ++ _readResolve.setAccessible(true); ++ } ++ } ++ ++ public static boolean isEnabled() ++ { ++ return _isEnabled; ++ } ++ ++ @Override ++ public Class getType() ++ { ++ return _type; ++ } ++ ++ @Override ++ public boolean isReadResolve() ++ { ++ return _readResolve != null; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readMap(in, obj); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object []createFields(int len) ++ { ++ return new FieldDeserializer2[len]; ++ } ++ ++ public Object createField(String name) ++ { ++ Object reader = _fieldMap.get(name); ++ ++ if (reader == null) ++ reader = NullFieldDeserializer.DESER; ++ ++ return reader; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, (FieldDeserializer2 []) fields); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, fieldNames); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ /** ++ * Returns the readResolve method ++ */ ++ protected Method getReadResolve(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("readResolve") ++ && method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ public Object readMap(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ while (! in.isEnd()) { ++ Object key = in.readObject(); ++ ++ FieldDeserializer2 deser = (FieldDeserializer2) _fieldMap.get(key); ++ ++ if (deser != null) ++ deser.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object obj, ++ FieldDeserializer2 []fields) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (FieldDeserializer2 reader : fields) { ++ reader.deserialize(in, obj); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object obj, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (String fieldName : fieldNames) { ++ FieldDeserializer2 reader = _fieldMap.get(fieldName); ++ ++ if (reader != null) ++ reader.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ protected Object resolve(AbstractHessianInput in, Object obj) ++ throws Exception ++ { ++ // if there's a readResolve method, call it ++ try { ++ if (_readResolve != null) ++ return _readResolve.invoke(obj, new Object[0]); ++ } catch (InvocationTargetException e) { ++ if (e.getCause() instanceof Exception) ++ throw (Exception) e.getCause(); ++ else ++ throw e; ++ } ++ ++ return obj; ++ } ++ ++ @SuppressWarnings("restriction") ++ protected Object instantiate() ++ throws Exception ++ { ++ return _unsafe.allocateInstance(_type); ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected HashMap ++ getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) ++ { ++ HashMap fieldMap ++ = new HashMap(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isTransient(field.getModifiers()) ++ || Modifier.isStatic(field.getModifiers())) ++ continue; ++ else if (fieldMap.get(field.getName()) != null) ++ continue; ++ ++ /* ++ // XXX: could parameterize the handler to only deal with public ++ try { ++ field.setAccessible(true); ++ } catch (Throwable e) { ++ e.printStackTrace(); ++ } ++ */ ++ ++ FieldDeserializer2 deser = fieldFactory.create(field); ++ ++ fieldMap.put(field.getName(), deser); ++ } ++ } ++ ++ return fieldMap; ++ } ++ ++ static void logDeserializeError(Field field, Object obj, Object value, ++ Throwable e) ++ throws IOException ++ { ++ String fieldName = (field.getDeclaringClass().getName() ++ + "." + field.getName()); ++ ++ if (e instanceof HessianFieldException) ++ throw (HessianFieldException) e; ++ else if (e instanceof IOException) ++ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); ++ ++ if (value != null) ++ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" ++ + " cannot be assigned to '" + field.getType().getName() + "'", e); ++ else ++ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); ++ } ++ ++ static { ++ boolean isEnabled = false; ++ ++ try { ++ Class unsafe = Class.forName("sun.misc.Unsafe"); ++ Field theUnsafe = null; ++ for (Field field : unsafe.getDeclaredFields()) { ++ if (field.getName().equals("theUnsafe")) ++ theUnsafe = field; ++ } ++ ++ if (theUnsafe != null) { ++ theUnsafe.setAccessible(true); ++ _unsafe = (Unsafe) theUnsafe.get(null); ++ } ++ ++ isEnabled = _unsafe != null; ++ ++ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); ++ ++ if ("false".equals(unsafeProp)) ++ isEnabled = false; ++ } catch (Throwable e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _isEnabled = isEnabled; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/UnsafeSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/UnsafeSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,570 +1,570 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.ref.SoftReference; +-import java.lang.reflect.Field; +-import java.lang.reflect.Modifier; +-import java.util.ArrayList; +-import java.util.WeakHashMap; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import sun.misc.Unsafe; +- +-import com.caucho.hessian.HessianUnshared; +- +-/** +- * Serializing an object for known object types. +- */ +-public class UnsafeSerializer extends AbstractSerializer +-{ +- private static final Logger log +- = Logger.getLogger(UnsafeSerializer.class.getName()); +- +- private static boolean _isEnabled; +- private static final Unsafe _unsafe; +- +- private static final WeakHashMap,SoftReference> _serializerMap +- = new WeakHashMap,SoftReference>(); +- +- private Field []_fields; +- private FieldSerializer []_fieldSerializers; +- +- public static boolean isEnabled() +- { +- return _isEnabled; +- } +- +- public UnsafeSerializer(Class cl) +- { +- introspect(cl); +- } +- +- public static UnsafeSerializer create(Class cl) +- { +- synchronized (_serializerMap) { +- SoftReference baseRef +- = _serializerMap.get(cl); +- +- UnsafeSerializer base = baseRef != null ? baseRef.get() : null; +- +- if (base == null) { +- if (cl.isAnnotationPresent(HessianUnshared.class)) +- base = new UnsafeUnsharedSerializer(cl); +- else +- base = new UnsafeSerializer(cl); +- +- baseRef = new SoftReference(base); +- _serializerMap.put(cl, baseRef); +- } +- +- return base; +- } +- } +- +- protected void introspect(Class cl) +- { +- ArrayList primitiveFields = new ArrayList(); +- ArrayList compoundFields = new ArrayList(); +- +- for (; cl != null; cl = cl.getSuperclass()) { +- Field []fields = cl.getDeclaredFields(); +- +- for (int i = 0; i < fields.length; i++) { +- Field field = fields[i]; +- +- if (Modifier.isTransient(field.getModifiers()) +- || Modifier.isStatic(field.getModifiers())) { +- continue; +- } +- +- /* +- // XXX: could parameterize the handler to only deal with public +- field.setAccessible(true); +- */ +- +- if (field.getType().isPrimitive() +- || (field.getType().getName().startsWith("java.lang.") +- && ! field.getType().equals(Object.class))) { +- primitiveFields.add(field); +- } +- else { +- compoundFields.add(field); +- } +- } +- } +- +- ArrayList fields = new ArrayList(); +- fields.addAll(primitiveFields); +- fields.addAll(compoundFields); +- +- _fields = new Field[fields.size()]; +- fields.toArray(_fields); +- +- _fieldSerializers = new FieldSerializer[_fields.length]; +- +- for (int i = 0; i < _fields.length; i++) { +- _fieldSerializers[i] = getFieldSerializer(_fields[i]); +- } +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- if (out.addRef(obj)) { +- return; +- } +- +- Class cl = obj.getClass(); +- +- int ref = out.writeObjectBegin(cl.getName()); +- +- if (ref >= 0) { +- writeInstance(obj, out); +- } +- else if (ref == -1) { +- writeDefinition20(out); +- out.writeObjectBegin(cl.getName()); +- writeInstance(obj, out); +- } +- else { +- writeObject10(obj, out); +- } +- } +- +- protected void writeObject10(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- for (int i = 0; i < _fields.length; i++) { +- Field field = _fields[i]; +- +- out.writeString(field.getName()); +- +- _fieldSerializers[i].serialize(out, obj); +- } +- +- out.writeMapEnd(); +- } +- +- private void writeDefinition20(AbstractHessianOutput out) +- throws IOException +- { +- out.writeClassFieldLength(_fields.length); +- +- for (int i = 0; i < _fields.length; i++) { +- Field field = _fields[i]; +- +- out.writeString(field.getName()); +- } +- } +- +- final public void writeInstance(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- try { +- FieldSerializer []fieldSerializers = _fieldSerializers; +- int length = fieldSerializers.length; +- +- for (int i = 0; i < length; i++) { +- fieldSerializers[i].serialize(out, obj); +- } +- } catch (RuntimeException e) { +- throw new RuntimeException(e.getMessage() + "\n class: " +- + obj.getClass().getName() +- + " (object=" + obj + ")", +- e); +- } catch (IOException e) { +- throw new IOExceptionWrapper(e.getMessage() + "\n class: " +- + obj.getClass().getName() +- + " (object=" + obj + ")", +- e); +- } +- } +- +- private static FieldSerializer getFieldSerializer(Field field) +- { +- Class type = field.getType(); +- +- if (boolean.class.equals(type)) { +- return new BooleanFieldSerializer(field); +- } +- else if (byte.class.equals(type)) { +- return new ByteFieldSerializer(field); +- } +- else if (char.class.equals(type)) { +- return new CharFieldSerializer(field); +- } +- else if (short.class.equals(type)) { +- return new ShortFieldSerializer(field); +- } +- else if (int.class.equals(type)) { +- return new IntFieldSerializer(field); +- } +- else if (long.class.equals(type)) { +- return new LongFieldSerializer(field); +- } +- else if (double.class.equals(type)) { +- return new DoubleFieldSerializer(field); +- } +- else if (float.class.equals(type)) { +- return new FloatFieldSerializer(field); +- } +- else if (String.class.equals(type)) { +- return new StringFieldSerializer(field); +- } +- else if (java.util.Date.class.equals(type) +- || java.sql.Date.class.equals(type) +- || java.sql.Timestamp.class.equals(type) +- || java.sql.Time.class.equals(type)) { +- return new DateFieldSerializer(field); +- } +- else +- return new ObjectFieldSerializer(field); +- } +- +- abstract static class FieldSerializer { +- abstract void serialize(AbstractHessianOutput out, Object obj) +- throws IOException; +- } +- +- final static class ObjectFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- ObjectFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- @Override +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- try { +- Object value = _unsafe.getObject(obj, _offset); +- +- out.writeObject(value); +- } catch (RuntimeException e) { +- throw new RuntimeException(e.getMessage() + "\n field: " +- + _field.getDeclaringClass().getName() +- + '.' + _field.getName(), +- e); +- } catch (IOException e) { +- throw new IOExceptionWrapper(e.getMessage() + "\n field: " +- + _field.getDeclaringClass().getName() +- + '.' + _field.getName(), +- e); +- } +- } +- } +- +- final static class BooleanFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- BooleanFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- boolean value = _unsafe.getBoolean(obj, _offset); +- +- out.writeBoolean(value); +- } +- } +- +- final static class ByteFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- ByteFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- int value = _unsafe.getByte(obj, _offset); +- +- out.writeInt(value); +- } +- } +- +- final static class CharFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- CharFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- char value = _unsafe.getChar(obj, _offset); +- +- out.writeString(String.valueOf(value)); +- } +- } +- +- final static class ShortFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- ShortFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- int value = _unsafe.getShort(obj, _offset); +- +- out.writeInt(value); +- } +- } +- +- final static class IntFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- IntFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- int value = _unsafe.getInt(obj, _offset); +- +- out.writeInt(value); +- } +- } +- +- final static class LongFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- LongFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- long value = _unsafe.getLong(obj, _offset); +- +- out.writeLong(value); +- } +- } +- +- final static class FloatFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- FloatFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- double value = _unsafe.getFloat(obj, _offset); +- +- out.writeDouble(value); +- } +- } +- +- final static class DoubleFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- DoubleFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- double value = _unsafe.getDouble(obj, _offset); +- +- out.writeDouble(value); +- } +- } +- +- final static class StringFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- StringFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- @Override +- final void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- String value = (String) _unsafe.getObject(obj, _offset); +- +- out.writeString(value); +- } +- } +- +- final static class DateFieldSerializer extends FieldSerializer { +- private final Field _field; +- private final long _offset; +- +- DateFieldSerializer(Field field) +- { +- _field = field; +- _offset = _unsafe.objectFieldOffset(field); +- +- if (_offset == Unsafe.INVALID_FIELD_OFFSET) +- throw new IllegalStateException(); +- } +- +- @Override +- void serialize(AbstractHessianOutput out, Object obj) +- throws IOException +- { +- java.util.Date value +- = (java.util.Date) _unsafe.getObject(obj, _offset); +- +- if (value == null) +- out.writeNull(); +- else +- out.writeUTCDate(value.getTime()); +- } +- } +- +- static { +- boolean isEnabled = false; +- Unsafe unsafe = null; +- +- try { +- Class unsafeClass = Class.forName("sun.misc.Unsafe"); +- Field theUnsafe = null; +- for (Field field : unsafeClass.getDeclaredFields()) { +- if (field.getName().equals("theUnsafe")) +- theUnsafe = field; +- } +- +- if (theUnsafe != null) { +- theUnsafe.setAccessible(true); +- unsafe = (Unsafe) theUnsafe.get(null); +- } +- +- isEnabled = unsafe != null; +- +- String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); +- +- if ("false".equals(unsafeProp)) +- isEnabled = false; +- } catch (Throwable e) { +- log.log(Level.ALL, e.toString(), e); +- } +- +- _unsafe = unsafe; +- _isEnabled = isEnabled; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.ref.SoftReference; ++import java.lang.reflect.Field; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.WeakHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import sun.misc.Unsafe; ++ ++import com.caucho.hessian.HessianUnshared; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class UnsafeSerializer extends AbstractSerializer ++{ ++ private static final Logger log ++ = Logger.getLogger(UnsafeSerializer.class.getName()); ++ ++ private static boolean _isEnabled; ++ private static final Unsafe _unsafe; ++ ++ private static final WeakHashMap,SoftReference> _serializerMap ++ = new WeakHashMap,SoftReference>(); ++ ++ private Field []_fields; ++ private FieldSerializer []_fieldSerializers; ++ ++ public static boolean isEnabled() ++ { ++ return _isEnabled; ++ } ++ ++ public UnsafeSerializer(Class cl) ++ { ++ introspect(cl); ++ } ++ ++ public static UnsafeSerializer create(Class cl) ++ { ++ synchronized (_serializerMap) { ++ SoftReference baseRef ++ = _serializerMap.get(cl); ++ ++ UnsafeSerializer base = baseRef != null ? baseRef.get() : null; ++ ++ if (base == null) { ++ if (cl.isAnnotationPresent(HessianUnshared.class)) ++ base = new UnsafeUnsharedSerializer(cl); ++ else ++ base = new UnsafeSerializer(cl); ++ ++ baseRef = new SoftReference(base); ++ _serializerMap.put(cl, baseRef); ++ } ++ ++ return base; ++ } ++ } ++ ++ protected void introspect(Class cl) ++ { ++ ArrayList primitiveFields = new ArrayList(); ++ ArrayList compoundFields = new ArrayList(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isTransient(field.getModifiers()) ++ || Modifier.isStatic(field.getModifiers())) { ++ continue; ++ } ++ ++ /* ++ // XXX: could parameterize the handler to only deal with public ++ field.setAccessible(true); ++ */ ++ ++ if (field.getType().isPrimitive() ++ || (field.getType().getName().startsWith("java.lang.") ++ && ! field.getType().equals(Object.class))) { ++ primitiveFields.add(field); ++ } ++ else { ++ compoundFields.add(field); ++ } ++ } ++ } ++ ++ ArrayList fields = new ArrayList(); ++ fields.addAll(primitiveFields); ++ fields.addAll(compoundFields); ++ ++ _fields = new Field[fields.size()]; ++ fields.toArray(_fields); ++ ++ _fieldSerializers = new FieldSerializer[_fields.length]; ++ ++ for (int i = 0; i < _fields.length; i++) { ++ _fieldSerializers[i] = getFieldSerializer(_fields[i]); ++ } ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) { ++ return; ++ } ++ ++ Class cl = obj.getClass(); ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref >= 0) { ++ writeInstance(obj, out); ++ } ++ else if (ref == -1) { ++ writeDefinition20(out); ++ out.writeObjectBegin(cl.getName()); ++ writeInstance(obj, out); ++ } ++ else { ++ writeObject10(obj, out); ++ } ++ } ++ ++ protected void writeObject10(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ ++ _fieldSerializers[i].serialize(out, obj); ++ } ++ ++ out.writeMapEnd(); ++ } ++ ++ private void writeDefinition20(AbstractHessianOutput out) ++ throws IOException ++ { ++ out.writeClassFieldLength(_fields.length); ++ ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ } ++ } ++ ++ final public void writeInstance(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ try { ++ FieldSerializer []fieldSerializers = _fieldSerializers; ++ int length = fieldSerializers.length; ++ ++ for (int i = 0; i < length; i++) { ++ fieldSerializers[i].serialize(out, obj); ++ } ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } ++ } ++ ++ private static FieldSerializer getFieldSerializer(Field field) ++ { ++ Class type = field.getType(); ++ ++ if (boolean.class.equals(type)) { ++ return new BooleanFieldSerializer(field); ++ } ++ else if (byte.class.equals(type)) { ++ return new ByteFieldSerializer(field); ++ } ++ else if (char.class.equals(type)) { ++ return new CharFieldSerializer(field); ++ } ++ else if (short.class.equals(type)) { ++ return new ShortFieldSerializer(field); ++ } ++ else if (int.class.equals(type)) { ++ return new IntFieldSerializer(field); ++ } ++ else if (long.class.equals(type)) { ++ return new LongFieldSerializer(field); ++ } ++ else if (double.class.equals(type)) { ++ return new DoubleFieldSerializer(field); ++ } ++ else if (float.class.equals(type)) { ++ return new FloatFieldSerializer(field); ++ } ++ else if (String.class.equals(type)) { ++ return new StringFieldSerializer(field); ++ } ++ else if (java.util.Date.class.equals(type) ++ || java.sql.Date.class.equals(type) ++ || java.sql.Timestamp.class.equals(type) ++ || java.sql.Time.class.equals(type)) { ++ return new DateFieldSerializer(field); ++ } ++ else ++ return new ObjectFieldSerializer(field); ++ } ++ ++ abstract static class FieldSerializer { ++ abstract void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException; ++ } ++ ++ final static class ObjectFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ObjectFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ try { ++ Object value = _unsafe.getObject(obj, _offset); ++ ++ out.writeObject(value); ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n field: " ++ + _field.getDeclaringClass().getName() ++ + '.' + _field.getName(), ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n field: " ++ + _field.getDeclaringClass().getName() ++ + '.' + _field.getName(), ++ e); ++ } ++ } ++ } ++ ++ final static class BooleanFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ BooleanFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ boolean value = _unsafe.getBoolean(obj, _offset); ++ ++ out.writeBoolean(value); ++ } ++ } ++ ++ final static class ByteFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ByteFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getByte(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class CharFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ CharFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ char value = _unsafe.getChar(obj, _offset); ++ ++ out.writeString(String.valueOf(value)); ++ } ++ } ++ ++ final static class ShortFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ShortFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getShort(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class IntFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ IntFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getInt(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class LongFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ LongFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ long value = _unsafe.getLong(obj, _offset); ++ ++ out.writeLong(value); ++ } ++ } ++ ++ final static class FloatFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ FloatFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ double value = _unsafe.getFloat(obj, _offset); ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ final static class DoubleFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DoubleFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ double value = _unsafe.getDouble(obj, _offset); ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ final static class StringFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ StringFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ String value = (String) _unsafe.getObject(obj, _offset); ++ ++ out.writeString(value); ++ } ++ } ++ ++ final static class DateFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DateFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ java.util.Date value ++ = (java.util.Date) _unsafe.getObject(obj, _offset); ++ ++ if (value == null) ++ out.writeNull(); ++ else ++ out.writeUTCDate(value.getTime()); ++ } ++ } ++ ++ static { ++ boolean isEnabled = false; ++ Unsafe unsafe = null; ++ ++ try { ++ Class unsafeClass = Class.forName("sun.misc.Unsafe"); ++ Field theUnsafe = null; ++ for (Field field : unsafeClass.getDeclaredFields()) { ++ if (field.getName().equals("theUnsafe")) ++ theUnsafe = field; ++ } ++ ++ if (theUnsafe != null) { ++ theUnsafe.setAccessible(true); ++ unsafe = (Unsafe) theUnsafe.get(null); ++ } ++ ++ isEnabled = unsafe != null; ++ ++ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); ++ ++ if ("false".equals(unsafeProp)) ++ isEnabled = false; ++ } catch (Throwable e) { ++ log.log(Level.ALL, e.toString(), e); ++ } ++ ++ _unsafe = unsafe; ++ _isEnabled = isEnabled; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/UnsafeUnsharedSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeUnsharedSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/UnsafeUnsharedSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeUnsharedSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,86 +1,86 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.ref.SoftReference; +-import java.lang.reflect.Field; +-import java.lang.reflect.Method; +-import java.lang.reflect.Modifier; +-import java.util.ArrayList; +-import java.util.WeakHashMap; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-/** +- * Serializing an object for known object types. +- */ +-public class UnsafeUnsharedSerializer extends UnsafeSerializer +-{ +- private static final Logger log +- = Logger.getLogger(UnsafeUnsharedSerializer.class.getName()); +- +- public UnsafeUnsharedSerializer(Class cl) +- { +- super(cl); +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- boolean oldUnshared = out.setUnshared(true); +- +- try { +- super.writeObject(obj, out); +- } finally { +- out.setUnshared(oldUnshared); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.ref.SoftReference; ++import java.lang.reflect.Field; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.WeakHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class UnsafeUnsharedSerializer extends UnsafeSerializer ++{ ++ private static final Logger log ++ = Logger.getLogger(UnsafeUnsharedSerializer.class.getName()); ++ ++ public UnsafeUnsharedSerializer(Class cl) ++ { ++ super(cl); ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ boolean oldUnshared = out.setUnshared(true); ++ ++ try { ++ super.writeObject(obj, out); ++ } finally { ++ out.setUnshared(oldUnshared); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ValueDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ValueDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/ValueDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/ValueDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,93 +1,93 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +- +-/** +- * Deserializing a string valued object +- */ +-abstract public class ValueDeserializer extends AbstractDeserializer { +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String initValue = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if (key.equals("value")) +- initValue = in.readString(); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- return create(initValue); +- } +- +- public Object readObject(AbstractHessianInput in, String []fieldNames) +- throws IOException +- { +- String initValue = null; +- +- for (int i = 0; i < fieldNames.length; i++) { +- if ("value".equals(fieldNames[i])) +- initValue = in.readString(); +- else +- in.readObject(); +- } +- +- return create(initValue); +- } +- +- abstract Object create(String value) +- throws IOException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++ ++/** ++ * Deserializing a string valued object ++ */ ++abstract public class ValueDeserializer extends AbstractDeserializer { ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String initValue = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("value")) ++ initValue = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ return create(initValue); ++ } ++ ++ public Object readObject(AbstractHessianInput in, String []fieldNames) ++ throws IOException ++ { ++ String initValue = null; ++ ++ for (int i = 0; i < fieldNames.length; i++) { ++ if ("value".equals(fieldNames[i])) ++ initValue = in.readString(); ++ else ++ in.readObject(); ++ } ++ ++ return create(initValue); ++ } ++ ++ abstract Object create(String value) ++ throws IOException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/WriteReplaceSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/WriteReplaceSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/WriteReplaceSerializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/WriteReplaceSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,193 +1,193 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.io; +- +-import java.io.IOException; +-import java.lang.reflect.InvocationTargetException; +-import java.lang.reflect.Method; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-/** +- * Serializing an object for known object types. +- */ +-public class WriteReplaceSerializer extends AbstractSerializer +-{ +- private static final Logger log +- = Logger.getLogger(WriteReplaceSerializer.class.getName()); +- +- private Object _writeReplaceFactory; +- private Method _writeReplace; +- private Serializer _baseSerializer; +- +- public WriteReplaceSerializer(Class cl, +- ClassLoader loader, +- Serializer baseSerializer) +- { +- introspectWriteReplace(cl, loader); +- +- _baseSerializer = baseSerializer; +- } +- +- private void introspectWriteReplace(Class cl, ClassLoader loader) +- { +- try { +- String className = cl.getName() + "HessianSerializer"; +- +- Class serializerClass = Class.forName(className, false, loader); +- +- Object serializerObject = serializerClass.newInstance(); +- +- Method writeReplace = getWriteReplace(serializerClass, cl); +- +- if (writeReplace != null) { +- _writeReplaceFactory = serializerObject; +- _writeReplace = writeReplace; +- } +- } catch (ClassNotFoundException e) { +- } catch (Exception e) { +- log.log(Level.FINER, e.toString(), e); +- } +- +- _writeReplace = getWriteReplace(cl); +- if (_writeReplace != null) +- _writeReplace.setAccessible(true); +- } +- +- /** +- * Returns the writeReplace method +- */ +- protected static Method getWriteReplace(Class cl, Class param) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- for (Method method : cl.getDeclaredMethods()) { +- if (method.getName().equals("writeReplace") +- && method.getParameterTypes().length == 1 +- && param.equals(method.getParameterTypes()[0])) +- return method; +- } +- } +- +- return null; +- } +- +- /** +- * Returns the writeReplace method +- */ +- protected static Method getWriteReplace(Class cl) +- { +- for (; cl != null; cl = cl.getSuperclass()) { +- Method []methods = cl.getDeclaredMethods(); +- +- for (int i = 0; i < methods.length; i++) { +- Method method = methods[i]; +- +- if (method.getName().equals("writeReplace") && +- method.getParameterTypes().length == 0) +- return method; +- } +- } +- +- return null; +- } +- +- @Override +- public void writeObject(Object obj, AbstractHessianOutput out) +- throws IOException +- { +- int ref = out.getRef(obj); +- +- if (ref >= 0) { +- out.writeRef(ref); +- +- return; +- } +- +- try { +- Object repl; +- +- repl = writeReplace(obj); +- +- if (obj == repl) { +- if (log.isLoggable(Level.FINE)) { +- log.fine(this + ": Hessian writeReplace error. The writeReplace method (" + _writeReplace + ") must not return the same object: " + obj); +- } +- +- _baseSerializer.writeObject(obj, out); +- +- return; +- } +- +- out.writeObject(repl); +- +- out.replaceRef(repl, obj); +- } catch (RuntimeException e) { +- throw e; +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- @Override +- protected Object writeReplace(Object obj) +- { +- try { +- if (_writeReplaceFactory != null) +- return _writeReplace.invoke(_writeReplaceFactory, obj); +- else +- return _writeReplace.invoke(obj); +- } catch (RuntimeException e) { +- throw e; +- } catch (InvocationTargetException e) { +- throw new RuntimeException(e.getCause()); +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++/** ++ * Serializing an object for known object types. ++ */ ++public class WriteReplaceSerializer extends AbstractSerializer ++{ ++ private static final Logger log ++ = Logger.getLogger(WriteReplaceSerializer.class.getName()); ++ ++ private Object _writeReplaceFactory; ++ private Method _writeReplace; ++ private Serializer _baseSerializer; ++ ++ public WriteReplaceSerializer(Class cl, ++ ClassLoader loader, ++ Serializer baseSerializer) ++ { ++ introspectWriteReplace(cl, loader); ++ ++ _baseSerializer = baseSerializer; ++ } ++ ++ private void introspectWriteReplace(Class cl, ClassLoader loader) ++ { ++ try { ++ String className = cl.getName() + "HessianSerializer"; ++ ++ Class serializerClass = Class.forName(className, false, loader); ++ ++ Object serializerObject = serializerClass.newInstance(); ++ ++ Method writeReplace = getWriteReplace(serializerClass, cl); ++ ++ if (writeReplace != null) { ++ _writeReplaceFactory = serializerObject; ++ _writeReplace = writeReplace; ++ } ++ } catch (ClassNotFoundException e) { ++ } catch (Exception e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _writeReplace = getWriteReplace(cl); ++ if (_writeReplace != null) ++ _writeReplace.setAccessible(true); ++ } ++ ++ /** ++ * Returns the writeReplace method ++ */ ++ protected static Method getWriteReplace(Class cl, Class param) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ for (Method method : cl.getDeclaredMethods()) { ++ if (method.getName().equals("writeReplace") ++ && method.getParameterTypes().length == 1 ++ && param.equals(method.getParameterTypes()[0])) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ /** ++ * Returns the writeReplace method ++ */ ++ protected static Method getWriteReplace(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("writeReplace") && ++ method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ int ref = out.getRef(obj); ++ ++ if (ref >= 0) { ++ out.writeRef(ref); ++ ++ return; ++ } ++ ++ try { ++ Object repl; ++ ++ repl = writeReplace(obj); ++ ++ if (obj == repl) { ++ if (log.isLoggable(Level.FINE)) { ++ log.fine(this + ": Hessian writeReplace error. The writeReplace method (" + _writeReplace + ") must not return the same object: " + obj); ++ } ++ ++ _baseSerializer.writeObject(obj, out); ++ ++ return; ++ } ++ ++ out.writeObject(repl); ++ ++ out.replaceRef(repl, obj); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ @Override ++ protected Object writeReplace(Object obj) ++ { ++ try { ++ if (_writeReplaceFactory != null) ++ return _writeReplace.invoke(_writeReplaceFactory, obj); ++ else ++ return _writeReplace.invoke(obj); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (InvocationTargetException e) { ++ throw new RuntimeException(e.getCause()); ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/JMXSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/jmx/JMXSerializerFactory.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/JMXSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/JMXSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,120 +1,120 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractSerializerFactory; +-import com.caucho.hessian.io.Deserializer; +-import com.caucho.hessian.io.HessianProtocolException; +-import com.caucho.hessian.io.Serializer; +-import com.caucho.hessian.io.StringValueDeserializer; +-import com.caucho.hessian.io.StringValueSerializer; +- +-import javax.management.*; +- +-/** +- * Serializers for JMX classes. +- */ +-public class JMXSerializerFactory extends AbstractSerializerFactory { +- /** +- * Returns the serializer for a class. +- * +- * @param cl the class of the object that needs to be serialized. +- * +- * @return a serializer object for the serialization. +- */ +- public Serializer getSerializer(Class cl) +- throws HessianProtocolException +- { +- if (ObjectName.class.equals(cl)) { +- return new StringValueSerializer(); +- } +- +- return null; +- } +- +- /** +- * Returns the deserializer for a class. +- * +- * @param cl the class of the object that needs to be deserialized. +- * +- * @return a deserializer object for the serialization. +- */ +- public Deserializer getDeserializer(Class cl) +- throws HessianProtocolException +- { +- if (ObjectName.class.equals(cl)) { +- return new StringValueDeserializer(cl); +- } +- else if (ObjectInstance.class.equals(cl)) { +- return new ObjectInstanceDeserializer(); +- } +- else if (MBeanAttributeInfo.class.isAssignableFrom(cl)) { +- return new MBeanAttributeInfoDeserializer(); +- } +- else if (MBeanConstructorInfo.class.isAssignableFrom(cl)) { +- return new MBeanConstructorInfoDeserializer(); +- } +- else if (MBeanOperationInfo.class.isAssignableFrom(cl)) { +- return new MBeanOperationInfoDeserializer(); +- } +- else if (MBeanParameterInfo.class.isAssignableFrom(cl)) { +- return new MBeanParameterInfoDeserializer(); +- } +- else if (MBeanNotificationInfo.class.isAssignableFrom(cl)) { +- return new MBeanNotificationInfoDeserializer(); +- } +- /* +- else if (MBeanInfo.class.equals(cl)) { +- return new MBeanInfoDeserializer(); +- } +- */ +- +- return null; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractSerializerFactory; ++import com.caucho.hessian.io.Deserializer; ++import com.caucho.hessian.io.HessianProtocolException; ++import com.caucho.hessian.io.Serializer; ++import com.caucho.hessian.io.StringValueDeserializer; ++import com.caucho.hessian.io.StringValueSerializer; ++ ++import javax.management.*; ++ ++/** ++ * Serializers for JMX classes. ++ */ ++public class JMXSerializerFactory extends AbstractSerializerFactory { ++ /** ++ * Returns the serializer for a class. ++ * ++ * @param cl the class of the object that needs to be serialized. ++ * ++ * @return a serializer object for the serialization. ++ */ ++ public Serializer getSerializer(Class cl) ++ throws HessianProtocolException ++ { ++ if (ObjectName.class.equals(cl)) { ++ return new StringValueSerializer(); ++ } ++ ++ return null; ++ } ++ ++ /** ++ * Returns the deserializer for a class. ++ * ++ * @param cl the class of the object that needs to be deserialized. ++ * ++ * @return a deserializer object for the serialization. ++ */ ++ public Deserializer getDeserializer(Class cl) ++ throws HessianProtocolException ++ { ++ if (ObjectName.class.equals(cl)) { ++ return new StringValueDeserializer(cl); ++ } ++ else if (ObjectInstance.class.equals(cl)) { ++ return new ObjectInstanceDeserializer(); ++ } ++ else if (MBeanAttributeInfo.class.isAssignableFrom(cl)) { ++ return new MBeanAttributeInfoDeserializer(); ++ } ++ else if (MBeanConstructorInfo.class.isAssignableFrom(cl)) { ++ return new MBeanConstructorInfoDeserializer(); ++ } ++ else if (MBeanOperationInfo.class.isAssignableFrom(cl)) { ++ return new MBeanOperationInfoDeserializer(); ++ } ++ else if (MBeanParameterInfo.class.isAssignableFrom(cl)) { ++ return new MBeanParameterInfoDeserializer(); ++ } ++ else if (MBeanNotificationInfo.class.isAssignableFrom(cl)) { ++ return new MBeanNotificationInfoDeserializer(); ++ } ++ /* ++ else if (MBeanInfo.class.equals(cl)) { ++ return new MBeanInfoDeserializer(); ++ } ++ */ ++ ++ return null; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,109 +1,109 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractDeserializer; +-import com.caucho.hessian.io.AbstractHessianInput; +- +-import javax.management.MBeanAttributeInfo; +-import java.io.IOException; +- +-/** +- * Deserializing an MBeanAttributeInfo valued object +- */ +-public class MBeanAttributeInfoDeserializer extends AbstractDeserializer { +- public Class getType() +- { +- return MBeanAttributeInfo.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String name = null; +- String type = null; +- String description = null; +- boolean isRead = false; +- boolean isWrite = false; +- boolean isIs = false; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if ("name".equals(key)) +- name = in.readString(); +- else if ("attributeType".equals(key)) +- type = in.readString(); +- else if ("description".equals(key)) +- description = in.readString(); +- else if ("isRead".equals(key)) +- isRead = in.readBoolean(); +- else if ("isWrite".equals(key)) +- isWrite = in.readBoolean(); +- else if ("is".equals(key)) +- isIs = in.readBoolean(); +- else { +- in.readObject(); +- } +- } +- +- in.readMapEnd(); +- +- try { +- MBeanAttributeInfo info; +- +- info = new MBeanAttributeInfo(name, type, description, +- isRead, isWrite, isIs); +- +- return info; +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import javax.management.MBeanAttributeInfo; ++import java.io.IOException; ++ ++/** ++ * Deserializing an MBeanAttributeInfo valued object ++ */ ++public class MBeanAttributeInfoDeserializer extends AbstractDeserializer { ++ public Class getType() ++ { ++ return MBeanAttributeInfo.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String name = null; ++ String type = null; ++ String description = null; ++ boolean isRead = false; ++ boolean isWrite = false; ++ boolean isIs = false; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if ("name".equals(key)) ++ name = in.readString(); ++ else if ("attributeType".equals(key)) ++ type = in.readString(); ++ else if ("description".equals(key)) ++ description = in.readString(); ++ else if ("isRead".equals(key)) ++ isRead = in.readBoolean(); ++ else if ("isWrite".equals(key)) ++ isWrite = in.readBoolean(); ++ else if ("is".equals(key)) ++ isIs = in.readBoolean(); ++ else { ++ in.readObject(); ++ } ++ } ++ ++ in.readMapEnd(); ++ ++ try { ++ MBeanAttributeInfo info; ++ ++ info = new MBeanAttributeInfo(name, type, description, ++ isRead, isWrite, isIs); ++ ++ return info; ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,100 +1,100 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractDeserializer; +-import com.caucho.hessian.io.AbstractHessianInput; +- +-import javax.management.MBeanConstructorInfo; +-import javax.management.MBeanParameterInfo; +-import java.io.IOException; +- +-/** +- * Deserializing an MBeanConstructorInfo valued object +- */ +-public class MBeanConstructorInfoDeserializer extends AbstractDeserializer { +- public Class getType() +- { +- return MBeanConstructorInfo.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String name = null; +- String description = null; +- MBeanParameterInfo []sig = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if ("name".equals(key)) +- name = in.readString(); +- else if ("description".equals(key)) +- description = in.readString(); +- else if ("signature".equals(key)) +- sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); +- else { +- in.readObject(); +- } +- } +- +- in.readMapEnd(); +- +- try { +- MBeanConstructorInfo info; +- +- info = new MBeanConstructorInfo(name, description, sig); +- +- return info; +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import javax.management.MBeanConstructorInfo; ++import javax.management.MBeanParameterInfo; ++import java.io.IOException; ++ ++/** ++ * Deserializing an MBeanConstructorInfo valued object ++ */ ++public class MBeanConstructorInfoDeserializer extends AbstractDeserializer { ++ public Class getType() ++ { ++ return MBeanConstructorInfo.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String name = null; ++ String description = null; ++ MBeanParameterInfo []sig = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if ("name".equals(key)) ++ name = in.readString(); ++ else if ("description".equals(key)) ++ description = in.readString(); ++ else if ("signature".equals(key)) ++ sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); ++ else { ++ in.readObject(); ++ } ++ } ++ ++ in.readMapEnd(); ++ ++ try { ++ MBeanConstructorInfo info; ++ ++ info = new MBeanConstructorInfo(name, description, sig); ++ ++ return info; ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanInfoDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,113 +1,113 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractDeserializer; +-import com.caucho.hessian.io.AbstractHessianInput; +- +-import javax.management.MBeanAttributeInfo; +-import javax.management.MBeanConstructorInfo; +-import javax.management.MBeanInfo; +-import javax.management.MBeanNotificationInfo; +-import javax.management.MBeanOperationInfo; +-import java.io.IOException; +- +-/** +- * Deserializing an MBeanInfo valued object +- */ +-public class MBeanInfoDeserializer extends AbstractDeserializer { +- public Class getType() +- { +- return MBeanInfo.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String className = null; +- String description = null; +- MBeanAttributeInfo []attributes = null; +- MBeanConstructorInfo []constructors = null; +- MBeanOperationInfo []operations = null; +- MBeanNotificationInfo []notifications = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if ("className".equals(key)) +- className = in.readString(); +- else if ("description".equals(key)) +- description = in.readString(); +- else if ("attributes".equals(key)) { +- attributes = (MBeanAttributeInfo []) in.readObject(MBeanAttributeInfo[].class); +- } +- /* +- else if ("isWrite".equals(key)) +- isWrite = in.readBoolean(); +- else if ("isIs".equals(key)) +- isIs = in.readBoolean(); +- */ +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- try { +- MBeanInfo info; +- +- info = new MBeanInfo(className, description, attributes, +- constructors, operations, notifications); +- +- return info; +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import javax.management.MBeanAttributeInfo; ++import javax.management.MBeanConstructorInfo; ++import javax.management.MBeanInfo; ++import javax.management.MBeanNotificationInfo; ++import javax.management.MBeanOperationInfo; ++import java.io.IOException; ++ ++/** ++ * Deserializing an MBeanInfo valued object ++ */ ++public class MBeanInfoDeserializer extends AbstractDeserializer { ++ public Class getType() ++ { ++ return MBeanInfo.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String className = null; ++ String description = null; ++ MBeanAttributeInfo []attributes = null; ++ MBeanConstructorInfo []constructors = null; ++ MBeanOperationInfo []operations = null; ++ MBeanNotificationInfo []notifications = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if ("className".equals(key)) ++ className = in.readString(); ++ else if ("description".equals(key)) ++ description = in.readString(); ++ else if ("attributes".equals(key)) { ++ attributes = (MBeanAttributeInfo []) in.readObject(MBeanAttributeInfo[].class); ++ } ++ /* ++ else if ("isWrite".equals(key)) ++ isWrite = in.readBoolean(); ++ else if ("isIs".equals(key)) ++ isIs = in.readBoolean(); ++ */ ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ try { ++ MBeanInfo info; ++ ++ info = new MBeanInfo(className, description, attributes, ++ constructors, operations, notifications); ++ ++ return info; ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,99 +1,99 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractDeserializer; +-import com.caucho.hessian.io.AbstractHessianInput; +- +-import javax.management.MBeanNotificationInfo; +-import java.io.IOException; +- +-/** +- * Deserializing an MBeanNotificationInfo valued object +- */ +-public class MBeanNotificationInfoDeserializer extends AbstractDeserializer { +- public Class getType() +- { +- return MBeanNotificationInfo.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String name = null; +- String description = null; +- String []types = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if ("name".equals(key)) +- name = in.readString(); +- else if ("description".equals(key)) +- description = in.readString(); +- else if ("types".equals(key)) +- types = (String[]) in.readObject(String[].class); +- else { +- in.readObject(); +- } +- } +- +- in.readMapEnd(); +- +- try { +- MBeanNotificationInfo info; +- +- info = new MBeanNotificationInfo(types, name, description); +- +- return info; +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import javax.management.MBeanNotificationInfo; ++import java.io.IOException; ++ ++/** ++ * Deserializing an MBeanNotificationInfo valued object ++ */ ++public class MBeanNotificationInfoDeserializer extends AbstractDeserializer { ++ public Class getType() ++ { ++ return MBeanNotificationInfo.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String name = null; ++ String description = null; ++ String []types = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if ("name".equals(key)) ++ name = in.readString(); ++ else if ("description".equals(key)) ++ description = in.readString(); ++ else if ("types".equals(key)) ++ types = (String[]) in.readObject(String[].class); ++ else { ++ in.readObject(); ++ } ++ } ++ ++ in.readMapEnd(); ++ ++ try { ++ MBeanNotificationInfo info; ++ ++ info = new MBeanNotificationInfo(types, name, description); ++ ++ return info; ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,107 +1,107 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractDeserializer; +-import com.caucho.hessian.io.AbstractHessianInput; +- +-import javax.management.MBeanOperationInfo; +-import javax.management.MBeanParameterInfo; +-import java.io.IOException; +- +-/** +- * Deserializing an MBeanOperationInfo valued object +- */ +-public class MBeanOperationInfoDeserializer extends AbstractDeserializer { +- public Class getType() +- { +- return MBeanOperationInfo.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String name = null; +- String type = null; +- String description = null; +- MBeanParameterInfo []sig = null; +- int impact = 0; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if ("name".equals(key)) +- name = in.readString(); +- else if ("description".equals(key)) +- description = in.readString(); +- else if ("type".equals(key)) +- type = in.readString(); +- else if ("impact".equals(key)) +- impact = in.readInt(); +- else if ("signature".equals(key)) { +- sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); +- } +- else { +- in.readObject(); +- } +- } +- +- in.readMapEnd(); +- +- try { +- MBeanOperationInfo info; +- +- info = new MBeanOperationInfo(name, description, sig, type, impact); +- +- return info; +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import javax.management.MBeanOperationInfo; ++import javax.management.MBeanParameterInfo; ++import java.io.IOException; ++ ++/** ++ * Deserializing an MBeanOperationInfo valued object ++ */ ++public class MBeanOperationInfoDeserializer extends AbstractDeserializer { ++ public Class getType() ++ { ++ return MBeanOperationInfo.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String name = null; ++ String type = null; ++ String description = null; ++ MBeanParameterInfo []sig = null; ++ int impact = 0; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if ("name".equals(key)) ++ name = in.readString(); ++ else if ("description".equals(key)) ++ description = in.readString(); ++ else if ("type".equals(key)) ++ type = in.readString(); ++ else if ("impact".equals(key)) ++ impact = in.readInt(); ++ else if ("signature".equals(key)) { ++ sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); ++ } ++ else { ++ in.readObject(); ++ } ++ } ++ ++ in.readMapEnd(); ++ ++ try { ++ MBeanOperationInfo info; ++ ++ info = new MBeanOperationInfo(name, description, sig, type, impact); ++ ++ return info; ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,102 +1,102 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractDeserializer; +-import com.caucho.hessian.io.AbstractHessianInput; +- +-import javax.management.MBeanParameterInfo; +-import java.io.IOException; +- +-/** +- * Deserializing an MBeanParameterInfo valued object +- */ +-public class MBeanParameterInfoDeserializer extends AbstractDeserializer { +- public Class getType() +- { +- return MBeanParameterInfo.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String name = null; +- String type = null; +- String description = null; +- boolean isRead = false; +- boolean isWrite = false; +- boolean isIs = false; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if ("name".equals(key)) +- name = in.readString(); +- else if ("type".equals(key)) +- type = in.readString(); +- else if ("description".equals(key)) +- description = in.readString(); +- else { +- in.readObject(); +- } +- } +- +- in.readMapEnd(); +- +- try { +- MBeanParameterInfo info; +- +- info = new MBeanParameterInfo(name, type, description); +- +- return info; +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import javax.management.MBeanParameterInfo; ++import java.io.IOException; ++ ++/** ++ * Deserializing an MBeanParameterInfo valued object ++ */ ++public class MBeanParameterInfoDeserializer extends AbstractDeserializer { ++ public Class getType() ++ { ++ return MBeanParameterInfo.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String name = null; ++ String type = null; ++ String description = null; ++ boolean isRead = false; ++ boolean isWrite = false; ++ boolean isIs = false; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if ("name".equals(key)) ++ name = in.readString(); ++ else if ("type".equals(key)) ++ type = in.readString(); ++ else if ("description".equals(key)) ++ description = in.readString(); ++ else { ++ in.readObject(); ++ } ++ } ++ ++ in.readMapEnd(); ++ ++ try { ++ MBeanParameterInfo info; ++ ++ info = new MBeanParameterInfo(name, type, description); ++ ++ return info; ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,94 +1,94 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.jmx; +- +-import com.caucho.hessian.io.AbstractDeserializer; +-import com.caucho.hessian.io.AbstractHessianInput; +- +-import javax.management.ObjectInstance; +-import javax.management.ObjectName; +-import java.io.IOException; +- +-/** +- * Deserializing an ObjectInstance valued object +- */ +-public class ObjectInstanceDeserializer extends AbstractDeserializer { +- public Class getType() +- { +- return ObjectInstance.class; +- } +- +- public Object readMap(AbstractHessianInput in) +- throws IOException +- { +- String className = null; +- ObjectName objectName = null; +- +- String initValue = null; +- +- while (! in.isEnd()) { +- String key = in.readString(); +- +- if ("className".equals(key)) +- className = in.readString(); +- else if ("name".equals(key)) +- objectName = (ObjectName) in.readObject(ObjectName.class); +- else +- in.readObject(); +- } +- +- in.readMapEnd(); +- +- try { +- return new ObjectInstance(objectName, className); +- } catch (Exception e) { +- throw new IOException(String.valueOf(e)); +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.jmx; ++ ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import javax.management.ObjectInstance; ++import javax.management.ObjectName; ++import java.io.IOException; ++ ++/** ++ * Deserializing an ObjectInstance valued object ++ */ ++public class ObjectInstanceDeserializer extends AbstractDeserializer { ++ public Class getType() ++ { ++ return ObjectInstance.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ String className = null; ++ ObjectName objectName = null; ++ ++ String initValue = null; ++ ++ while (! in.isEnd()) { ++ String key = in.readString(); ++ ++ if ("className".equals(key)) ++ className = in.readString(); ++ else if ("name".equals(key)) ++ objectName = (ObjectName) in.readObject(ObjectName.class); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ try { ++ return new ObjectInstance(objectName, className); ++ } catch (Exception e) { ++ throw new IOException(String.valueOf(e)); ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianInput.java hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianInput.java +--- hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianInput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianInput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,456 +1,456 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.micro; +- +-import java.io.ByteArrayOutputStream; +-import java.io.IOException; +-import java.io.InputStream; +-import java.util.Date; +- +-/** +- * Input stream for Hessian requests, compatible with microedition +- * Java. It only uses classes and types available to J2ME. In +- * particular, it does not have any support for the <double> type. +- * +- *

MicroHessianInput does not depend on any classes other than +- * in J2ME, so it can be extracted independently into a smaller package. +- * +- *

MicroHessianInput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * InputStream is = ...; // from http connection
+- * MicroHessianInput in = new MicroHessianInput(is);
+- * String value;
+- *
+- * in.startReply();         // read reply header
+- * value = in.readString(); // read string value
+- * in.completeReply();      // read reply footer
+- * 
+- */ +-public class MicroHessianInput { +- protected InputStream is; +- /** +- * Creates a new Hessian input stream, initialized with an +- * underlying input stream. +- * +- * @param is the underlying input stream. +- */ +- public MicroHessianInput(InputStream is) +- { +- init(is); +- } +- +- /** +- * Creates an uninitialized Hessian input stream. +- */ +- public MicroHessianInput() +- { +- } +- +- /** +- * Initialize the hessian stream with the underlying input stream. +- */ +- public void init(InputStream is) +- { +- this.is = is; +- } +- +- /** +- * Starts reading the reply +- * +- *

A successful completion will have a single value: +- * +- *

+-   * r x01 x00
+-   * 
+- */ +- public void startReply() +- throws IOException +- { +- int tag = is.read(); +- +- if (tag != 'r') +- protocolException("expected hessian reply"); +- +- int major = is.read(); +- int minor = is.read(); +- } +- +- /** +- * Completes reading the call +- * +- *

A successful completion will have a single value: +- * +- *

+-   * z
+-   * 
+- */ +- public void completeReply() +- throws IOException +- { +- int tag = is.read(); +- +- if (tag != 'z') +- protocolException("expected end of reply"); +- } +- +- /** +- * Reads a boolean +- * +- *
+-   * T
+-   * F
+-   * 
+- */ +- public boolean readBoolean() +- throws IOException +- { +- int tag = is.read(); +- +- switch (tag) { +- case 'T': return true; +- case 'F': return false; +- default: +- throw expect("boolean", tag); +- } +- } +- +- /** +- * Reads an integer +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- */ +- public int readInt() +- throws IOException +- { +- int tag = is.read(); +- +- if (tag != 'I') +- throw expect("integer", tag); +- +- int b32 = is.read(); +- int b24 = is.read(); +- int b16 = is.read(); +- int b8 = is.read(); +- +- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; +- } +- +- /** +- * Reads a long +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public long readLong() +- throws IOException +- { +- int tag = is.read(); +- +- if (tag != 'L') +- throw protocolException("expected long"); +- +- long b64 = is.read(); +- long b56 = is.read(); +- long b48 = is.read(); +- long b40 = is.read(); +- long b32 = is.read(); +- long b24 = is.read(); +- long b16 = is.read(); +- long b8 = is.read(); +- +- return ((b64 << 56) + +- (b56 << 48) + +- (b48 << 40) + +- (b40 << 32) + +- (b32 << 24) + +- (b24 << 16) + +- (b16 << 8) + +- b8); +- } +- +- /** +- * Reads a date. +- * +- *
+-   * T b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- */ +- public long readUTCDate() +- throws IOException +- { +- int tag = is.read(); +- +- if (tag != 'd') +- throw protocolException("expected date"); +- +- long b64 = is.read(); +- long b56 = is.read(); +- long b48 = is.read(); +- long b40 = is.read(); +- long b32 = is.read(); +- long b24 = is.read(); +- long b16 = is.read(); +- long b8 = is.read(); +- +- return ((b64 << 56) + +- (b56 << 48) + +- (b48 << 40) + +- (b40 << 32) + +- (b32 << 24) + +- (b24 << 16) + +- (b16 << 8) + +- b8); +- } +- +- /** +- * Reads a string +- * +- *
+-   * S b16 b8 string value
+-   * 
+- */ +- public String readString() +- throws IOException +- { +- int tag = is.read(); +- +- if (tag == 'N') +- return null; +- +- if (tag != 'S') +- throw expect("string", tag); +- +- int b16 = is.read(); +- int b8 = is.read(); +- +- int len = (b16 << 8) + b8; +- +- return readStringImpl(len); +- } +- +- /** +- * Reads a byte array +- * +- *
+-   * B b16 b8 data value
+-   * 
+- */ +- public byte []readBytes() +- throws IOException +- { +- int tag = is.read(); +- +- if (tag == 'N') +- return null; +- +- if (tag != 'B') +- throw expect("bytes", tag); +- +- int b16 = is.read(); +- int b8 = is.read(); +- +- int len = (b16 << 8) + b8; +- +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- for (int i = 0; i < len; i++) +- bos.write(is.read()); +- +- return bos.toByteArray(); +- } +- +- /** +- * Reads an arbitrary object the input stream. +- */ +- public Object readObject(Class expectedClass) +- throws IOException +- { +- int tag = is.read(); +- +- switch (tag) { +- case 'N': +- return null; +- +- case 'T': +- return new Boolean(true); +- +- case 'F': +- return new Boolean(false); +- +- case 'I': { +- int b32 = is.read(); +- int b24 = is.read(); +- int b16 = is.read(); +- int b8 = is.read(); +- +- return new Integer((b32 << 24) + (b24 << 16) + (b16 << 8) + b8); +- } +- +- case 'L': { +- long b64 = is.read(); +- long b56 = is.read(); +- long b48 = is.read(); +- long b40 = is.read(); +- long b32 = is.read(); +- long b24 = is.read(); +- long b16 = is.read(); +- long b8 = is.read(); +- +- return new Long((b64 << 56) + +- (b56 << 48) + +- (b48 << 40) + +- (b40 << 32) + +- (b32 << 24) + +- (b24 << 16) + +- (b16 << 8) + +- b8); +- } +- +- case 'd': { +- long b64 = is.read(); +- long b56 = is.read(); +- long b48 = is.read(); +- long b40 = is.read(); +- long b32 = is.read(); +- long b24 = is.read(); +- long b16 = is.read(); +- long b8 = is.read(); +- +- return new Date((b64 << 56) + +- (b56 << 48) + +- (b48 << 40) + +- (b40 << 32) + +- (b32 << 24) + +- (b24 << 16) + +- (b16 << 8) + +- b8); +- } +- +- case 'S': +- case 'X': { +- int b16 = is.read(); +- int b8 = is.read(); +- +- int len = (b16 << 8) + b8; +- +- return readStringImpl(len); +- } +- +- case 'B': { +- if (tag != 'B') +- throw expect("bytes", tag); +- +- int b16 = is.read(); +- int b8 = is.read(); +- +- int len = (b16 << 8) + b8; +- +- ByteArrayOutputStream bos = new ByteArrayOutputStream(); +- +- for (int i = 0; i < len; i++) +- bos.write(is.read()); +- +- return bos.toByteArray(); +- } +- default: +- throw new IOException("unknown code:" + (char) tag); +- } +- } +- +- /** +- * Reads a string from the underlying stream. +- */ +- protected String readStringImpl(int length) +- throws IOException +- { +- StringBuffer sb = new StringBuffer(); +- +- for (int i = 0; i < length; i++) { +- int ch = is.read(); +- +- if (ch < 0x80) +- sb.append((char) ch); +- else if ((ch & 0xe0) == 0xc0) { +- int ch1 = is.read(); +- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); +- +- sb.append((char) v); +- } +- else if ((ch & 0xf0) == 0xe0) { +- int ch1 = is.read(); +- int ch2 = is.read(); +- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); +- +- sb.append((char) v); +- } +- else +- throw new IOException("bad utf-8 encoding"); +- } +- +- return sb.toString(); +- } +- +- protected IOException expect(String expect, int ch) +- { +- if (ch < 0) +- return protocolException("expected " + expect + " at end of file"); +- else +- return protocolException("expected " + expect + " at " + (char) ch); +- } +- +- protected IOException protocolException(String message) +- { +- return new IOException(message); +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.micro; ++ ++import java.io.ByteArrayOutputStream; ++import java.io.IOException; ++import java.io.InputStream; ++import java.util.Date; ++ ++/** ++ * Input stream for Hessian requests, compatible with microedition ++ * Java. It only uses classes and types available to J2ME. In ++ * particular, it does not have any support for the <double> type. ++ * ++ *

MicroHessianInput does not depend on any classes other than ++ * in J2ME, so it can be extracted independently into a smaller package. ++ * ++ *

MicroHessianInput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * InputStream is = ...; // from http connection
++ * MicroHessianInput in = new MicroHessianInput(is);
++ * String value;
++ *
++ * in.startReply();         // read reply header
++ * value = in.readString(); // read string value
++ * in.completeReply();      // read reply footer
++ * 
++ */ ++public class MicroHessianInput { ++ protected InputStream is; ++ /** ++ * Creates a new Hessian input stream, initialized with an ++ * underlying input stream. ++ * ++ * @param is the underlying input stream. ++ */ ++ public MicroHessianInput(InputStream is) ++ { ++ init(is); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian input stream. ++ */ ++ public MicroHessianInput() ++ { ++ } ++ ++ /** ++ * Initialize the hessian stream with the underlying input stream. ++ */ ++ public void init(InputStream is) ++ { ++ this.is = is; ++ } ++ ++ /** ++ * Starts reading the reply ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * r x01 x00
++   * 
++ */ ++ public void startReply() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ if (tag != 'r') ++ protocolException("expected hessian reply"); ++ ++ int major = is.read(); ++ int minor = is.read(); ++ } ++ ++ /** ++ * Completes reading the call ++ * ++ *

A successful completion will have a single value: ++ * ++ *

++   * z
++   * 
++ */ ++ public void completeReply() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ if (tag != 'z') ++ protocolException("expected end of reply"); ++ } ++ ++ /** ++ * Reads a boolean ++ * ++ *
++   * T
++   * F
++   * 
++ */ ++ public boolean readBoolean() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ switch (tag) { ++ case 'T': return true; ++ case 'F': return false; ++ default: ++ throw expect("boolean", tag); ++ } ++ } ++ ++ /** ++ * Reads an integer ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ */ ++ public int readInt() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ if (tag != 'I') ++ throw expect("integer", tag); ++ ++ int b32 = is.read(); ++ int b24 = is.read(); ++ int b16 = is.read(); ++ int b8 = is.read(); ++ ++ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; ++ } ++ ++ /** ++ * Reads a long ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public long readLong() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ if (tag != 'L') ++ throw protocolException("expected long"); ++ ++ long b64 = is.read(); ++ long b56 = is.read(); ++ long b48 = is.read(); ++ long b40 = is.read(); ++ long b32 = is.read(); ++ long b24 = is.read(); ++ long b16 = is.read(); ++ long b8 = is.read(); ++ ++ return ((b64 << 56) + ++ (b56 << 48) + ++ (b48 << 40) + ++ (b40 << 32) + ++ (b32 << 24) + ++ (b24 << 16) + ++ (b16 << 8) + ++ b8); ++ } ++ ++ /** ++ * Reads a date. ++ * ++ *
++   * T b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ */ ++ public long readUTCDate() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ if (tag != 'd') ++ throw protocolException("expected date"); ++ ++ long b64 = is.read(); ++ long b56 = is.read(); ++ long b48 = is.read(); ++ long b40 = is.read(); ++ long b32 = is.read(); ++ long b24 = is.read(); ++ long b16 = is.read(); ++ long b8 = is.read(); ++ ++ return ((b64 << 56) + ++ (b56 << 48) + ++ (b48 << 40) + ++ (b40 << 32) + ++ (b32 << 24) + ++ (b24 << 16) + ++ (b16 << 8) + ++ b8); ++ } ++ ++ /** ++ * Reads a string ++ * ++ *
++   * S b16 b8 string value
++   * 
++ */ ++ public String readString() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ if (tag == 'N') ++ return null; ++ ++ if (tag != 'S') ++ throw expect("string", tag); ++ ++ int b16 = is.read(); ++ int b8 = is.read(); ++ ++ int len = (b16 << 8) + b8; ++ ++ return readStringImpl(len); ++ } ++ ++ /** ++ * Reads a byte array ++ * ++ *
++   * B b16 b8 data value
++   * 
++ */ ++ public byte []readBytes() ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ if (tag == 'N') ++ return null; ++ ++ if (tag != 'B') ++ throw expect("bytes", tag); ++ ++ int b16 = is.read(); ++ int b8 = is.read(); ++ ++ int len = (b16 << 8) + b8; ++ ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ for (int i = 0; i < len; i++) ++ bos.write(is.read()); ++ ++ return bos.toByteArray(); ++ } ++ ++ /** ++ * Reads an arbitrary object the input stream. ++ */ ++ public Object readObject(Class expectedClass) ++ throws IOException ++ { ++ int tag = is.read(); ++ ++ switch (tag) { ++ case 'N': ++ return null; ++ ++ case 'T': ++ return new Boolean(true); ++ ++ case 'F': ++ return new Boolean(false); ++ ++ case 'I': { ++ int b32 = is.read(); ++ int b24 = is.read(); ++ int b16 = is.read(); ++ int b8 = is.read(); ++ ++ return new Integer((b32 << 24) + (b24 << 16) + (b16 << 8) + b8); ++ } ++ ++ case 'L': { ++ long b64 = is.read(); ++ long b56 = is.read(); ++ long b48 = is.read(); ++ long b40 = is.read(); ++ long b32 = is.read(); ++ long b24 = is.read(); ++ long b16 = is.read(); ++ long b8 = is.read(); ++ ++ return new Long((b64 << 56) + ++ (b56 << 48) + ++ (b48 << 40) + ++ (b40 << 32) + ++ (b32 << 24) + ++ (b24 << 16) + ++ (b16 << 8) + ++ b8); ++ } ++ ++ case 'd': { ++ long b64 = is.read(); ++ long b56 = is.read(); ++ long b48 = is.read(); ++ long b40 = is.read(); ++ long b32 = is.read(); ++ long b24 = is.read(); ++ long b16 = is.read(); ++ long b8 = is.read(); ++ ++ return new Date((b64 << 56) + ++ (b56 << 48) + ++ (b48 << 40) + ++ (b40 << 32) + ++ (b32 << 24) + ++ (b24 << 16) + ++ (b16 << 8) + ++ b8); ++ } ++ ++ case 'S': ++ case 'X': { ++ int b16 = is.read(); ++ int b8 = is.read(); ++ ++ int len = (b16 << 8) + b8; ++ ++ return readStringImpl(len); ++ } ++ ++ case 'B': { ++ if (tag != 'B') ++ throw expect("bytes", tag); ++ ++ int b16 = is.read(); ++ int b8 = is.read(); ++ ++ int len = (b16 << 8) + b8; ++ ++ ByteArrayOutputStream bos = new ByteArrayOutputStream(); ++ ++ for (int i = 0; i < len; i++) ++ bos.write(is.read()); ++ ++ return bos.toByteArray(); ++ } ++ default: ++ throw new IOException("unknown code:" + (char) tag); ++ } ++ } ++ ++ /** ++ * Reads a string from the underlying stream. ++ */ ++ protected String readStringImpl(int length) ++ throws IOException ++ { ++ StringBuffer sb = new StringBuffer(); ++ ++ for (int i = 0; i < length; i++) { ++ int ch = is.read(); ++ ++ if (ch < 0x80) ++ sb.append((char) ch); ++ else if ((ch & 0xe0) == 0xc0) { ++ int ch1 = is.read(); ++ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); ++ ++ sb.append((char) v); ++ } ++ else if ((ch & 0xf0) == 0xe0) { ++ int ch1 = is.read(); ++ int ch2 = is.read(); ++ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); ++ ++ sb.append((char) v); ++ } ++ else ++ throw new IOException("bad utf-8 encoding"); ++ } ++ ++ return sb.toString(); ++ } ++ ++ protected IOException expect(String expect, int ch) ++ { ++ if (ch < 0) ++ return protocolException("expected " + expect + " at end of file"); ++ else ++ return protocolException("expected " + expect + " at " + (char) ch); ++ } ++ ++ protected IOException protocolException(String message) ++ { ++ return new IOException(message); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianOutput.java hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianOutput.java +--- hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianOutput.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianOutput.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,550 +1,550 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.micro; +- +-import java.io.IOException; +-import java.io.OutputStream; +-import java.util.Date; +-import java.util.Enumeration; +-import java.util.Hashtable; +-import java.util.Vector; +- +-/** +- * Output stream for Hessian requests, compatible with microedition +- * Java. It only uses classes and types available to J2ME. In +- * particular, it does not have any support for the <double> type. +- * +- *

MicroHessianOutput does not depend on any classes other than +- * in J2ME, so it can be extracted independently into a smaller package. +- * +- *

MicroHessianOutput is unbuffered, so any client needs to provide +- * its own buffering. +- * +- *

+- * OutputStream os = ...; // from http connection
+- * MicroHessianOutput out = new MicroHessianOutput(os);
+- * String value;
+- *
+- * out.startCall("hello");  // start hello call
+- * out.writeString("arg1"); // write a string argument
+- * out.completeCall();      // complete the call
+- * 
+- */ +-public class MicroHessianOutput { +- protected OutputStream os; +- +- /** +- * Creates a new Hessian output stream, initialized with an +- * underlying output stream. +- * +- * @param os the underlying output stream. +- */ +- public MicroHessianOutput(OutputStream os) +- { +- init(os); +- } +- +- /** +- * Creates an uninitialized Hessian output stream. +- */ +- public MicroHessianOutput() +- { +- } +- +- public void init(OutputStream os) +- { +- this.os = os; +- } +- +- /** +- * Writes the method call: +- * +- *
+-   * c major minor
+-   * m b16 b8 method-namek
+-   * 
+- * +- * @param method the method name to call. +- */ +- public void startCall(String method) +- throws IOException +- { +- os.write('c'); +- os.write(0); +- os.write(1); +- +- os.write('m'); +- int len = method.length(); +- os.write(len >> 8); +- os.write(len); +- printString(method, 0, len); +- } +- +- /** +- * Writes the method call: +- * +- *
+-   * z
+-   * 
+- */ +- public void completeCall() +- throws IOException +- { +- os.write('z'); +- } +- +- /** +- * Writes a boolean value to the stream. The boolean will be written +- * with the following syntax: +- * +- *
+-   * T
+-   * F
+-   * 
+- * +- * @param value the boolean value to write. +- */ +- public void writeBoolean(boolean value) +- throws IOException +- { +- if (value) +- os.write('T'); +- else +- os.write('F'); +- } +- +- /** +- * Writes an integer value to the stream. The integer will be written +- * with the following syntax: +- * +- *
+-   * I b32 b24 b16 b8
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeInt(int value) +- throws IOException +- { +- os.write('I'); +- os.write(value >> 24); +- os.write(value >> 16); +- os.write(value >> 8); +- os.write(value); +- } +- +- /** +- * Writes a long value to the stream. The long will be written +- * with the following syntax: +- * +- *
+-   * L b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param value the long value to write. +- */ +- public void writeLong(long value) +- throws IOException +- { +- os.write('L'); +- os.write((byte) (value >> 56)); +- os.write((byte) (value >> 48)); +- os.write((byte) (value >> 40)); +- os.write((byte) (value >> 32)); +- os.write((byte) (value >> 24)); +- os.write((byte) (value >> 16)); +- os.write((byte) (value >> 8)); +- os.write((byte) (value)); +- } +- +- /** +- * Writes a date to the stream. +- * +- *
+-   * T  b64 b56 b48 b40 b32 b24 b16 b8
+-   * 
+- * +- * @param time the date in milliseconds from the epoch in UTC +- */ +- public void writeUTCDate(long time) +- throws IOException +- { +- os.write('d'); +- os.write((byte) (time >> 56)); +- os.write((byte) (time >> 48)); +- os.write((byte) (time >> 40)); +- os.write((byte) (time >> 32)); +- os.write((byte) (time >> 24)); +- os.write((byte) (time >> 16)); +- os.write((byte) (time >> 8)); +- os.write((byte) (time)); +- } +- +- /** +- * Writes a null value to the stream. +- * The null will be written with the following syntax +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeNull() +- throws IOException +- { +- os.write('N'); +- } +- +- /** +- * Writes a string value to the stream using UTF-8 encoding. +- * The string will be written with the following syntax: +- * +- *
+-   * S b16 b8 string-value
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeString(String value) +- throws IOException +- { +- if (value == null) { +- os.write('N'); +- } +- else { +- int len = value.length(); +- +- os.write('S'); +- os.write(len >> 8); +- os.write(len); +- +- printString(value); +- } +- } +- +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer) +- throws IOException +- { +- if (buffer == null) +- os.write('N'); +- else +- writeBytes(buffer, 0, buffer.length); +- } +- /** +- * Writes a byte array to the stream. +- * The array will be written with the following syntax: +- * +- *
+-   * B b16 b18 bytes
+-   * 
+- * +- * If the value is null, it will be written as +- * +- *
+-   * N
+-   * 
+- * +- * @param value the string value to write. +- */ +- public void writeBytes(byte []buffer, int offset, int length) +- throws IOException +- { +- if (buffer == null) { +- os.write('N'); +- } +- else { +- os.write('B'); +- os.write(length << 8); +- os.write(length); +- os.write(buffer, offset, length); +- } +- } +- +- /** +- * Writes a reference. +- * +- *
+-   * R b32 b24 b16 b8
+-   * 
+- * +- * @param value the integer value to write. +- */ +- public void writeRef(int value) +- throws IOException +- { +- os.write('R'); +- os.write(value << 24); +- os.write(value << 16); +- os.write(value << 8); +- os.write(value); +- } +- +- /** +- * Writes a generic object to the output stream. +- */ +- public void writeObject(Object object) +- throws IOException +- { +- if (object == null) +- writeNull(); +- else if (object instanceof String) +- writeString((String) object); +- else if (object instanceof Boolean) +- writeBoolean(((Boolean) object).booleanValue()); +- else if (object instanceof Integer) +- writeInt(((Integer) object).intValue()); +- else if (object instanceof Long) +- writeLong(((Long) object).longValue()); +- else if (object instanceof Date) +- writeUTCDate(((Date) object).getTime()); +- else if (object instanceof byte[]) { +- byte []data = (byte []) object; +- writeBytes(data, 0, data.length); +- } +- else if (object instanceof Vector) { +- Vector vector = (Vector) object; +- +- int size = vector.size(); +- writeListBegin(size, null); +- for (int i = 0; i < size; i++) +- writeObject(vector.elementAt(i)); +- +- writeListEnd(); +- } +- else if (object instanceof Hashtable) { +- Hashtable hashtable = (Hashtable) object; +- +- writeMapBegin(null); +- Enumeration e = hashtable.keys(); +- while (e.hasMoreElements()) { +- Object key = e.nextElement(); +- Object value = hashtable.get(key); +- +- writeObject(key); +- writeObject(value); +- } +- writeMapEnd(); +- } +- else +- writeCustomObject(object); +- } +- +- /** +- * Applications which override this can do custom serialization. +- * +- * @param object the object to write. +- */ +- public void writeCustomObject(Object object) +- throws IOException +- { +- throw new IOException("unexpected object: " + object); +- } +- +- /** +- * Writes the list header to the stream. List writers will call +- * writeListBegin followed by the list contents and then +- * call writeListEnd. +- * +- *
+-   * <list>
+-   *   <type>java.util.ArrayList</type>
+-   *   <length>3</length>
+-   *   <int>1</int>
+-   *   <int>2</int>
+-   *   <int>3</int>
+-   * </list>
+-   * 
+- */ +- public void writeListBegin(int length, String type) +- throws IOException +- { +- os.write('V'); +- os.write('t'); +- printLenString(type); +- +- os.write('l'); +- os.write(length >> 24); +- os.write(length >> 16); +- os.write(length >> 8); +- os.write(length); +- } +- +- /** +- * Writes the tail of the list to the stream. +- */ +- public void writeListEnd() +- throws IOException +- { +- os.write('z'); +- } +- +- /** +- * Writes the map header to the stream. Map writers will call +- * writeMapBegin followed by the map contents and then +- * call writeMapEnd. +- * +- *
+-   * Mt b16 b8 type ( )z
+-   * 
+- */ +- public void writeMapBegin(String type) +- throws IOException +- { +- os.write('M'); +- os.write('t'); +- printLenString(type); +- } +- +- /** +- * Writes the tail of the map to the stream. +- */ +- public void writeMapEnd() +- throws IOException +- { +- os.write('z'); +- } +- +- /** +- * Writes a remote object reference to the stream. The type is the +- * type of the remote interface. +- * +- *
+-   * 'r' 't' b16 b8 type url
+-   * 
+- */ +- public void writeRemote(String type, String url) +- throws IOException +- { +- os.write('r'); +- os.write('t'); +- printLenString(type); +- os.write('S'); +- printLenString(url); +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 with preceeding length +- * +- * @param v the string to print. +- */ +- public void printLenString(String v) +- throws IOException +- { +- if (v == null) { +- os.write(0); +- os.write(0); +- } +- else { +- int len = v.length(); +- os.write(len >> 8); +- os.write(len); +- +- printString(v, 0, len); +- } +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v) +- throws IOException +- { +- printString(v, 0, v.length()); +- } +- +- /** +- * Prints a string to the stream, encoded as UTF-8 +- * +- * @param v the string to print. +- */ +- public void printString(String v, int offset, int length) +- throws IOException +- { +- for (int i = 0; i < length; i++) { +- char ch = v.charAt(i + offset); +- +- if (ch < 0x80) +- os.write(ch); +- else if (ch < 0x800) { +- os.write(0xc0 + ((ch >> 6) & 0x1f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- else { +- os.write(0xe0 + ((ch >> 12) & 0xf)); +- os.write(0x80 + ((ch >> 6) & 0x3f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.micro; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++import java.util.Date; ++import java.util.Enumeration; ++import java.util.Hashtable; ++import java.util.Vector; ++ ++/** ++ * Output stream for Hessian requests, compatible with microedition ++ * Java. It only uses classes and types available to J2ME. In ++ * particular, it does not have any support for the <double> type. ++ * ++ *

MicroHessianOutput does not depend on any classes other than ++ * in J2ME, so it can be extracted independently into a smaller package. ++ * ++ *

MicroHessianOutput is unbuffered, so any client needs to provide ++ * its own buffering. ++ * ++ *

++ * OutputStream os = ...; // from http connection
++ * MicroHessianOutput out = new MicroHessianOutput(os);
++ * String value;
++ *
++ * out.startCall("hello");  // start hello call
++ * out.writeString("arg1"); // write a string argument
++ * out.completeCall();      // complete the call
++ * 
++ */ ++public class MicroHessianOutput { ++ protected OutputStream os; ++ ++ /** ++ * Creates a new Hessian output stream, initialized with an ++ * underlying output stream. ++ * ++ * @param os the underlying output stream. ++ */ ++ public MicroHessianOutput(OutputStream os) ++ { ++ init(os); ++ } ++ ++ /** ++ * Creates an uninitialized Hessian output stream. ++ */ ++ public MicroHessianOutput() ++ { ++ } ++ ++ public void init(OutputStream os) ++ { ++ this.os = os; ++ } ++ ++ /** ++ * Writes the method call: ++ * ++ *
++   * c major minor
++   * m b16 b8 method-namek
++   * 
++ * ++ * @param method the method name to call. ++ */ ++ public void startCall(String method) ++ throws IOException ++ { ++ os.write('c'); ++ os.write(0); ++ os.write(1); ++ ++ os.write('m'); ++ int len = method.length(); ++ os.write(len >> 8); ++ os.write(len); ++ printString(method, 0, len); ++ } ++ ++ /** ++ * Writes the method call: ++ * ++ *
++   * z
++   * 
++ */ ++ public void completeCall() ++ throws IOException ++ { ++ os.write('z'); ++ } ++ ++ /** ++ * Writes a boolean value to the stream. The boolean will be written ++ * with the following syntax: ++ * ++ *
++   * T
++   * F
++   * 
++ * ++ * @param value the boolean value to write. ++ */ ++ public void writeBoolean(boolean value) ++ throws IOException ++ { ++ if (value) ++ os.write('T'); ++ else ++ os.write('F'); ++ } ++ ++ /** ++ * Writes an integer value to the stream. The integer will be written ++ * with the following syntax: ++ * ++ *
++   * I b32 b24 b16 b8
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeInt(int value) ++ throws IOException ++ { ++ os.write('I'); ++ os.write(value >> 24); ++ os.write(value >> 16); ++ os.write(value >> 8); ++ os.write(value); ++ } ++ ++ /** ++ * Writes a long value to the stream. The long will be written ++ * with the following syntax: ++ * ++ *
++   * L b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param value the long value to write. ++ */ ++ public void writeLong(long value) ++ throws IOException ++ { ++ os.write('L'); ++ os.write((byte) (value >> 56)); ++ os.write((byte) (value >> 48)); ++ os.write((byte) (value >> 40)); ++ os.write((byte) (value >> 32)); ++ os.write((byte) (value >> 24)); ++ os.write((byte) (value >> 16)); ++ os.write((byte) (value >> 8)); ++ os.write((byte) (value)); ++ } ++ ++ /** ++ * Writes a date to the stream. ++ * ++ *
++   * T  b64 b56 b48 b40 b32 b24 b16 b8
++   * 
++ * ++ * @param time the date in milliseconds from the epoch in UTC ++ */ ++ public void writeUTCDate(long time) ++ throws IOException ++ { ++ os.write('d'); ++ os.write((byte) (time >> 56)); ++ os.write((byte) (time >> 48)); ++ os.write((byte) (time >> 40)); ++ os.write((byte) (time >> 32)); ++ os.write((byte) (time >> 24)); ++ os.write((byte) (time >> 16)); ++ os.write((byte) (time >> 8)); ++ os.write((byte) (time)); ++ } ++ ++ /** ++ * Writes a null value to the stream. ++ * The null will be written with the following syntax ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeNull() ++ throws IOException ++ { ++ os.write('N'); ++ } ++ ++ /** ++ * Writes a string value to the stream using UTF-8 encoding. ++ * The string will be written with the following syntax: ++ * ++ *
++   * S b16 b8 string-value
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeString(String value) ++ throws IOException ++ { ++ if (value == null) { ++ os.write('N'); ++ } ++ else { ++ int len = value.length(); ++ ++ os.write('S'); ++ os.write(len >> 8); ++ os.write(len); ++ ++ printString(value); ++ } ++ } ++ ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer) ++ throws IOException ++ { ++ if (buffer == null) ++ os.write('N'); ++ else ++ writeBytes(buffer, 0, buffer.length); ++ } ++ /** ++ * Writes a byte array to the stream. ++ * The array will be written with the following syntax: ++ * ++ *
++   * B b16 b18 bytes
++   * 
++ * ++ * If the value is null, it will be written as ++ * ++ *
++   * N
++   * 
++ * ++ * @param value the string value to write. ++ */ ++ public void writeBytes(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ if (buffer == null) { ++ os.write('N'); ++ } ++ else { ++ os.write('B'); ++ os.write(length << 8); ++ os.write(length); ++ os.write(buffer, offset, length); ++ } ++ } ++ ++ /** ++ * Writes a reference. ++ * ++ *
++   * R b32 b24 b16 b8
++   * 
++ * ++ * @param value the integer value to write. ++ */ ++ public void writeRef(int value) ++ throws IOException ++ { ++ os.write('R'); ++ os.write(value << 24); ++ os.write(value << 16); ++ os.write(value << 8); ++ os.write(value); ++ } ++ ++ /** ++ * Writes a generic object to the output stream. ++ */ ++ public void writeObject(Object object) ++ throws IOException ++ { ++ if (object == null) ++ writeNull(); ++ else if (object instanceof String) ++ writeString((String) object); ++ else if (object instanceof Boolean) ++ writeBoolean(((Boolean) object).booleanValue()); ++ else if (object instanceof Integer) ++ writeInt(((Integer) object).intValue()); ++ else if (object instanceof Long) ++ writeLong(((Long) object).longValue()); ++ else if (object instanceof Date) ++ writeUTCDate(((Date) object).getTime()); ++ else if (object instanceof byte[]) { ++ byte []data = (byte []) object; ++ writeBytes(data, 0, data.length); ++ } ++ else if (object instanceof Vector) { ++ Vector vector = (Vector) object; ++ ++ int size = vector.size(); ++ writeListBegin(size, null); ++ for (int i = 0; i < size; i++) ++ writeObject(vector.elementAt(i)); ++ ++ writeListEnd(); ++ } ++ else if (object instanceof Hashtable) { ++ Hashtable hashtable = (Hashtable) object; ++ ++ writeMapBegin(null); ++ Enumeration e = hashtable.keys(); ++ while (e.hasMoreElements()) { ++ Object key = e.nextElement(); ++ Object value = hashtable.get(key); ++ ++ writeObject(key); ++ writeObject(value); ++ } ++ writeMapEnd(); ++ } ++ else ++ writeCustomObject(object); ++ } ++ ++ /** ++ * Applications which override this can do custom serialization. ++ * ++ * @param object the object to write. ++ */ ++ public void writeCustomObject(Object object) ++ throws IOException ++ { ++ throw new IOException("unexpected object: " + object); ++ } ++ ++ /** ++ * Writes the list header to the stream. List writers will call ++ * writeListBegin followed by the list contents and then ++ * call writeListEnd. ++ * ++ *
++   * <list>
++   *   <type>java.util.ArrayList</type>
++   *   <length>3</length>
++   *   <int>1</int>
++   *   <int>2</int>
++   *   <int>3</int>
++   * </list>
++   * 
++ */ ++ public void writeListBegin(int length, String type) ++ throws IOException ++ { ++ os.write('V'); ++ os.write('t'); ++ printLenString(type); ++ ++ os.write('l'); ++ os.write(length >> 24); ++ os.write(length >> 16); ++ os.write(length >> 8); ++ os.write(length); ++ } ++ ++ /** ++ * Writes the tail of the list to the stream. ++ */ ++ public void writeListEnd() ++ throws IOException ++ { ++ os.write('z'); ++ } ++ ++ /** ++ * Writes the map header to the stream. Map writers will call ++ * writeMapBegin followed by the map contents and then ++ * call writeMapEnd. ++ * ++ *
++   * Mt b16 b8 type ( )z
++   * 
++ */ ++ public void writeMapBegin(String type) ++ throws IOException ++ { ++ os.write('M'); ++ os.write('t'); ++ printLenString(type); ++ } ++ ++ /** ++ * Writes the tail of the map to the stream. ++ */ ++ public void writeMapEnd() ++ throws IOException ++ { ++ os.write('z'); ++ } ++ ++ /** ++ * Writes a remote object reference to the stream. The type is the ++ * type of the remote interface. ++ * ++ *
++   * 'r' 't' b16 b8 type url
++   * 
++ */ ++ public void writeRemote(String type, String url) ++ throws IOException ++ { ++ os.write('r'); ++ os.write('t'); ++ printLenString(type); ++ os.write('S'); ++ printLenString(url); ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 with preceeding length ++ * ++ * @param v the string to print. ++ */ ++ public void printLenString(String v) ++ throws IOException ++ { ++ if (v == null) { ++ os.write(0); ++ os.write(0); ++ } ++ else { ++ int len = v.length(); ++ os.write(len >> 8); ++ os.write(len); ++ ++ printString(v, 0, len); ++ } ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v) ++ throws IOException ++ { ++ printString(v, 0, v.length()); ++ } ++ ++ /** ++ * Prints a string to the stream, encoded as UTF-8 ++ * ++ * @param v the string to print. ++ */ ++ public void printString(String v, int offset, int length) ++ throws IOException ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = v.charAt(i + offset); ++ ++ if (ch < 0x80) ++ os.write(ch); ++ else if (ch < 0x800) { ++ os.write(0xc0 + ((ch >> 6) & 0x1f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ else { ++ os.write(0xe0 + ((ch >> 12) & 0xf)); ++ os.write(0x80 + ((ch >> 6) & 0x3f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/mux/MuxInputStream.java hessian-4.0.65-fix/com/caucho/hessian/mux/MuxInputStream.java +--- hessian-4.0.65-src/com/caucho/hessian/mux/MuxInputStream.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/mux/MuxInputStream.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,280 +1,280 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.mux; +- +-import java.io.IOException; +-import java.io.InputStream; +- +-/** +- * Input stream to a specific channel. +- */ +-public class MuxInputStream extends InputStream { +- private MuxServer server; +- protected InputStream is; +- private int channel; +- +- private String url; +- +- private int chunkLength; +- +- /** +- * Null argument constructor. +- */ +- public MuxInputStream() +- { +- } +- +- /** +- * Initialize the multiplexor with input and output streams. +- */ +- protected void init(MuxServer server, int channel) +- throws IOException +- { +- this.server = server; +- this.channel = channel; +- +- this.url = null; +- +- chunkLength = 0; +- } +- +- /** +- * Gets the raw input stream. Clients will normally not call +- * this. +- */ +- protected InputStream getInputStream() +- throws IOException +- { +- if (is == null && server != null) +- is = server.readChannel(channel); +- +- return is; +- } +- +- void setInputStream(InputStream is) +- { +- this.is = is; +- } +- +- /** +- * Gets the channel of the connection. +- */ +- public int getChannel() +- { +- return channel; +- } +- +- /** +- * Returns the request's URL +- */ +- public String getURL() +- { +- return url; +- } +- +- /** +- * Writes a data byte to the output stream. +- */ +- public int read() +- throws IOException +- { +- if (chunkLength <= 0) { +- readToData(false); +- +- if (chunkLength <= 0) +- return -1; +- } +- +- chunkLength--; +- return is.read(); +- } +- +- /** +- * Complete writing to the stream, closing the channel. +- */ +- public void close() +- throws IOException +- { +- skipToEnd(); +- } +- +- /** +- * Skips data until the end of the channel. +- */ +- private void skipToEnd() +- throws IOException +- { +- InputStream is = getInputStream(); +- +- if (is == null) +- return; +- +- if (chunkLength > 0) +- is.skip(chunkLength); +- +- for (int tag = is.read(); tag >= 0; tag = is.read()) { +- switch (tag) { +- case 'Y': +- server.freeReadLock(); +- this.is = is = server.readChannel(channel); +- if (is == null) { +- this.server = null; +- return; +- } +- break; +- +- case 'Q': +- server.freeReadLock(); +- this.is = null; +- this.server = null; +- return; +- +- case -1: +- server.freeReadLock(); +- this.is = null; +- this.server = null; +- return; +- +- default: +- int length = (is.read() << 8) + is.read(); +- is.skip(length); +- break; +- } +- } +- } +- +- /** +- * Reads tags, until getting data. +- */ +- void readToData(boolean returnOnYield) +- throws IOException +- { +- InputStream is = getInputStream(); +- +- if (is == null) +- return; +- +- for (int tag = is.read(); tag >= 0; tag = is.read()) { +- switch (tag) { +- case 'Y': +- server.freeReadLock(); +- if (returnOnYield) +- return; +- server.readChannel(channel); +- break; +- +- case 'Q': +- server.freeReadLock(); +- this.is = null; +- this.server = null; +- return; +- +- case 'U': +- this.url = readUTF(); +- break; +- +- case 'D': +- chunkLength = (is.read() << 8) + is.read(); +- return; +- +- default: +- readTag(tag); +- break; +- } +- } +- } +- +- /** +- * Subclasses will extend this to read values. +- */ +- protected void readTag(int tag) +- throws IOException +- { +- int length = (is.read() << 8) + is.read(); +- is.skip(length); +- } +- +- /** +- * Reads a UTF-8 string. +- * +- * @return the utf-8 encoded string +- */ +- protected String readUTF() +- throws IOException +- { +- int len = (is.read() << 8) + is.read(); +- +- StringBuffer sb = new StringBuffer(); +- +- while (len > 0) { +- int d1 = is.read(); +- +- if (d1 < 0) +- return sb.toString(); +- else if (d1 < 0x80) { +- len--; +- sb.append((char) d1); +- } +- else if ((d1 & 0xe0) == 0xc0) { +- len -= 2; +- sb.append(((d1 & 0x1f) << 6) + (is.read() & 0x3f)); +- } +- else if ((d1 & 0xf0) == 0xe0) { +- len -= 3; +- sb.append(((d1 & 0x0f) << 12) + +- ((is.read() & 0x3f) << 6) + +- (is.read() & 0x3f)); +- } +- else +- throw new IOException("utf-8 encoding error"); +- } +- +- return sb.toString(); +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.mux; ++ ++import java.io.IOException; ++import java.io.InputStream; ++ ++/** ++ * Input stream to a specific channel. ++ */ ++public class MuxInputStream extends InputStream { ++ private MuxServer server; ++ protected InputStream is; ++ private int channel; ++ ++ private String url; ++ ++ private int chunkLength; ++ ++ /** ++ * Null argument constructor. ++ */ ++ public MuxInputStream() ++ { ++ } ++ ++ /** ++ * Initialize the multiplexor with input and output streams. ++ */ ++ protected void init(MuxServer server, int channel) ++ throws IOException ++ { ++ this.server = server; ++ this.channel = channel; ++ ++ this.url = null; ++ ++ chunkLength = 0; ++ } ++ ++ /** ++ * Gets the raw input stream. Clients will normally not call ++ * this. ++ */ ++ protected InputStream getInputStream() ++ throws IOException ++ { ++ if (is == null && server != null) ++ is = server.readChannel(channel); ++ ++ return is; ++ } ++ ++ void setInputStream(InputStream is) ++ { ++ this.is = is; ++ } ++ ++ /** ++ * Gets the channel of the connection. ++ */ ++ public int getChannel() ++ { ++ return channel; ++ } ++ ++ /** ++ * Returns the request's URL ++ */ ++ public String getURL() ++ { ++ return url; ++ } ++ ++ /** ++ * Writes a data byte to the output stream. ++ */ ++ public int read() ++ throws IOException ++ { ++ if (chunkLength <= 0) { ++ readToData(false); ++ ++ if (chunkLength <= 0) ++ return -1; ++ } ++ ++ chunkLength--; ++ return is.read(); ++ } ++ ++ /** ++ * Complete writing to the stream, closing the channel. ++ */ ++ public void close() ++ throws IOException ++ { ++ skipToEnd(); ++ } ++ ++ /** ++ * Skips data until the end of the channel. ++ */ ++ private void skipToEnd() ++ throws IOException ++ { ++ InputStream is = getInputStream(); ++ ++ if (is == null) ++ return; ++ ++ if (chunkLength > 0) ++ is.skip(chunkLength); ++ ++ for (int tag = is.read(); tag >= 0; tag = is.read()) { ++ switch (tag) { ++ case 'Y': ++ server.freeReadLock(); ++ this.is = is = server.readChannel(channel); ++ if (is == null) { ++ this.server = null; ++ return; ++ } ++ break; ++ ++ case 'Q': ++ server.freeReadLock(); ++ this.is = null; ++ this.server = null; ++ return; ++ ++ case -1: ++ server.freeReadLock(); ++ this.is = null; ++ this.server = null; ++ return; ++ ++ default: ++ int length = (is.read() << 8) + is.read(); ++ is.skip(length); ++ break; ++ } ++ } ++ } ++ ++ /** ++ * Reads tags, until getting data. ++ */ ++ void readToData(boolean returnOnYield) ++ throws IOException ++ { ++ InputStream is = getInputStream(); ++ ++ if (is == null) ++ return; ++ ++ for (int tag = is.read(); tag >= 0; tag = is.read()) { ++ switch (tag) { ++ case 'Y': ++ server.freeReadLock(); ++ if (returnOnYield) ++ return; ++ server.readChannel(channel); ++ break; ++ ++ case 'Q': ++ server.freeReadLock(); ++ this.is = null; ++ this.server = null; ++ return; ++ ++ case 'U': ++ this.url = readUTF(); ++ break; ++ ++ case 'D': ++ chunkLength = (is.read() << 8) + is.read(); ++ return; ++ ++ default: ++ readTag(tag); ++ break; ++ } ++ } ++ } ++ ++ /** ++ * Subclasses will extend this to read values. ++ */ ++ protected void readTag(int tag) ++ throws IOException ++ { ++ int length = (is.read() << 8) + is.read(); ++ is.skip(length); ++ } ++ ++ /** ++ * Reads a UTF-8 string. ++ * ++ * @return the utf-8 encoded string ++ */ ++ protected String readUTF() ++ throws IOException ++ { ++ int len = (is.read() << 8) + is.read(); ++ ++ StringBuffer sb = new StringBuffer(); ++ ++ while (len > 0) { ++ int d1 = is.read(); ++ ++ if (d1 < 0) ++ return sb.toString(); ++ else if (d1 < 0x80) { ++ len--; ++ sb.append((char) d1); ++ } ++ else if ((d1 & 0xe0) == 0xc0) { ++ len -= 2; ++ sb.append(((d1 & 0x1f) << 6) + (is.read() & 0x3f)); ++ } ++ else if ((d1 & 0xf0) == 0xe0) { ++ len -= 3; ++ sb.append(((d1 & 0x0f) << 12) + ++ ((is.read() & 0x3f) << 6) + ++ (is.read() & 0x3f)); ++ } ++ else ++ throw new IOException("utf-8 encoding error"); ++ } ++ ++ return sb.toString(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/mux/MuxOutputStream.java hessian-4.0.65-fix/com/caucho/hessian/mux/MuxOutputStream.java +--- hessian-4.0.65-src/com/caucho/hessian/mux/MuxOutputStream.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/mux/MuxOutputStream.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,236 +1,236 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.mux; +- +-import java.io.IOException; +-import java.io.OutputStream; +- +-/** +- * Output stream to a specific channel. +- */ +-public class MuxOutputStream extends OutputStream { +- private MuxServer server; +- private int channel; +- private OutputStream os; +- +- /** +- * Null argument constructor. +- */ +- public MuxOutputStream() +- { +- } +- +- /** +- * Initialize the multiplexor with input and output streams. +- */ +- protected void init(MuxServer server, int channel) +- throws IOException +- { +- this.server = server; +- this.channel = channel; +- this.os = null; +- } +- +- /** +- * Gets the raw output stream. Clients will normally not call +- * this. +- */ +- protected OutputStream getOutputStream() +- throws IOException +- { +- if (os == null && server != null) +- os = server.writeChannel(channel); +- +- return os; +- } +- +- /** +- * Gets the channel of the connection. +- */ +- public int getChannel() +- { +- return channel; +- } +- +- /** +- * Writes a URL to the stream. +- */ +- public void writeURL(String url) +- throws IOException +- { +- writeUTF('U', url); +- } +- +- /** +- * Writes a data byte to the output stream. +- */ +- public void write(int ch) +- throws IOException +- { +- OutputStream os = getOutputStream(); +- +- os.write('D'); +- os.write(0); +- os.write(1); +- os.write(ch); +- } +- +- /** +- * Writes data to the output stream. +- */ +- public void write(byte []buffer, int offset, int length) +- throws IOException +- { +- OutputStream os = getOutputStream(); +- +- for (; length > 0x8000; length -= 0x8000) { +- os.write('D'); +- os.write(0x80); +- os.write(0x00); +- os.write(buffer, offset, 0x8000); +- +- offset += 0x8000; +- } +- +- os.write('D'); +- os.write(length >> 8); +- os.write(length); +- os.write(buffer, offset, length); +- } +- +- /** +- * Flush data to the output stream. +- */ +- public void yield() +- throws IOException +- { +- OutputStream os = this.os; +- this.os = null; +- +- if (os != null) +- server.yield(channel); +- } +- +- /** +- * Flush data to the output stream. +- */ +- public void flush() +- throws IOException +- { +- OutputStream os = this.os; +- this.os = null; +- +- if (os != null) +- server.flush(channel); +- } +- +- /** +- * Complete writing to the stream, closing the channel. +- */ +- public void close() +- throws IOException +- { +- if (server != null) { +- OutputStream os = getOutputStream(); +- this.os = null; +- +- MuxServer server = this.server; +- this.server = null; +- +- server.close(channel); +- } +- } +- +- /** +- * Writes a UTF-8 string. +- * +- * @param code the HMUX code identifying the string +- * @param string the string to write +- */ +- protected void writeUTF(int code, String string) +- throws IOException +- { +- OutputStream os = getOutputStream(); +- +- os.write(code); +- +- int charLength = string.length(); +- +- int length = 0; +- for (int i = 0; i < charLength; i++) { +- char ch = string.charAt(i); +- +- if (ch < 0x80) +- length++; +- else if (ch < 0x800) +- length += 2; +- else +- length += 3; +- } +- +- os.write(length >> 8); +- os.write(length); +- +- for (int i = 0; i < length; i++) { +- char ch = string.charAt(i); +- +- if (ch < 0x80) +- os.write(ch); +- else if (ch < 0x800) { +- os.write(0xc0 + (ch >> 6) & 0x1f); +- os.write(0x80 + (ch & 0x3f)); +- } +- else { +- os.write(0xe0 + (ch >> 12) & 0xf); +- os.write(0x80 + ((ch >> 6) & 0x3f)); +- os.write(0x80 + (ch & 0x3f)); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.mux; ++ ++import java.io.IOException; ++import java.io.OutputStream; ++ ++/** ++ * Output stream to a specific channel. ++ */ ++public class MuxOutputStream extends OutputStream { ++ private MuxServer server; ++ private int channel; ++ private OutputStream os; ++ ++ /** ++ * Null argument constructor. ++ */ ++ public MuxOutputStream() ++ { ++ } ++ ++ /** ++ * Initialize the multiplexor with input and output streams. ++ */ ++ protected void init(MuxServer server, int channel) ++ throws IOException ++ { ++ this.server = server; ++ this.channel = channel; ++ this.os = null; ++ } ++ ++ /** ++ * Gets the raw output stream. Clients will normally not call ++ * this. ++ */ ++ protected OutputStream getOutputStream() ++ throws IOException ++ { ++ if (os == null && server != null) ++ os = server.writeChannel(channel); ++ ++ return os; ++ } ++ ++ /** ++ * Gets the channel of the connection. ++ */ ++ public int getChannel() ++ { ++ return channel; ++ } ++ ++ /** ++ * Writes a URL to the stream. ++ */ ++ public void writeURL(String url) ++ throws IOException ++ { ++ writeUTF('U', url); ++ } ++ ++ /** ++ * Writes a data byte to the output stream. ++ */ ++ public void write(int ch) ++ throws IOException ++ { ++ OutputStream os = getOutputStream(); ++ ++ os.write('D'); ++ os.write(0); ++ os.write(1); ++ os.write(ch); ++ } ++ ++ /** ++ * Writes data to the output stream. ++ */ ++ public void write(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ OutputStream os = getOutputStream(); ++ ++ for (; length > 0x8000; length -= 0x8000) { ++ os.write('D'); ++ os.write(0x80); ++ os.write(0x00); ++ os.write(buffer, offset, 0x8000); ++ ++ offset += 0x8000; ++ } ++ ++ os.write('D'); ++ os.write(length >> 8); ++ os.write(length); ++ os.write(buffer, offset, length); ++ } ++ ++ /** ++ * Flush data to the output stream. ++ */ ++ public void yield() ++ throws IOException ++ { ++ OutputStream os = this.os; ++ this.os = null; ++ ++ if (os != null) ++ server.yield(channel); ++ } ++ ++ /** ++ * Flush data to the output stream. ++ */ ++ public void flush() ++ throws IOException ++ { ++ OutputStream os = this.os; ++ this.os = null; ++ ++ if (os != null) ++ server.flush(channel); ++ } ++ ++ /** ++ * Complete writing to the stream, closing the channel. ++ */ ++ public void close() ++ throws IOException ++ { ++ if (server != null) { ++ OutputStream os = getOutputStream(); ++ this.os = null; ++ ++ MuxServer server = this.server; ++ this.server = null; ++ ++ server.close(channel); ++ } ++ } ++ ++ /** ++ * Writes a UTF-8 string. ++ * ++ * @param code the HMUX code identifying the string ++ * @param string the string to write ++ */ ++ protected void writeUTF(int code, String string) ++ throws IOException ++ { ++ OutputStream os = getOutputStream(); ++ ++ os.write(code); ++ ++ int charLength = string.length(); ++ ++ int length = 0; ++ for (int i = 0; i < charLength; i++) { ++ char ch = string.charAt(i); ++ ++ if (ch < 0x80) ++ length++; ++ else if (ch < 0x800) ++ length += 2; ++ else ++ length += 3; ++ } ++ ++ os.write(length >> 8); ++ os.write(length); ++ ++ for (int i = 0; i < length; i++) { ++ char ch = string.charAt(i); ++ ++ if (ch < 0x80) ++ os.write(ch); ++ else if (ch < 0x800) { ++ os.write(0xc0 + (ch >> 6) & 0x1f); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ else { ++ os.write(0xe0 + (ch >> 12) & 0xf); ++ os.write(0x80 + ((ch >> 6) & 0x3f)); ++ os.write(0x80 + (ch & 0x3f)); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/mux/MuxServer.java hessian-4.0.65-fix/com/caucho/hessian/mux/MuxServer.java +--- hessian-4.0.65-src/com/caucho/hessian/mux/MuxServer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/mux/MuxServer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,383 +1,383 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.mux; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +- +-/** +- * Hessian Mux, a peer-to-peer protocol. +- */ +-public class MuxServer { +- private Object READ_LOCK = new Object(); +- private Object WRITE_LOCK = new Object(); +- +- private InputStream is; +- private OutputStream os; +- private boolean isClient; +- +- private transient boolean isClosed; +- +- // channels that have data ready. +- private boolean inputReady[] = new boolean[4]; +- +- // true if there's a thread already reading +- private boolean isReadLocked; +- // true if there's a thread already writing +- private boolean isWriteLocked; +- +- /** +- * Null argument constructor. +- */ +- public MuxServer() +- { +- } +- +- /** +- * Create a new multiplexor with input and output streams. +- * +- * @param is the underlying input stream +- * @param os the underlying output stream +- * @param isClient true if this is the connection client. +- */ +- public MuxServer(InputStream is, OutputStream os, boolean isClient) +- { +- init(is, os, isClient); +- } +- +- /** +- * Initialize the multiplexor with input and output streams. +- * +- * @param is the underlying input stream +- * @param os the underlying output stream +- * @param isClient true if this is the connection client. +- */ +- public void init(InputStream is, OutputStream os, boolean isClient) +- { +- this.is = is; +- this.os = os; +- this.isClient = isClient; +- } +- +- /** +- * Gets the raw input stream. Clients will normally not call +- * this. +- */ +- public InputStream getInputStream() +- { +- return is; +- } +- +- /** +- * Gets the raw output stream. Clients will normally not call +- * this. +- */ +- public OutputStream getOutputStream() +- { +- return os; +- } +- +- /** +- * Starts a client call. +- */ +- public boolean startCall(MuxInputStream in, MuxOutputStream out) +- throws IOException +- { +- int channel = isClient ? 2 : 3; +- +- return startCall(channel, in, out); +- } +- +- /** +- * Starts a client call. +- */ +- public boolean startCall(int channel, MuxInputStream in, MuxOutputStream out) +- throws IOException +- { +- // XXX: Eventually need to check to see if the channel is used. +- // It's not clear whether this should cause a wait or an exception. +- +- in.init(this, channel); +- out.init(this, channel); +- +- return true; +- } +- +- /** +- * Reads a server request. +- */ +- public boolean readRequest(MuxInputStream in, MuxOutputStream out) +- throws IOException +- { +- int channel = isClient ? 3 : 2; +- +- in.init(this, channel); +- out.init(this, channel); +- +- if (readChannel(channel) != null) { +- in.setInputStream(is); +- in.readToData(false); +- return true; +- } +- else +- return false; +- } +- +- /** +- * Grabs the channel for writing. +- * +- * @param channel the channel +- * +- * @return true if the channel has permission to write. +- */ +- OutputStream writeChannel(int channel) +- throws IOException +- { +- while (os != null) { +- boolean canWrite = false; +- synchronized (WRITE_LOCK) { +- if (! isWriteLocked) { +- isWriteLocked = true; +- canWrite = true; +- } +- else { +- try { +- WRITE_LOCK.wait(5000); +- } catch (Exception e) { +- } +- } +- } +- +- if (canWrite) { +- os.write('C'); +- os.write(channel >> 8); +- os.write(channel); +- +- return os; +- } +- } +- +- return null; +- } +- +- void yield(int channel) +- throws IOException +- { +- os.write('Y'); +- freeWriteLock(); +- } +- +- void flush(int channel) +- throws IOException +- { +- os.write('Y'); +- os.flush(); +- freeWriteLock(); +- } +- +- void close(int channel) +- throws IOException +- { +- if (os != null) { +- os.write('Q'); +- os.flush(); +- freeWriteLock(); +- } +- } +- +- /** +- * Frees the channel for writing. +- */ +- void freeWriteLock() +- { +- synchronized (WRITE_LOCK) { +- isWriteLocked = false; +- WRITE_LOCK.notifyAll(); +- } +- } +- +- /** +- * Reads data from a channel. +- * +- * @param channel the channel +- * +- * @return true if the channel is valid. +- */ +- InputStream readChannel(int channel) +- throws IOException +- { +- while (! isClosed) { +- if (inputReady[channel]) { +- inputReady[channel] = false; +- return is; +- } +- +- boolean canRead = false; +- synchronized (READ_LOCK) { +- if (! isReadLocked) { +- isReadLocked = true; +- canRead = true; +- } +- else { +- try { +- READ_LOCK.wait(5000); +- } catch (Exception e) { +- } +- } +- } +- +- if (canRead) { +- try { +- readData(); +- } catch (IOException e) { +- close(); +- } +- } +- } +- +- return null; +- } +- +- boolean getReadLock() +- { +- synchronized (READ_LOCK) { +- if (! isReadLocked) { +- isReadLocked = true; +- return true; +- } +- else { +- try { +- READ_LOCK.wait(5000); +- } catch (Exception e) { +- } +- } +- } +- +- return false; +- } +- +- /** +- * Frees the channel for reading. +- */ +- void freeReadLock() +- { +- synchronized (READ_LOCK) { +- isReadLocked = false; +- READ_LOCK.notifyAll(); +- } +- } +- +- /** +- * Reads data until a channel packet 'C' or error 'E' is received. +- */ +- private void readData() +- throws IOException +- { +- while (! isClosed) { +- int code = is.read(); +- +- switch (code) { +- case ' ': +- case '\t': +- case '\n': +- case '\r': +- break; +- +- case 'C': { +- int channel = (is.read() << 8) + is.read(); +- +- inputReady[channel] = true; +- return; +- } +- +- case 'E': { +- int channel = (is.read() << 8) + is.read(); +- int status = (is.read() << 8) + is.read(); +- +- inputReady[channel] = true; +- +- return; +- } +- +- case -1: +- close(); +- return; +- +- default: +- // An error in the protocol. Kill the connection. +- close(); +- return; +- } +- } +- +- return; +- } +- +- /** +- * Close the mux +- */ +- public void close() +- throws IOException +- { +- isClosed = true; +- +- OutputStream os = this.os; +- this.os = null; +- +- InputStream is = this.is; +- this.is = null; +- +- if (os != null) +- os.close(); +- +- if (is != null) +- is.close(); +- } +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.mux; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++ ++/** ++ * Hessian Mux, a peer-to-peer protocol. ++ */ ++public class MuxServer { ++ private Object READ_LOCK = new Object(); ++ private Object WRITE_LOCK = new Object(); ++ ++ private InputStream is; ++ private OutputStream os; ++ private boolean isClient; ++ ++ private transient boolean isClosed; ++ ++ // channels that have data ready. ++ private boolean inputReady[] = new boolean[4]; ++ ++ // true if there's a thread already reading ++ private boolean isReadLocked; ++ // true if there's a thread already writing ++ private boolean isWriteLocked; ++ ++ /** ++ * Null argument constructor. ++ */ ++ public MuxServer() ++ { ++ } ++ ++ /** ++ * Create a new multiplexor with input and output streams. ++ * ++ * @param is the underlying input stream ++ * @param os the underlying output stream ++ * @param isClient true if this is the connection client. ++ */ ++ public MuxServer(InputStream is, OutputStream os, boolean isClient) ++ { ++ init(is, os, isClient); ++ } ++ ++ /** ++ * Initialize the multiplexor with input and output streams. ++ * ++ * @param is the underlying input stream ++ * @param os the underlying output stream ++ * @param isClient true if this is the connection client. ++ */ ++ public void init(InputStream is, OutputStream os, boolean isClient) ++ { ++ this.is = is; ++ this.os = os; ++ this.isClient = isClient; ++ } ++ ++ /** ++ * Gets the raw input stream. Clients will normally not call ++ * this. ++ */ ++ public InputStream getInputStream() ++ { ++ return is; ++ } ++ ++ /** ++ * Gets the raw output stream. Clients will normally not call ++ * this. ++ */ ++ public OutputStream getOutputStream() ++ { ++ return os; ++ } ++ ++ /** ++ * Starts a client call. ++ */ ++ public boolean startCall(MuxInputStream in, MuxOutputStream out) ++ throws IOException ++ { ++ int channel = isClient ? 2 : 3; ++ ++ return startCall(channel, in, out); ++ } ++ ++ /** ++ * Starts a client call. ++ */ ++ public boolean startCall(int channel, MuxInputStream in, MuxOutputStream out) ++ throws IOException ++ { ++ // XXX: Eventually need to check to see if the channel is used. ++ // It's not clear whether this should cause a wait or an exception. ++ ++ in.init(this, channel); ++ out.init(this, channel); ++ ++ return true; ++ } ++ ++ /** ++ * Reads a server request. ++ */ ++ public boolean readRequest(MuxInputStream in, MuxOutputStream out) ++ throws IOException ++ { ++ int channel = isClient ? 3 : 2; ++ ++ in.init(this, channel); ++ out.init(this, channel); ++ ++ if (readChannel(channel) != null) { ++ in.setInputStream(is); ++ in.readToData(false); ++ return true; ++ } ++ else ++ return false; ++ } ++ ++ /** ++ * Grabs the channel for writing. ++ * ++ * @param channel the channel ++ * ++ * @return true if the channel has permission to write. ++ */ ++ OutputStream writeChannel(int channel) ++ throws IOException ++ { ++ while (os != null) { ++ boolean canWrite = false; ++ synchronized (WRITE_LOCK) { ++ if (! isWriteLocked) { ++ isWriteLocked = true; ++ canWrite = true; ++ } ++ else { ++ try { ++ WRITE_LOCK.wait(5000); ++ } catch (Exception e) { ++ } ++ } ++ } ++ ++ if (canWrite) { ++ os.write('C'); ++ os.write(channel >> 8); ++ os.write(channel); ++ ++ return os; ++ } ++ } ++ ++ return null; ++ } ++ ++ void yield(int channel) ++ throws IOException ++ { ++ os.write('Y'); ++ freeWriteLock(); ++ } ++ ++ void flush(int channel) ++ throws IOException ++ { ++ os.write('Y'); ++ os.flush(); ++ freeWriteLock(); ++ } ++ ++ void close(int channel) ++ throws IOException ++ { ++ if (os != null) { ++ os.write('Q'); ++ os.flush(); ++ freeWriteLock(); ++ } ++ } ++ ++ /** ++ * Frees the channel for writing. ++ */ ++ void freeWriteLock() ++ { ++ synchronized (WRITE_LOCK) { ++ isWriteLocked = false; ++ WRITE_LOCK.notifyAll(); ++ } ++ } ++ ++ /** ++ * Reads data from a channel. ++ * ++ * @param channel the channel ++ * ++ * @return true if the channel is valid. ++ */ ++ InputStream readChannel(int channel) ++ throws IOException ++ { ++ while (! isClosed) { ++ if (inputReady[channel]) { ++ inputReady[channel] = false; ++ return is; ++ } ++ ++ boolean canRead = false; ++ synchronized (READ_LOCK) { ++ if (! isReadLocked) { ++ isReadLocked = true; ++ canRead = true; ++ } ++ else { ++ try { ++ READ_LOCK.wait(5000); ++ } catch (Exception e) { ++ } ++ } ++ } ++ ++ if (canRead) { ++ try { ++ readData(); ++ } catch (IOException e) { ++ close(); ++ } ++ } ++ } ++ ++ return null; ++ } ++ ++ boolean getReadLock() ++ { ++ synchronized (READ_LOCK) { ++ if (! isReadLocked) { ++ isReadLocked = true; ++ return true; ++ } ++ else { ++ try { ++ READ_LOCK.wait(5000); ++ } catch (Exception e) { ++ } ++ } ++ } ++ ++ return false; ++ } ++ ++ /** ++ * Frees the channel for reading. ++ */ ++ void freeReadLock() ++ { ++ synchronized (READ_LOCK) { ++ isReadLocked = false; ++ READ_LOCK.notifyAll(); ++ } ++ } ++ ++ /** ++ * Reads data until a channel packet 'C' or error 'E' is received. ++ */ ++ private void readData() ++ throws IOException ++ { ++ while (! isClosed) { ++ int code = is.read(); ++ ++ switch (code) { ++ case ' ': ++ case '\t': ++ case '\n': ++ case '\r': ++ break; ++ ++ case 'C': { ++ int channel = (is.read() << 8) + is.read(); ++ ++ inputReady[channel] = true; ++ return; ++ } ++ ++ case 'E': { ++ int channel = (is.read() << 8) + is.read(); ++ int status = (is.read() << 8) + is.read(); ++ ++ inputReady[channel] = true; ++ ++ return; ++ } ++ ++ case -1: ++ close(); ++ return; ++ ++ default: ++ // An error in the protocol. Kill the connection. ++ close(); ++ return; ++ } ++ } ++ ++ return; ++ } ++ ++ /** ++ * Close the mux ++ */ ++ public void close() ++ throws IOException ++ { ++ isClosed = true; ++ ++ OutputStream os = this.os; ++ this.os = null; ++ ++ InputStream is = this.is; ++ this.is = null; ++ ++ if (os != null) ++ os.close(); ++ ++ if (is != null) ++ is.close(); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/security/X509Encryption.java hessian-4.0.65-fix/com/caucho/hessian/security/X509Encryption.java +--- hessian-4.0.65-src/com/caucho/hessian/security/X509Encryption.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/security/X509Encryption.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,380 +1,380 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.security; +- +-import java.security.*; +-import java.security.cert.*; +-import java.util.*; +-import javax.crypto.*; +- +-import java.io.*; +- +-import com.caucho.hessian.io.*; +- +-public class X509Encryption extends HessianEnvelope { +- private String _algorithm = "AES"; +- +- // certificate for encryption/decryption +- private X509Certificate _cert; +- +- // private key for decryption +- private PrivateKey _privateKey; +- +- private SecureRandom _secureRandom; +- +- public X509Encryption() +- { +- } +- +- /** +- * Sets the encryption algorithm for the content. +- */ +- public void setAlgorithm(String algorithm) +- { +- if (algorithm == null) +- throw new NullPointerException(); +- +- _algorithm = algorithm; +- } +- +- /** +- * Gets the encryption algorithm for the content. +- */ +- public String getAlgorithm() +- { +- return _algorithm; +- } +- +- /** +- * The X509 certificate to obtain the public key of the recipient. +- */ +- public X509Certificate getCertificate() +- { +- return _cert; +- } +- +- /** +- * The X509 certificate to obtain the public key of the recipient. +- */ +- public void setCertificate(X509Certificate cert) +- { +- _cert = cert; +- } +- +- /** +- * The private key for decryption. +- */ +- public PrivateKey getPrivateKey() +- { +- return _privateKey; +- } +- +- /** +- * The X509 certificate to obtain the public key of the recipient. +- */ +- public void setPrivateKey(PrivateKey privateKey) +- { +- _privateKey = privateKey; +- } +- +- /** +- * The random number generator for the shared secrets. +- */ +- public SecureRandom getSecureRandom() +- { +- return _secureRandom; +- } +- +- /** +- * The random number generator for the shared secrets. +- */ +- public void setSecureRandom(SecureRandom random) +- { +- _secureRandom = random; +- } +- +- public Hessian2Output wrap(Hessian2Output out) +- throws IOException +- { +- if (_cert == null) +- throw new IOException("X509Encryption.wrap requires a certificate"); +- +- OutputStream os = new EncryptOutputStream(out); +- +- Hessian2Output filterOut = new Hessian2Output(os); +- +- filterOut.setCloseStreamOnClose(true); +- +- return filterOut; +- } +- +- public Hessian2Input unwrap(Hessian2Input in) +- throws IOException +- { +- if (_privateKey == null) +- throw new IOException("X509Encryption.unwrap requires a private key"); +- +- if (_cert == null) +- throw new IOException("X509Encryption.unwrap requires a certificate"); +- +- int version = in.readEnvelope(); +- +- String method = in.readMethod(); +- +- if (! method.equals(getClass().getName())) +- throw new IOException("expected hessian Envelope method '" + +- getClass().getName() + "' at '" + method + "'"); +- +- return unwrapHeaders(in); +- } +- +- public Hessian2Input unwrapHeaders(Hessian2Input in) +- throws IOException +- { +- if (_privateKey == null) +- throw new IOException("X509Encryption.unwrap requires a private key"); +- +- if (_cert == null) +- throw new IOException("X509Encryption.unwrap requires a certificate"); +- +- InputStream is = new EncryptInputStream(in); +- +- Hessian2Input filter = new Hessian2Input(is); +- +- filter.setCloseStreamOnClose(true); +- +- return filter; +- } +- +- class EncryptOutputStream extends OutputStream { +- private Hessian2Output _out; +- +- private Cipher _cipher; +- private OutputStream _bodyOut; +- private CipherOutputStream _cipherOut; +- +- EncryptOutputStream(Hessian2Output out) +- throws IOException +- { +- try { +- _out = out; +- +- KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); +- +- if (_secureRandom != null) +- keyGen.init(_secureRandom); +- +- SecretKey sharedKey = keyGen.generateKey(); +- +- _out = out; +- +- _out.startEnvelope(X509Encryption.class.getName()); +- +- PublicKey publicKey = _cert.getPublicKey(); +- +- byte []encoded = publicKey.getEncoded(); +- MessageDigest md = MessageDigest.getInstance("SHA1"); +- md.update(encoded); +- byte []fingerprint = md.digest(); +- +- String keyAlgorithm = publicKey.getAlgorithm(); +- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); +- if (_secureRandom != null) +- keyCipher.init(Cipher.WRAP_MODE, _cert, _secureRandom); +- else +- keyCipher.init(Cipher.WRAP_MODE, _cert); +- +- byte []encKey = keyCipher.wrap(sharedKey); +- +- _out.writeInt(4); +- +- _out.writeString("algorithm"); +- _out.writeString(_algorithm); +- _out.writeString("fingerprint"); +- _out.writeBytes(fingerprint); +- _out.writeString("key-algorithm"); +- _out.writeString(keyAlgorithm); +- _out.writeString("key"); +- _out.writeBytes(encKey); +- +- _bodyOut = _out.getBytesOutputStream(); +- +- _cipher = Cipher.getInstance(_algorithm); +- if (_secureRandom != null) +- _cipher.init(Cipher.ENCRYPT_MODE, sharedKey, _secureRandom); +- else +- _cipher.init(Cipher.ENCRYPT_MODE, sharedKey); +- +- _cipherOut = new CipherOutputStream(_bodyOut, _cipher); +- } catch (RuntimeException e) { +- throw e; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- public void write(int ch) +- throws IOException +- { +- _cipherOut.write(ch); +- } +- +- public void write(byte []buffer, int offset, int length) +- throws IOException +- { +- _cipherOut.write(buffer, offset, length); +- } +- +- public void close() +- throws IOException +- { +- Hessian2Output out = _out; +- _out = null; +- +- if (out != null) { +- _cipherOut.close(); +- _bodyOut.close(); +- +- out.writeInt(0); +- out.completeEnvelope(); +- out.close(); +- } +- } +- } +- +- class EncryptInputStream extends InputStream { +- private Hessian2Input _in; +- +- private Cipher _cipher; +- private InputStream _bodyIn; +- private CipherInputStream _cipherIn; +- +- EncryptInputStream(Hessian2Input in) +- throws IOException +- { +- try { +- _in = in; +- +- byte []fingerprint = null; +- String keyAlgorithm = null; +- String algorithm = null; +- byte []encKey = null; +- +- int len = in.readInt(); +- +- for (int i = 0; i < len; i++) { +- String header = in.readString(); +- +- if ("fingerprint".equals(header)) +- fingerprint = in.readBytes(); +- else if ("key-algorithm".equals(header)) +- keyAlgorithm = in.readString(); +- else if ("algorithm".equals(header)) +- algorithm = in.readString(); +- else if ("key".equals(header)) +- encKey = in.readBytes(); +- else +- throw new IOException("'" + header + "' is an unexpected header"); +- } +- +- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); +- keyCipher.init(Cipher.UNWRAP_MODE, _privateKey); +- +- Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); +- _bodyIn = _in.readInputStream(); +- +- _cipher = Cipher.getInstance(algorithm); +- _cipher.init(Cipher.DECRYPT_MODE, key); +- +- _cipherIn = new CipherInputStream(_bodyIn, _cipher); +- } catch (RuntimeException e) { +- throw e; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- public int read() +- throws IOException +- { +- return _cipherIn.read(); +- } +- +- public int read(byte []buffer, int offset, int length) +- throws IOException +- { +- return _cipherIn.read(buffer, offset, length); +- } +- +- public void close() +- throws IOException +- { +- Hessian2Input in = _in; +- _in = null; +- +- if (in != null) { +- _cipherIn.close(); +- _bodyIn.close(); +- +- int len = in.readInt(); +- +- if (len != 0) +- throw new IOException("Unexpected footer"); +- +- in.completeEnvelope(); +- +- in.close(); +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.security; ++ ++import java.security.*; ++import java.security.cert.*; ++import java.util.*; ++import javax.crypto.*; ++ ++import java.io.*; ++ ++import com.caucho.hessian.io.*; ++ ++public class X509Encryption extends HessianEnvelope { ++ private String _algorithm = "AES"; ++ ++ // certificate for encryption/decryption ++ private X509Certificate _cert; ++ ++ // private key for decryption ++ private PrivateKey _privateKey; ++ ++ private SecureRandom _secureRandom; ++ ++ public X509Encryption() ++ { ++ } ++ ++ /** ++ * Sets the encryption algorithm for the content. ++ */ ++ public void setAlgorithm(String algorithm) ++ { ++ if (algorithm == null) ++ throw new NullPointerException(); ++ ++ _algorithm = algorithm; ++ } ++ ++ /** ++ * Gets the encryption algorithm for the content. ++ */ ++ public String getAlgorithm() ++ { ++ return _algorithm; ++ } ++ ++ /** ++ * The X509 certificate to obtain the public key of the recipient. ++ */ ++ public X509Certificate getCertificate() ++ { ++ return _cert; ++ } ++ ++ /** ++ * The X509 certificate to obtain the public key of the recipient. ++ */ ++ public void setCertificate(X509Certificate cert) ++ { ++ _cert = cert; ++ } ++ ++ /** ++ * The private key for decryption. ++ */ ++ public PrivateKey getPrivateKey() ++ { ++ return _privateKey; ++ } ++ ++ /** ++ * The X509 certificate to obtain the public key of the recipient. ++ */ ++ public void setPrivateKey(PrivateKey privateKey) ++ { ++ _privateKey = privateKey; ++ } ++ ++ /** ++ * The random number generator for the shared secrets. ++ */ ++ public SecureRandom getSecureRandom() ++ { ++ return _secureRandom; ++ } ++ ++ /** ++ * The random number generator for the shared secrets. ++ */ ++ public void setSecureRandom(SecureRandom random) ++ { ++ _secureRandom = random; ++ } ++ ++ public Hessian2Output wrap(Hessian2Output out) ++ throws IOException ++ { ++ if (_cert == null) ++ throw new IOException("X509Encryption.wrap requires a certificate"); ++ ++ OutputStream os = new EncryptOutputStream(out); ++ ++ Hessian2Output filterOut = new Hessian2Output(os); ++ ++ filterOut.setCloseStreamOnClose(true); ++ ++ return filterOut; ++ } ++ ++ public Hessian2Input unwrap(Hessian2Input in) ++ throws IOException ++ { ++ if (_privateKey == null) ++ throw new IOException("X509Encryption.unwrap requires a private key"); ++ ++ if (_cert == null) ++ throw new IOException("X509Encryption.unwrap requires a certificate"); ++ ++ int version = in.readEnvelope(); ++ ++ String method = in.readMethod(); ++ ++ if (! method.equals(getClass().getName())) ++ throw new IOException("expected hessian Envelope method '" + ++ getClass().getName() + "' at '" + method + "'"); ++ ++ return unwrapHeaders(in); ++ } ++ ++ public Hessian2Input unwrapHeaders(Hessian2Input in) ++ throws IOException ++ { ++ if (_privateKey == null) ++ throw new IOException("X509Encryption.unwrap requires a private key"); ++ ++ if (_cert == null) ++ throw new IOException("X509Encryption.unwrap requires a certificate"); ++ ++ InputStream is = new EncryptInputStream(in); ++ ++ Hessian2Input filter = new Hessian2Input(is); ++ ++ filter.setCloseStreamOnClose(true); ++ ++ return filter; ++ } ++ ++ class EncryptOutputStream extends OutputStream { ++ private Hessian2Output _out; ++ ++ private Cipher _cipher; ++ private OutputStream _bodyOut; ++ private CipherOutputStream _cipherOut; ++ ++ EncryptOutputStream(Hessian2Output out) ++ throws IOException ++ { ++ try { ++ _out = out; ++ ++ KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); ++ ++ if (_secureRandom != null) ++ keyGen.init(_secureRandom); ++ ++ SecretKey sharedKey = keyGen.generateKey(); ++ ++ _out = out; ++ ++ _out.startEnvelope(X509Encryption.class.getName()); ++ ++ PublicKey publicKey = _cert.getPublicKey(); ++ ++ byte []encoded = publicKey.getEncoded(); ++ MessageDigest md = MessageDigest.getInstance("SHA1"); ++ md.update(encoded); ++ byte []fingerprint = md.digest(); ++ ++ String keyAlgorithm = publicKey.getAlgorithm(); ++ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); ++ if (_secureRandom != null) ++ keyCipher.init(Cipher.WRAP_MODE, _cert, _secureRandom); ++ else ++ keyCipher.init(Cipher.WRAP_MODE, _cert); ++ ++ byte []encKey = keyCipher.wrap(sharedKey); ++ ++ _out.writeInt(4); ++ ++ _out.writeString("algorithm"); ++ _out.writeString(_algorithm); ++ _out.writeString("fingerprint"); ++ _out.writeBytes(fingerprint); ++ _out.writeString("key-algorithm"); ++ _out.writeString(keyAlgorithm); ++ _out.writeString("key"); ++ _out.writeBytes(encKey); ++ ++ _bodyOut = _out.getBytesOutputStream(); ++ ++ _cipher = Cipher.getInstance(_algorithm); ++ if (_secureRandom != null) ++ _cipher.init(Cipher.ENCRYPT_MODE, sharedKey, _secureRandom); ++ else ++ _cipher.init(Cipher.ENCRYPT_MODE, sharedKey); ++ ++ _cipherOut = new CipherOutputStream(_bodyOut, _cipher); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ public void write(int ch) ++ throws IOException ++ { ++ _cipherOut.write(ch); ++ } ++ ++ public void write(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ _cipherOut.write(buffer, offset, length); ++ } ++ ++ public void close() ++ throws IOException ++ { ++ Hessian2Output out = _out; ++ _out = null; ++ ++ if (out != null) { ++ _cipherOut.close(); ++ _bodyOut.close(); ++ ++ out.writeInt(0); ++ out.completeEnvelope(); ++ out.close(); ++ } ++ } ++ } ++ ++ class EncryptInputStream extends InputStream { ++ private Hessian2Input _in; ++ ++ private Cipher _cipher; ++ private InputStream _bodyIn; ++ private CipherInputStream _cipherIn; ++ ++ EncryptInputStream(Hessian2Input in) ++ throws IOException ++ { ++ try { ++ _in = in; ++ ++ byte []fingerprint = null; ++ String keyAlgorithm = null; ++ String algorithm = null; ++ byte []encKey = null; ++ ++ int len = in.readInt(); ++ ++ for (int i = 0; i < len; i++) { ++ String header = in.readString(); ++ ++ if ("fingerprint".equals(header)) ++ fingerprint = in.readBytes(); ++ else if ("key-algorithm".equals(header)) ++ keyAlgorithm = in.readString(); ++ else if ("algorithm".equals(header)) ++ algorithm = in.readString(); ++ else if ("key".equals(header)) ++ encKey = in.readBytes(); ++ else ++ throw new IOException("'" + header + "' is an unexpected header"); ++ } ++ ++ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); ++ keyCipher.init(Cipher.UNWRAP_MODE, _privateKey); ++ ++ Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); ++ _bodyIn = _in.readInputStream(); ++ ++ _cipher = Cipher.getInstance(algorithm); ++ _cipher.init(Cipher.DECRYPT_MODE, key); ++ ++ _cipherIn = new CipherInputStream(_bodyIn, _cipher); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ public int read() ++ throws IOException ++ { ++ return _cipherIn.read(); ++ } ++ ++ public int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ return _cipherIn.read(buffer, offset, length); ++ } ++ ++ public void close() ++ throws IOException ++ { ++ Hessian2Input in = _in; ++ _in = null; ++ ++ if (in != null) { ++ _cipherIn.close(); ++ _bodyIn.close(); ++ ++ int len = in.readInt(); ++ ++ if (len != 0) ++ throw new IOException("Unexpected footer"); ++ ++ in.completeEnvelope(); ++ ++ in.close(); ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/security/X509Signature.java hessian-4.0.65-fix/com/caucho/hessian/security/X509Signature.java +--- hessian-4.0.65-src/com/caucho/hessian/security/X509Signature.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/security/X509Signature.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,397 +1,397 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.security; +- +-import java.security.*; +-import java.security.cert.*; +-import java.util.*; +-import javax.crypto.*; +- +-import java.io.*; +- +-import com.caucho.hessian.io.*; +- +-public class X509Signature extends HessianEnvelope { +- private String _algorithm = "HmacSHA256"; +- private X509Certificate _cert; +- private PrivateKey _privateKey; +- private SecureRandom _secureRandom; +- +- public X509Signature() +- { +- } +- +- /** +- * Sets the encryption algorithm for the content. +- */ +- public void setAlgorithm(String algorithm) +- { +- if (algorithm == null) +- throw new NullPointerException(); +- +- _algorithm = algorithm; +- } +- +- /** +- * Gets the encryption algorithm for the content. +- */ +- public String getAlgorithm() +- { +- return _algorithm; +- } +- +- /** +- * The X509 certificate to obtain the public key of the recipient. +- */ +- public X509Certificate getCertificate() +- { +- return _cert; +- } +- +- /** +- * The X509 certificate to obtain the public key of the recipient. +- */ +- public void setCertificate(X509Certificate cert) +- { +- _cert = cert; +- } +- +- /** +- * The key to obtain the private key of the recipient. +- */ +- public PrivateKey getPrivateKey() +- { +- return _privateKey; +- } +- +- /** +- * The private key. +- */ +- public void setPrivateKey(PrivateKey key) +- { +- _privateKey = key; +- } +- +- /** +- * The random number generator for the shared secrets. +- */ +- public SecureRandom getSecureRandom() +- { +- return _secureRandom; +- } +- +- /** +- * The random number generator for the shared secrets. +- */ +- public void setSecureRandom(SecureRandom random) +- { +- _secureRandom = random; +- } +- +- public Hessian2Output wrap(Hessian2Output out) +- throws IOException +- { +- if (_privateKey == null) +- throw new IOException("X509Signature.wrap requires a private key"); +- +- if (_cert == null) +- throw new IOException("X509Signature.wrap requires a certificate"); +- +- OutputStream os = new SignatureOutputStream(out); +- +- Hessian2Output filterOut = new Hessian2Output(os); +- +- filterOut.setCloseStreamOnClose(true); +- +- return filterOut; +- } +- +- public Hessian2Input unwrap(Hessian2Input in) +- throws IOException +- { +- if (_cert == null) +- throw new IOException("X509Signature.unwrap requires a certificate"); +- +- int version = in.readEnvelope(); +- +- String method = in.readMethod(); +- +- if (! method.equals(getClass().getName())) +- throw new IOException("expected hessian Envelope method '" + +- getClass().getName() + "' at '" + method + "'"); +- +- return unwrapHeaders(in); +- } +- +- public Hessian2Input unwrapHeaders(Hessian2Input in) +- throws IOException +- { +- if (_cert == null) +- throw new IOException("X509Signature.unwrap requires a certificate"); +- +- InputStream is = new SignatureInputStream(in); +- +- Hessian2Input filter = new Hessian2Input(is); +- +- filter.setCloseStreamOnClose(true); +- +- return filter; +- } +- +- class SignatureOutputStream extends OutputStream { +- private Hessian2Output _out; +- private OutputStream _bodyOut; +- private Mac _mac; +- +- SignatureOutputStream(Hessian2Output out) +- throws IOException +- { +- try { +- KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); +- +- if (_secureRandom != null) +- keyGen.init(_secureRandom); +- +- SecretKey sharedKey = keyGen.generateKey(); +- +- _out = out; +- +- _out.startEnvelope(X509Signature.class.getName()); +- +- PublicKey publicKey = _cert.getPublicKey(); +- +- byte []encoded = publicKey.getEncoded(); +- MessageDigest md = MessageDigest.getInstance("SHA1"); +- md.update(encoded); +- byte []fingerprint = md.digest(); +- +- String keyAlgorithm = _privateKey.getAlgorithm(); +- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); +- keyCipher.init(Cipher.WRAP_MODE, _privateKey); +- +- byte []encKey = keyCipher.wrap(sharedKey); +- +- _out.writeInt(4); +- _out.writeString("algorithm"); +- _out.writeString(_algorithm); +- _out.writeString("fingerprint"); +- _out.writeBytes(fingerprint); +- _out.writeString("key-algorithm"); +- _out.writeString(keyAlgorithm); +- _out.writeString("key"); +- _out.writeBytes(encKey); +- +- _mac = Mac.getInstance(_algorithm); +- _mac.init(sharedKey); +- +- _bodyOut = _out.getBytesOutputStream(); +- } catch (RuntimeException e) { +- throw e; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- public void write(int ch) +- throws IOException +- { +- _bodyOut.write(ch); +- _mac.update((byte) ch); +- } +- +- public void write(byte []buffer, int offset, int length) +- throws IOException +- { +- _bodyOut.write(buffer, offset, length); +- _mac.update(buffer, offset, length); +- } +- +- public void close() +- throws IOException +- { +- Hessian2Output out = _out; +- _out = null; +- +- if (out == null) +- return; +- +- _bodyOut.close(); +- +- byte []sig = _mac.doFinal(); +- +- out.writeInt(1); +- out.writeString("signature"); +- out.writeBytes(sig); +- +- out.completeEnvelope(); +- out.close(); +- } +- } +- +- class SignatureInputStream extends InputStream { +- private Hessian2Input _in; +- +- private Mac _mac; +- private InputStream _bodyIn; +- private CipherInputStream _cipherIn; +- +- SignatureInputStream(Hessian2Input in) +- throws IOException +- { +- try { +- _in = in; +- +- byte []fingerprint = null; +- String keyAlgorithm = null; +- String algorithm = null; +- byte []encKey = null; +- +- int len = in.readInt(); +- +- for (int i = 0; i < len; i++) { +- String header = in.readString(); +- +- if ("fingerprint".equals(header)) +- fingerprint = in.readBytes(); +- else if ("key-algorithm".equals(header)) +- keyAlgorithm = in.readString(); +- else if ("algorithm".equals(header)) +- algorithm = in.readString(); +- else if ("key".equals(header)) +- encKey = in.readBytes(); +- else +- throw new IOException("'" + header + "' is an unexpected header"); +- } +- +- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); +- keyCipher.init(Cipher.UNWRAP_MODE, _cert); +- +- Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); +- _bodyIn = _in.readInputStream(); +- +- _mac = Mac.getInstance(algorithm); +- _mac.init(key); +- } catch (RuntimeException e) { +- throw e; +- } catch (IOException e) { +- throw e; +- } catch (Exception e) { +- throw new RuntimeException(e); +- } +- } +- +- public int read() +- throws IOException +- { +- int ch = _bodyIn.read(); +- +- if (ch < 0) +- return ch; +- +- _mac.update((byte) ch); +- +- return ch; +- } +- +- public int read(byte []buffer, int offset, int length) +- throws IOException +- { +- int len = _bodyIn.read(buffer, offset, length); +- +- if (len < 0) +- return len; +- +- _mac.update(buffer, offset, len); +- +- return len; +- } +- +- public void close() +- throws IOException +- { +- Hessian2Input in = _in; +- _in = null; +- +- if (in != null) { +- _bodyIn.close(); +- +- int len = in.readInt(); +- byte []signature = null; +- +- for (int i = 0; i < len; i++) { +- String header = in.readString(); +- +- if ("signature".equals(header)) +- signature = in.readBytes(); +- } +- +- in.completeEnvelope(); +- in.close(); +- +- +- if (signature == null) +- throw new IOException("Expected signature"); +- +- byte []sig = _mac.doFinal(); +- +- if (sig.length != signature.length) +- throw new IOException("mismatched signature"); +- +- for (int i = 0; i < sig.length; i++) { +- if (signature[i] != sig[i]) +- throw new IOException("mismatched signature"); +- } +- +- // XXX: save principal +- } +- } +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.security; ++ ++import java.security.*; ++import java.security.cert.*; ++import java.util.*; ++import javax.crypto.*; ++ ++import java.io.*; ++ ++import com.caucho.hessian.io.*; ++ ++public class X509Signature extends HessianEnvelope { ++ private String _algorithm = "HmacSHA256"; ++ private X509Certificate _cert; ++ private PrivateKey _privateKey; ++ private SecureRandom _secureRandom; ++ ++ public X509Signature() ++ { ++ } ++ ++ /** ++ * Sets the encryption algorithm for the content. ++ */ ++ public void setAlgorithm(String algorithm) ++ { ++ if (algorithm == null) ++ throw new NullPointerException(); ++ ++ _algorithm = algorithm; ++ } ++ ++ /** ++ * Gets the encryption algorithm for the content. ++ */ ++ public String getAlgorithm() ++ { ++ return _algorithm; ++ } ++ ++ /** ++ * The X509 certificate to obtain the public key of the recipient. ++ */ ++ public X509Certificate getCertificate() ++ { ++ return _cert; ++ } ++ ++ /** ++ * The X509 certificate to obtain the public key of the recipient. ++ */ ++ public void setCertificate(X509Certificate cert) ++ { ++ _cert = cert; ++ } ++ ++ /** ++ * The key to obtain the private key of the recipient. ++ */ ++ public PrivateKey getPrivateKey() ++ { ++ return _privateKey; ++ } ++ ++ /** ++ * The private key. ++ */ ++ public void setPrivateKey(PrivateKey key) ++ { ++ _privateKey = key; ++ } ++ ++ /** ++ * The random number generator for the shared secrets. ++ */ ++ public SecureRandom getSecureRandom() ++ { ++ return _secureRandom; ++ } ++ ++ /** ++ * The random number generator for the shared secrets. ++ */ ++ public void setSecureRandom(SecureRandom random) ++ { ++ _secureRandom = random; ++ } ++ ++ public Hessian2Output wrap(Hessian2Output out) ++ throws IOException ++ { ++ if (_privateKey == null) ++ throw new IOException("X509Signature.wrap requires a private key"); ++ ++ if (_cert == null) ++ throw new IOException("X509Signature.wrap requires a certificate"); ++ ++ OutputStream os = new SignatureOutputStream(out); ++ ++ Hessian2Output filterOut = new Hessian2Output(os); ++ ++ filterOut.setCloseStreamOnClose(true); ++ ++ return filterOut; ++ } ++ ++ public Hessian2Input unwrap(Hessian2Input in) ++ throws IOException ++ { ++ if (_cert == null) ++ throw new IOException("X509Signature.unwrap requires a certificate"); ++ ++ int version = in.readEnvelope(); ++ ++ String method = in.readMethod(); ++ ++ if (! method.equals(getClass().getName())) ++ throw new IOException("expected hessian Envelope method '" + ++ getClass().getName() + "' at '" + method + "'"); ++ ++ return unwrapHeaders(in); ++ } ++ ++ public Hessian2Input unwrapHeaders(Hessian2Input in) ++ throws IOException ++ { ++ if (_cert == null) ++ throw new IOException("X509Signature.unwrap requires a certificate"); ++ ++ InputStream is = new SignatureInputStream(in); ++ ++ Hessian2Input filter = new Hessian2Input(is); ++ ++ filter.setCloseStreamOnClose(true); ++ ++ return filter; ++ } ++ ++ class SignatureOutputStream extends OutputStream { ++ private Hessian2Output _out; ++ private OutputStream _bodyOut; ++ private Mac _mac; ++ ++ SignatureOutputStream(Hessian2Output out) ++ throws IOException ++ { ++ try { ++ KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); ++ ++ if (_secureRandom != null) ++ keyGen.init(_secureRandom); ++ ++ SecretKey sharedKey = keyGen.generateKey(); ++ ++ _out = out; ++ ++ _out.startEnvelope(X509Signature.class.getName()); ++ ++ PublicKey publicKey = _cert.getPublicKey(); ++ ++ byte []encoded = publicKey.getEncoded(); ++ MessageDigest md = MessageDigest.getInstance("SHA1"); ++ md.update(encoded); ++ byte []fingerprint = md.digest(); ++ ++ String keyAlgorithm = _privateKey.getAlgorithm(); ++ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); ++ keyCipher.init(Cipher.WRAP_MODE, _privateKey); ++ ++ byte []encKey = keyCipher.wrap(sharedKey); ++ ++ _out.writeInt(4); ++ _out.writeString("algorithm"); ++ _out.writeString(_algorithm); ++ _out.writeString("fingerprint"); ++ _out.writeBytes(fingerprint); ++ _out.writeString("key-algorithm"); ++ _out.writeString(keyAlgorithm); ++ _out.writeString("key"); ++ _out.writeBytes(encKey); ++ ++ _mac = Mac.getInstance(_algorithm); ++ _mac.init(sharedKey); ++ ++ _bodyOut = _out.getBytesOutputStream(); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ public void write(int ch) ++ throws IOException ++ { ++ _bodyOut.write(ch); ++ _mac.update((byte) ch); ++ } ++ ++ public void write(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ _bodyOut.write(buffer, offset, length); ++ _mac.update(buffer, offset, length); ++ } ++ ++ public void close() ++ throws IOException ++ { ++ Hessian2Output out = _out; ++ _out = null; ++ ++ if (out == null) ++ return; ++ ++ _bodyOut.close(); ++ ++ byte []sig = _mac.doFinal(); ++ ++ out.writeInt(1); ++ out.writeString("signature"); ++ out.writeBytes(sig); ++ ++ out.completeEnvelope(); ++ out.close(); ++ } ++ } ++ ++ class SignatureInputStream extends InputStream { ++ private Hessian2Input _in; ++ ++ private Mac _mac; ++ private InputStream _bodyIn; ++ private CipherInputStream _cipherIn; ++ ++ SignatureInputStream(Hessian2Input in) ++ throws IOException ++ { ++ try { ++ _in = in; ++ ++ byte []fingerprint = null; ++ String keyAlgorithm = null; ++ String algorithm = null; ++ byte []encKey = null; ++ ++ int len = in.readInt(); ++ ++ for (int i = 0; i < len; i++) { ++ String header = in.readString(); ++ ++ if ("fingerprint".equals(header)) ++ fingerprint = in.readBytes(); ++ else if ("key-algorithm".equals(header)) ++ keyAlgorithm = in.readString(); ++ else if ("algorithm".equals(header)) ++ algorithm = in.readString(); ++ else if ("key".equals(header)) ++ encKey = in.readBytes(); ++ else ++ throw new IOException("'" + header + "' is an unexpected header"); ++ } ++ ++ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); ++ keyCipher.init(Cipher.UNWRAP_MODE, _cert); ++ ++ Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); ++ _bodyIn = _in.readInputStream(); ++ ++ _mac = Mac.getInstance(algorithm); ++ _mac.init(key); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ public int read() ++ throws IOException ++ { ++ int ch = _bodyIn.read(); ++ ++ if (ch < 0) ++ return ch; ++ ++ _mac.update((byte) ch); ++ ++ return ch; ++ } ++ ++ public int read(byte []buffer, int offset, int length) ++ throws IOException ++ { ++ int len = _bodyIn.read(buffer, offset, length); ++ ++ if (len < 0) ++ return len; ++ ++ _mac.update(buffer, offset, len); ++ ++ return len; ++ } ++ ++ public void close() ++ throws IOException ++ { ++ Hessian2Input in = _in; ++ _in = null; ++ ++ if (in != null) { ++ _bodyIn.close(); ++ ++ int len = in.readInt(); ++ byte []signature = null; ++ ++ for (int i = 0; i < len; i++) { ++ String header = in.readString(); ++ ++ if ("signature".equals(header)) ++ signature = in.readBytes(); ++ } ++ ++ in.completeEnvelope(); ++ in.close(); ++ ++ ++ if (signature == null) ++ throw new IOException("Expected signature"); ++ ++ byte []sig = _mac.doFinal(); ++ ++ if (sig.length != signature.length) ++ throw new IOException("mismatched signature"); ++ ++ for (int i = 0; i < sig.length; i++) { ++ if (signature[i] != sig[i]) ++ throw new IOException("mismatched signature"); ++ } ++ ++ // XXX: save principal ++ } ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/server/HessianDispatcher.java hessian-4.0.65-fix/com/caucho/hessian/server/HessianDispatcher.java +--- hessian-4.0.65-src/com/caucho/hessian/server/HessianDispatcher.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/server/HessianDispatcher.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,337 @@ ++ ++package com.caucho.hessian.server; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.PrintWriter; ++import java.io.Writer; ++import java.util.Map; ++import java.util.Properties; ++import java.util.concurrent.ConcurrentHashMap; ++import java.util.logging.Logger; ++ ++import javax.servlet.GenericServlet; ++import javax.servlet.Servlet; ++import javax.servlet.ServletConfig; ++import javax.servlet.ServletException; ++import javax.servlet.ServletRequest; ++import javax.servlet.ServletResponse; ++import javax.servlet.http.HttpServletRequest; ++import javax.servlet.http.HttpServletResponse; ++ ++import org.springframework.context.ApplicationContext; ++import org.springframework.web.context.support.WebApplicationContextUtils; ++ ++import com.caucho.hessian.io.Hessian2Input; ++import com.caucho.hessian.io.SerializerFactory; ++import com.caucho.services.server.Service; ++import com.caucho.services.server.ServiceContext; ++ ++ ++public class HessianDispatcher extends GenericServlet ++{ ++ ++ ++ private static final long serialVersionUID = -8611469561907416355L; ++ ++ private SerializerFactory _serializerFactory; ++ ++ private static final String SERVICE_FILE_PATH = "config-file"; ++ ++ private static Map registry = new ConcurrentHashMap(); ++ ++ private static Properties props = new Properties(); ++ ++ public HessianDispatcher() ++ { ++ } ++ ++ public String getServletInfo() ++ { ++ return "Hessian Dispatcher"; ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(); ++ ++ return _serializerFactory; ++ } ++ ++ /** ++ * Sets the serializer send collection java type. ++ */ ++ public void setSendCollectionType(boolean sendType) ++ { ++ getSerializerFactory().setSendCollectionType(sendType); ++ } ++ ++ /** ++ * Initialize the service, including the service object. ++ */ ++ public void init(ServletConfig config) throws ServletException ++ { ++ super.init(config); ++ ++ try ++ { ++ String serviceConfigFile = getInitParameter(SERVICE_FILE_PATH); ++ ++ if (null == serviceConfigFile) ++ { ++ throw new ServletException( ++ "Hessian service registry file path must be set in classpath when using 'HessianDispatcher'"); ++ } ++ ++ props.load(this.getClass().getClassLoader() ++ .getResourceAsStream(serviceConfigFile)); ++ } ++ ++ catch (Exception e) ++ { ++ throw new ServletException(e); ++ } ++ } ++ ++ private Class loadClass(String className) throws ClassNotFoundException ++ { ++ ClassLoader loader = getContextClassLoader(); ++ ++ if (loader != null) ++ return Class.forName(className, false, loader); ++ else ++ return Class.forName(className); ++ } ++ ++ protected ClassLoader getContextClassLoader() ++ { ++ return Thread.currentThread().getContextClassLoader(); ++ } ++ ++ private void init(Object service) throws ServletException ++ { ++ if (!this.getClass().equals(HessianDispatcher.class)) ++ { ++ } ++ else if (service instanceof Service) ++ ((Service) service).init(getServletConfig()); ++ else if (service instanceof Servlet) ++ ((Servlet) service).init(getServletConfig()); ++ } ++ ++ /** ++ * Execute a request. The path-info of the request selects the bean. Once ++ * the bean's selected, it will be applied. ++ */ ++ public void service(ServletRequest request, ServletResponse response) ++ throws IOException, ServletException ++ { ++ HttpServletRequest req = (HttpServletRequest) request; ++ HttpServletResponse res = (HttpServletResponse) response; ++ ++ if (!req.getMethod().equals("POST")) ++ { ++ res.setStatus(500, "Hessian Requires POST"); ++ PrintWriter out = res.getWriter(); ++ ++ res.setContentType("text/html"); ++ out.println("

Hessian Requires POST

"); ++ ++ return; ++ } ++ ++ String serviceInterface = req.getHeader("Interface-Name"); ++ ++ if (null == serviceInterface) ++ { ++ throw new ServletException( ++ "The service interface you reqeust is null. please check the client setting."); ++ } ++ ++ try ++ { ++ HessianSkeleton skeleton = findHessianSkeleton(serviceInterface); ++ ++ String serviceId = req.getPathInfo(); ++ ++ String objectId = req.getParameter("id"); ++ ++ if (objectId == null) ++ objectId = req.getParameter("ejbid"); ++ ++ ServiceContext.begin(req, serviceId, objectId); ++ ++ InputStream is = request.getInputStream(); ++ ++ OutputStream os = response.getOutputStream(); ++ ++ response.setContentType("application/x-hessian"); ++ ++ SerializerFactory serializerFactory = getSerializerFactory(); ++ ++ invoke(is, os, skeleton, serializerFactory); ++ } ++ catch (RuntimeException e) ++ { ++ throw e; ++ } ++ catch (ServletException e) ++ { ++ throw e; ++ } ++ catch (Throwable e) ++ { ++ throw new ServletException(e); ++ } ++ finally ++ { ++ ServiceContext.end(); ++ } ++ } ++ ++ ++ private HessianSkeleton findHessianSkeleton(String serviceInterface) ++ throws ServletException, ClassNotFoundException, ++ IllegalAccessException, InstantiationException ++ { ++ HessianSkeleton skeleton = null; ++ ++ if (registry.containsKey(serviceInterface))// find in cache first ++ { ++ skeleton = registry.get(serviceInterface); ++ } ++ else ++ // parse serviceImpl string to create skeleton. ++ { ++ String serviceImpl = (String) this.props.get(serviceInterface); ++ ++ if (null == serviceImpl) ++ { ++ throw new ServletException( ++ "Your request service of " ++ + serviceInterface ++ + " dose not exsit.please check the server configuration."); ++ } ++ if (serviceImpl.startsWith("#"))// for get bean from spring ++ { ++ skeleton = findSpringSkeleton(serviceInterface, serviceImpl); ++ } ++ else ++ { ++ skeleton = findLocalSkeleton(serviceInterface, serviceImpl); ++ } ++ ++ } ++ ++ registry.put(serviceInterface, skeleton); ++ ++ return skeleton; ++ } ++ ++ ++ private HessianSkeleton findLocalSkeleton(String serviceInterface, ++ String serviceImpl) throws ClassNotFoundException, ++ InstantiationException, IllegalAccessException, ServletException ++ { ++ HessianSkeleton skeleton; ++ Class homeClass = loadClass(serviceImpl); ++ ++ Object localBean = homeClass.newInstance(); ++ ++ init(localBean); ++ ++ skeleton = new HessianSkeleton(localBean, loadClass(serviceInterface)); ++ return skeleton; ++ } ++ ++ ++ private HessianSkeleton findSpringSkeleton(String serviceInterface, ++ String serviceImpl) throws ServletException, ClassNotFoundException ++ { ++ HessianSkeleton skeleton; ++ String beanId = serviceImpl.substring(1, serviceImpl.length()); ++ ++ ApplicationContext wac = WebApplicationContextUtils ++ .getWebApplicationContext(getServletContext()); ++ ++ Object springBean = wac.getBean(beanId.trim()); ++ ++ init(springBean); ++ ++ skeleton = new HessianSkeleton(springBean, loadClass(serviceInterface)); ++ ++ return skeleton; ++ } ++ ++ protected void invoke(InputStream is, OutputStream os, ++ HessianSkeleton skeleton, SerializerFactory serializerFactory) ++ throws Exception ++ { ++ skeleton.invoke(is, os, serializerFactory); ++ } ++ ++ protected Hessian2Input createHessian2Input(InputStream is) ++ { ++ return new Hessian2Input(is); ++ } ++ ++ static class LogWriter extends Writer ++ { ++ private Logger _log; ++ ++ private StringBuilder _sb = new StringBuilder(); ++ ++ LogWriter(Logger log) ++ { ++ _log = log; ++ } ++ ++ public void write(char ch) ++ { ++ if (ch == '\n' && _sb.length() > 0) ++ { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ ++ public void write(char[] buffer, int offset, int length) ++ { ++ for (int i = 0; i < length; i++) ++ { ++ char ch = buffer[offset + i]; ++ ++ if (ch == '\n' && _sb.length() > 0) ++ { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ } ++ ++ public void flush() ++ { ++ } ++ ++ public void close() ++ { ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/server/HessianServlet.java hessian-4.0.65-fix/com/caucho/hessian/server/HessianServlet.java +--- hessian-4.0.65-src/com/caucho/hessian/server/HessianServlet.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/server/HessianServlet.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,477 +1,551 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.server; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.PrintWriter; +-import java.io.Writer; +-import java.util.logging.Logger; +- +-import javax.servlet.GenericServlet; +-import javax.servlet.Servlet; +-import javax.servlet.ServletConfig; +-import javax.servlet.ServletException; +-import javax.servlet.ServletRequest; +-import javax.servlet.ServletResponse; +-import javax.servlet.http.HttpServlet; +-import javax.servlet.http.HttpServletRequest; +-import javax.servlet.http.HttpServletResponse; +- +-import com.caucho.hessian.io.Hessian2Input; +-import com.caucho.hessian.io.SerializerFactory; +-import com.caucho.services.server.Service; +-import com.caucho.services.server.ServiceContext; +- +-/** +- * Servlet for serving Hessian services. +- * +- * Applications can use ServletContext inside a Hessian service to get +- * ServletRequest, ServletResponse and session information. +- */ +-@SuppressWarnings("serial") +-public class HessianServlet extends HttpServlet { +- private Class _homeAPI; +- private Object _homeImpl; +- +- private Class _objectAPI; +- private Object _objectImpl; +- +- private HessianSkeleton _homeSkeleton; +- private HessianSkeleton _objectSkeleton; +- +- private SerializerFactory _serializerFactory; +- +- public HessianServlet() +- { +- } +- +- public String getServletInfo() +- { +- return "Hessian Servlet"; +- } +- +- /** +- * Sets the home api. +- */ +- public void setHomeAPI(Class api) +- { +- _homeAPI = api; +- } +- +- /** +- * Sets the home implementation +- */ +- public void setHome(Object home) +- { +- _homeImpl = home; +- } +- +- /** +- * Sets the object api. +- */ +- public void setObjectAPI(Class api) +- { +- _objectAPI = api; +- } +- +- /** +- * Sets the object implementation +- */ +- public void setObject(Object object) +- { +- _objectImpl = object; +- } +- +- /** +- * Sets the service class. +- */ +- public void setService(Object service) +- { +- setHome(service); +- } +- +- /** +- * Sets the api-class. +- */ +- public void setAPIClass(Class api) +- { +- setHomeAPI(api); +- } +- +- /** +- * Gets the api-class. +- */ +- public Class getAPIClass() +- { +- return _homeAPI; +- } +- +- /** +- * Sets the serializer factory. +- */ +- public void setSerializerFactory(SerializerFactory factory) +- { +- _serializerFactory = factory; +- } +- +- /** +- * Gets the serializer factory. +- */ +- public SerializerFactory getSerializerFactory() +- { +- if (_serializerFactory == null) +- _serializerFactory = new SerializerFactory(); +- +- return _serializerFactory; +- } +- +- /** +- * Sets the serializer send collection java type. +- */ +- public void setSendCollectionType(boolean sendType) +- { +- getSerializerFactory().setSendCollectionType(sendType); +- } +- +- /** +- * Sets whitelist mode for the deserializer +- */ +- public void setWhitelist(boolean isWhitelist) +- { +- getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); +- } +- +- /** +- * Adds an allow rule to the deserializer +- * +- * Examples: "java.util.*", "com.foo.io.Bean" +- */ +- public void allow(String pattern) +- { +- getSerializerFactory().getClassFactory().allow(pattern); +- } +- +- /** +- * Adds a deny rule to the deserializer +- */ +- public void deny(String pattern) +- { +- getSerializerFactory().getClassFactory().deny(pattern); +- } +- +- /** +- * Sets the debugging flag. +- */ +- public void setDebug(boolean isDebug) +- { +- } +- +- /** +- * Sets the debugging log name. +- */ +- public void setLogName(String name) +- { +- // _log = Logger.getLogger(name); +- } +- +- /** +- * Initialize the service, including the service object. +- */ +- public void init(ServletConfig config) +- throws ServletException +- { +- super.init(config); +- +- try { +- if (_homeImpl != null) { +- } +- else if (getInitParameter("home-class") != null) { +- String className = getInitParameter("home-class"); +- +- Class homeClass = loadClass(className); +- +- _homeImpl = homeClass.newInstance(); +- +- init(_homeImpl); +- } +- else if (getInitParameter("service-class") != null) { +- String className = getInitParameter("service-class"); +- +- Class homeClass = loadClass(className); +- +- _homeImpl = homeClass.newInstance(); +- +- init(_homeImpl); +- } +- else { +- if (getClass().equals(HessianServlet.class)) +- throw new ServletException("server must extend HessianServlet"); +- +- _homeImpl = this; +- } +- +- if (_homeAPI != null) { +- } +- else if (getInitParameter("home-api") != null) { +- String className = getInitParameter("home-api"); +- +- _homeAPI = loadClass(className); +- } +- else if (getInitParameter("api-class") != null) { +- String className = getInitParameter("api-class"); +- +- _homeAPI = loadClass(className); +- } +- else if (_homeImpl != null) { +- _homeAPI = findRemoteAPI(_homeImpl.getClass()); +- +- if (_homeAPI == null) +- _homeAPI = _homeImpl.getClass(); +- +- _homeAPI = _homeImpl.getClass(); +- } +- +- if (_objectImpl != null) { +- } +- else if (getInitParameter("object-class") != null) { +- String className = getInitParameter("object-class"); +- +- Class objectClass = loadClass(className); +- +- _objectImpl = objectClass.newInstance(); +- +- init(_objectImpl); +- } +- +- if (_objectAPI != null) { +- } +- else if (getInitParameter("object-api") != null) { +- String className = getInitParameter("object-api"); +- +- _objectAPI = loadClass(className); +- } +- else if (_objectImpl != null) +- _objectAPI = _objectImpl.getClass(); +- +- _homeSkeleton = new HessianSkeleton(_homeImpl, _homeAPI); +- +- if (_objectAPI != null) +- _homeSkeleton.setObjectClass(_objectAPI); +- +- if (_objectImpl != null) { +- _objectSkeleton = new HessianSkeleton(_objectImpl, _objectAPI); +- _objectSkeleton.setHomeClass(_homeAPI); +- } +- else +- _objectSkeleton = _homeSkeleton; +- +- if ("true".equals(getInitParameter("debug"))) { +- } +- +- if ("false".equals(getInitParameter("send-collection-type"))) +- setSendCollectionType(false); +- } catch (ServletException e) { +- throw e; +- } catch (Exception e) { +- throw new ServletException(e); +- } +- } +- +- private Class findRemoteAPI(Class implClass) +- { +- // hessian/34d0 +- return null; +- +- /* +- if (implClass == null || implClass.equals(GenericService.class)) +- return null; +- +- Class []interfaces = implClass.getInterfaces(); +- +- if (interfaces.length == 1) +- return interfaces[0]; +- +- return findRemoteAPI(implClass.getSuperclass()); +- */ +- } +- +- private Class loadClass(String className) +- throws ClassNotFoundException +- { +- ClassLoader loader = getContextClassLoader(); +- +- if (loader != null) +- return Class.forName(className, false, loader); +- else +- return Class.forName(className); +- } +- +- protected ClassLoader getContextClassLoader() +- { +- return Thread.currentThread().getContextClassLoader(); +- } +- +- private void init(Object service) +- throws ServletException +- { +- if (! this.getClass().equals(HessianServlet.class)) { +- } +- else if (service instanceof Service) +- ((Service) service).init(getServletConfig()); +- else if (service instanceof Servlet) +- ((Servlet) service).init(getServletConfig()); +- } +- +- /** +- * Execute a request. The path-info of the request selects the bean. +- * Once the bean's selected, it will be applied. +- */ +- public void service(ServletRequest request, ServletResponse response) +- throws IOException, ServletException +- { +- HttpServletRequest req = (HttpServletRequest) request; +- HttpServletResponse res = (HttpServletResponse) response; +- +- if (! req.getMethod().equals("POST")) { +- res.setStatus(500); // , "Hessian Requires POST"); +- PrintWriter out = res.getWriter(); +- +- res.setContentType("text/html"); +- out.println("

Hessian Requires POST

"); +- +- return; +- } +- +- String serviceId = req.getPathInfo(); +- String objectId = req.getParameter("id"); +- if (objectId == null) +- objectId = req.getParameter("ejbid"); +- +- ServiceContext.begin(req, res, serviceId, objectId); +- +- try { +- InputStream is = request.getInputStream(); +- OutputStream os = response.getOutputStream(); +- +- response.setContentType("x-application/hessian"); +- +- SerializerFactory serializerFactory = getSerializerFactory(); +- +- invoke(is, os, objectId, serializerFactory); +- } catch (RuntimeException e) { +- throw e; +- } catch (ServletException e) { +- throw e; +- } catch (Throwable e) { +- throw new ServletException(e); +- } finally { +- ServiceContext.end(); +- } +- } +- +- protected void invoke(InputStream is, OutputStream os, +- String objectId, +- SerializerFactory serializerFactory) +- throws Exception +- { +- if (objectId != null) +- _objectSkeleton.invoke(is, os, serializerFactory); +- else +- _homeSkeleton.invoke(is, os, serializerFactory); +- } +- +- protected Hessian2Input createHessian2Input(InputStream is) +- { +- return new Hessian2Input(is); +- } +- +- static class LogWriter extends Writer { +- private Logger _log; +- private StringBuilder _sb = new StringBuilder(); +- +- LogWriter(Logger log) +- { +- _log = log; +- } +- +- public void write(char ch) +- { +- if (ch == '\n' && _sb.length() > 0) { +- _log.fine(_sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- +- public void write(char []buffer, int offset, int length) +- { +- for (int i = 0; i < length; i++) { +- char ch = buffer[offset + i]; +- +- if (ch == '\n' && _sb.length() > 0) { +- _log.fine(_sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- } +- +- public void flush() +- { +- } +- +- public void close() +- { +- } +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.server; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.PrintWriter; ++import java.io.Writer; ++import java.util.logging.Logger; ++ ++import javax.servlet.GenericServlet; ++import javax.servlet.Servlet; ++import javax.servlet.ServletConfig; ++import javax.servlet.ServletException; ++import javax.servlet.ServletRequest; ++import javax.servlet.ServletResponse; ++import javax.servlet.http.HttpServlet; ++import javax.servlet.http.HttpServletRequest; ++import javax.servlet.http.HttpServletResponse; ++ ++import org.springframework.context.ApplicationContext; ++import org.springframework.web.context.support.WebApplicationContextUtils; ++ ++import com.caucho.hessian.io.Hessian2Input; ++import com.caucho.hessian.io.SerializerFactory; ++import com.caucho.services.server.GenericService; ++import com.caucho.services.server.Service; ++import com.caucho.services.server.ServiceContext; ++ ++/** ++ * Servlet for serving Hessian services. ++ * ++ * Applications can use ServletContext inside a Hessian service to get ++ * ServletRequest, ServletResponse and session information. ++ */ ++@SuppressWarnings("serial") ++public class HessianServlet extends HttpServlet { ++ private static final long serialVersionUID = 1345616653808440850L; ++ private Logger _log = Logger.getLogger(HessianServlet.class.getName()); ++ private Class _homeAPI; ++ private Object _homeImpl; ++ ++ private Class _objectAPI; ++ private Object _objectImpl; ++ ++ private HessianSkeleton _homeSkeleton; ++ private HessianSkeleton _objectSkeleton; ++ ++ private SerializerFactory _serializerFactory; ++ private boolean _isDebug; ++ ++ public HessianServlet() ++ { ++ } ++ ++ public String getServletInfo() ++ { ++ return "Hessian Servlet"; ++ } ++ ++ /** ++ * Sets the home api. ++ */ ++ public void setHomeAPI(Class api) ++ { ++ _homeAPI = api; ++ } ++ ++ /** ++ * Sets the home implementation ++ */ ++ public void setHome(Object home) ++ { ++ _homeImpl = home; ++ } ++ ++ /** ++ * Sets the object api. ++ */ ++ public void setObjectAPI(Class api) ++ { ++ _objectAPI = api; ++ } ++ ++ /** ++ * Sets the object implementation ++ */ ++ public void setObject(Object object) ++ { ++ _objectImpl = object; ++ } ++ ++ /** ++ * Sets the service class. ++ */ ++ public void setService(Object service) ++ { ++ setHome(service); ++ } ++ ++ /** ++ * Sets the api-class. ++ */ ++ public void setAPIClass(Class api) ++ { ++ setHomeAPI(api); ++ } ++ ++ /** ++ * Gets the api-class. ++ */ ++ public Class getAPIClass() ++ { ++ return _homeAPI; ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(); ++ ++ return _serializerFactory; ++ } ++ ++ /** ++ * Sets the serializer send collection java type. ++ */ ++ public void setSendCollectionType(boolean sendType) ++ { ++ getSerializerFactory().setSendCollectionType(sendType); ++ } ++ ++ /** ++ * Sets whitelist mode for the deserializer ++ */ ++ public void setWhitelist(boolean isWhitelist) ++ { ++ getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); ++ } ++ ++ /** ++ * Adds an allow rule to the deserializer ++ * ++ * Examples: "java.util.*", "com.foo.io.Bean" ++ */ ++ public void allow(String pattern) ++ { ++ getSerializerFactory().getClassFactory().allow(pattern); ++ } ++ ++ /** ++ * Adds a deny rule to the deserializer ++ */ ++ public void deny(String pattern) ++ { ++ getSerializerFactory().getClassFactory().deny(pattern); ++ } ++ ++ /** ++ * Sets the debugging flag. ++ */ ++ public void setDebug(boolean isDebug) ++ { ++ _isDebug = isDebug; ++ } ++ ++ /** ++ * Sets the debugging log name. ++ */ ++ public void setLogName(String name) ++ { ++ _log = Logger.getLogger(name); ++ } ++ ++ /** ++ * Initialize the service, including the service object. ++ */ ++ public void init(ServletConfig config) throws ServletException { ++ super.init(config); ++ ++ try { ++ String homeClassValue = getInitParameter("home-class"); ++ ++ if ((homeClassValue != null) & homeClassValue.startsWith("#")) //for get bean from spring ++ { ++ SpringPrepareForSkeleton(config, homeClassValue); ++ } else { ++ LocalPrepareForSkeleton(); ++ } ++ ++ _homeSkeleton = new HessianSkeleton(_homeImpl, _homeAPI); ++ ++ if (_objectAPI != null) { ++ _homeSkeleton.setObjectClass(_objectAPI); ++ } ++ ++ if (_objectImpl != null) { ++ _objectSkeleton = new HessianSkeleton(_objectImpl, _objectAPI); ++ _objectSkeleton.setHomeClass(_homeAPI); ++ } else { ++ _objectSkeleton = _homeSkeleton; ++ } ++ ++ if ("true".equals(getInitParameter("debug"))) { ++ _isDebug = true; ++ } ++ ++ if ("false".equals(getInitParameter("send-collection-type"))) { ++ setSendCollectionType(false); ++ } ++ } catch (ServletException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new ServletException(e); ++ } ++ } ++ ++ /** ++ * TODO ++ * ++ * @param config ++ * @param homeClassValue ++ * @throws ServletException ++ */ ++ private void SpringPrepareForSkeleton(ServletConfig config, ++ String homeClassValue) ++ throws ClassNotFoundException, InstantiationException, ++ IllegalAccessException, ServletException { ++ if (getInitParameter("home-api") != null) { ++ String className = getInitParameter("home-api"); ++ _homeAPI = loadClass(className); ++ } ++ ++ String beanID = homeClassValue.substring(1, homeClassValue.length()); ++ ApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext()); ++ _homeImpl = wac.getBean(beanID); ++ ++ init(_homeImpl); ++ } ++ ++ /** ++ * @throws ClassNotFoundException ++ * @throws InstantiationException ++ * @throws IllegalAccessException ++ * @throws ServletException ++ */ ++ private void LocalPrepareForSkeleton() ++ throws ClassNotFoundException, InstantiationException, ++ IllegalAccessException, ServletException { ++ ++ if (_homeImpl != null) { ++ } ++ else if (getInitParameter("home-class") != null) { ++ String className = getInitParameter("home-class"); ++ ++ Class homeClass = loadClass(className); ++ ++ _homeImpl = homeClass.newInstance(); ++ ++ init(_homeImpl); ++ } ++ else if (getInitParameter("service-class") != null) { ++ String className = getInitParameter("service-class"); ++ ++ Class homeClass = loadClass(className); ++ ++ _homeImpl = homeClass.newInstance(); ++ ++ init(_homeImpl); ++ } ++ else { ++ if (getClass().equals(HessianServlet.class)) ++ throw new ServletException("server must extend HessianServlet"); ++ ++ _homeImpl = this; ++ } ++ ++ if (_homeAPI != null) { ++ } ++ else if (getInitParameter("home-api") != null) { ++ String className = getInitParameter("home-api"); ++ ++ _homeAPI = loadClass(className); ++ } ++ else if (getInitParameter("api-class") != null) { ++ String className = getInitParameter("api-class"); ++ ++ _homeAPI = loadClass(className); ++ } ++ else if (_homeImpl != null) { ++ _homeAPI = findRemoteAPI(_homeImpl.getClass()); ++ ++ if (_homeAPI == null) ++ _homeAPI = _homeImpl.getClass(); ++ ++ // _homeAPI = _homeImpl.getClass(); ++ } ++ ++ if (_objectImpl != null) { ++ } ++ else if (getInitParameter("object-class") != null) { ++ String className = getInitParameter("object-class"); ++ ++ Class objectClass = loadClass(className); ++ ++ _objectImpl = objectClass.newInstance(); ++ ++ init(_objectImpl); ++ } ++ ++ if (_objectAPI != null) { ++ } ++ else if (getInitParameter("object-api") != null) { ++ String className = getInitParameter("object-api"); ++ ++ _objectAPI = loadClass(className); ++ } ++ else if (_objectImpl != null) ++ _objectAPI = _objectImpl.getClass(); ++ ++ /* _homeSkeleton = new HessianSkeleton(_homeImpl, _homeAPI); ++ ++ if (_objectAPI != null) ++ _homeSkeleton.setObjectClass(_objectAPI); ++ ++ if (_objectImpl != null) { ++ _objectSkeleton = new HessianSkeleton(_objectImpl, _objectAPI); ++ _objectSkeleton.setHomeClass(_homeAPI); ++ } ++ else ++ _objectSkeleton = _homeSkeleton; ++ ++ if ("true".equals(getInitParameter("debug"))) { ++ } ++ ++ if ("false".equals(getInitParameter("send-collection-type"))) ++ setSendCollectionType(false); ++ } catch (ServletException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new ServletException(e); ++ } ++ */ ++ ++ } ++ ++ private Class findRemoteAPI(Class implClass) ++ { ++ ++ if (implClass == null || implClass.equals(GenericService.class)) ++ return null; ++ ++ Class []interfaces = implClass.getInterfaces(); ++ ++ if (interfaces.length == 1) ++ return interfaces[0]; ++ ++ return findRemoteAPI(implClass.getSuperclass()); ++ ++ } ++ ++ private Class loadClass(String className) ++ throws ClassNotFoundException ++ { ++ ClassLoader loader = getContextClassLoader(); ++ ++ if (loader != null) ++ return Class.forName(className, false, loader); ++ else ++ return Class.forName(className); ++ } ++ ++ protected ClassLoader getContextClassLoader() ++ { ++ return Thread.currentThread().getContextClassLoader(); ++ } ++ ++ private void init(Object service) ++ throws ServletException ++ { ++ if (! this.getClass().equals(HessianServlet.class)) { ++ } ++ else if (service instanceof Service) ++ ((Service) service).init(getServletConfig()); ++ else if (service instanceof Servlet) ++ ((Servlet) service).init(getServletConfig()); ++ } ++ ++ /** ++ * Execute a request. The path-info of the request selects the bean. ++ * Once the bean's selected, it will be applied. ++ */ ++ public void service(ServletRequest request, ServletResponse response) ++ throws IOException, ServletException ++ { ++ HttpServletRequest req = (HttpServletRequest) request; ++ HttpServletResponse res = (HttpServletResponse) response; ++ ++ if (! req.getMethod().equals("POST")) { ++ res.setStatus(500); // , "Hessian Requires POST"); ++ PrintWriter out = res.getWriter(); ++ ++ res.setContentType("text/html"); ++ out.println("

Hessian Requires POST

"); ++ ++ return; ++ } ++ ++ String serviceId = req.getPathInfo(); ++ String objectId = req.getParameter("id"); ++ if (objectId == null) ++ objectId = req.getParameter("ejbid"); ++ ++ ServiceContext.begin(req, res, serviceId, objectId); ++ ++ try { ++ InputStream is = request.getInputStream(); ++ OutputStream os = response.getOutputStream(); ++ ++ response.setContentType("x-application/hessian"); ++ ++ SerializerFactory serializerFactory = getSerializerFactory(); ++ ++ invoke(is, os, objectId, serializerFactory); ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (ServletException e) { ++ throw e; ++ } catch (Throwable e) { ++ throw new ServletException(e); ++ } finally { ++ ServiceContext.end(); ++ } ++ } ++ ++ protected void invoke(InputStream is, OutputStream os, ++ String objectId, ++ SerializerFactory serializerFactory) ++ throws Exception ++ { ++ if (objectId != null) ++ _objectSkeleton.invoke(is, os, serializerFactory); ++ else ++ _homeSkeleton.invoke(is, os, serializerFactory); ++ } ++ ++ protected Hessian2Input createHessian2Input(InputStream is) ++ { ++ return new Hessian2Input(is); ++ } ++ ++ static class LogWriter extends Writer { ++ private Logger _log; ++ private StringBuilder _sb = new StringBuilder(); ++ ++ LogWriter(Logger log) ++ { ++ _log = log; ++ } ++ ++ public void write(char ch) ++ { ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ ++ public void write(char []buffer, int offset, int length) ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = buffer[offset + i]; ++ ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ } ++ ++ public void flush() ++ { ++ } ++ ++ public void close() ++ { ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/server/HessianSkeleton.java hessian-4.0.65-fix/com/caucho/hessian/server/HessianSkeleton.java +--- hessian-4.0.65-src/com/caucho/hessian/server/HessianSkeleton.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/server/HessianSkeleton.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,416 +1,416 @@ +-/* +- * Copyright (c) 2001-2009 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.server; +- +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.PrintWriter; +-import java.io.Writer; +-import java.lang.reflect.InvocationTargetException; +-import java.lang.reflect.Method; +-import java.util.logging.Level; +-import java.util.logging.Logger; +- +-import com.caucho.hessian.io.AbstractHessianInput; +-import com.caucho.hessian.io.AbstractHessianOutput; +-import com.caucho.hessian.io.HessianDebugInputStream; +-import com.caucho.hessian.io.HessianDebugOutputStream; +-import com.caucho.hessian.io.HessianFactory; +-import com.caucho.hessian.io.HessianInputFactory; +-import com.caucho.hessian.io.SerializerFactory; +-import com.caucho.services.server.AbstractSkeleton; +-import com.caucho.services.server.ServiceContext; +- +-/** +- * Proxy class for Hessian services. +- */ +-public class HessianSkeleton extends AbstractSkeleton { +- private static final Logger log +- = Logger.getLogger(HessianSkeleton.class.getName()); +- +- private boolean _isDebug; +- +- private HessianInputFactory _inputFactory = new HessianInputFactory(); +- private HessianFactory _hessianFactory = new HessianFactory(); +- +- private Object _service; +- +- /** +- * Create a new hessian skeleton. +- * +- * @param service the underlying service object. +- * @param apiClass the API interface +- */ +- public HessianSkeleton(Object service, Class apiClass) +- { +- super(apiClass); +- +- if (service == null) +- service = this; +- +- _service = service; +- +- if (! apiClass.isAssignableFrom(service.getClass())) +- throw new IllegalArgumentException("Service " + service + " must be an instance of " + apiClass.getName()); +- } +- +- /** +- * Create a new hessian skeleton. +- * +- * @param service the underlying service object. +- * @param apiClass the API interface +- */ +- public HessianSkeleton(Class apiClass) +- { +- super(apiClass); +- } +- +- public void setDebug(boolean isDebug) +- { +- _isDebug = isDebug; +- } +- +- public boolean isDebug() +- { +- return _isDebug; +- } +- +- public void setHessianFactory(HessianFactory factory) +- { +- _hessianFactory = factory; +- } +- +- /** +- * Invoke the object with the request from the input stream. +- * +- * @param in the Hessian input stream +- * @param out the Hessian output stream +- */ +- public void invoke(InputStream is, OutputStream os) +- throws Exception +- { +- invoke(is, os, null); +- } +- +- /** +- * Invoke the object with the request from the input stream. +- * +- * @param in the Hessian input stream +- * @param out the Hessian output stream +- */ +- public void invoke(InputStream is, OutputStream os, +- SerializerFactory serializerFactory) +- throws Exception +- { +- boolean isDebug = false; +- +- if (isDebugInvoke()) { +- isDebug = true; +- +- PrintWriter dbg = createDebugPrintWriter(); +- HessianDebugInputStream dIs = new HessianDebugInputStream(is, dbg); +- dIs.startTop2(); +- is = dIs; +- HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); +- dOs.startTop2(); +- os = dOs; +- } +- +- HessianInputFactory.HeaderType header = _inputFactory.readHeader(is); +- +- AbstractHessianInput in; +- AbstractHessianOutput out; +- +- switch (header) { +- case CALL_1_REPLY_1: +- in = _hessianFactory.createHessianInput(is); +- out = _hessianFactory.createHessianOutput(os); +- break; +- +- case CALL_1_REPLY_2: +- in = _hessianFactory.createHessianInput(is); +- out = _hessianFactory.createHessian2Output(os); +- break; +- +- case HESSIAN_2: +- in = _hessianFactory.createHessian2Input(is); +- in.readCall(); +- out = _hessianFactory.createHessian2Output(os); +- break; +- +- default: +- throw new IllegalStateException(header + " is an unknown Hessian call"); +- } +- +- if (serializerFactory != null) { +- in.setSerializerFactory(serializerFactory); +- out.setSerializerFactory(serializerFactory); +- } +- +- try { +- invoke(_service, in, out); +- } finally { +- in.close(); +- out.close(); +- +- if (isDebug) +- os.close(); +- } +- } +- +- /** +- * Invoke the object with the request from the input stream. +- * +- * @param in the Hessian input stream +- * @param out the Hessian output stream +- */ +- public void invoke(AbstractHessianInput in, AbstractHessianOutput out) +- throws Exception +- { +- invoke(_service, in, out); +- } +- +- /** +- * Invoke the object with the request from the input stream. +- * +- * @param in the Hessian input stream +- * @param out the Hessian output stream +- */ +- public void invoke(Object service, +- AbstractHessianInput in, +- AbstractHessianOutput out) +- throws Exception +- { +- ServiceContext context = ServiceContext.getContext(); +- +- // backward compatibility for some frameworks that don't read +- // the call type first +- in.skipOptionalCall(); +- +- // Hessian 1.0 backward compatibility +- String header; +- while ((header = in.readHeader()) != null) { +- Object value = in.readObject(); +- +- context.addHeader(header, value); +- } +- +- String methodName = in.readMethod(); +- int argLength = in.readMethodArgLength(); +- +- Method method; +- +- method = getMethod(methodName + "__" + argLength); +- +- if (method == null) +- method = getMethod(methodName); +- +- if (method != null) { +- } +- else if ("_hessian_getAttribute".equals(methodName)) { +- String attrName = in.readString(); +- in.completeCall(); +- +- String value = null; +- +- if ("java.api.class".equals(attrName)) +- value = getAPIClassName(); +- else if ("java.home.class".equals(attrName)) +- value = getHomeClassName(); +- else if ("java.object.class".equals(attrName)) +- value = getObjectClassName(); +- +- out.writeReply(value); +- out.close(); +- return; +- } +- else if (method == null) { +- out.writeFault("NoSuchMethodException", +- escapeMessage("The service has no method named: " + in.getMethod()), +- null); +- out.close(); +- return; +- } +- +- Class []args = method.getParameterTypes(); +- +- if (argLength != args.length && argLength >= 0) { +- out.writeFault("NoSuchMethod", +- escapeMessage("method " + method + " argument length mismatch, received length=" + argLength), +- null); +- out.close(); +- return; +- } +- +- Object []values = new Object[args.length]; +- +- for (int i = 0; i < args.length; i++) { +- // XXX: needs Marshal object +- values[i] = in.readObject(args[i]); +- } +- +- Object result = null; +- +- try { +- result = method.invoke(service, values); +- } catch (Exception e) { +- Throwable e1 = e; +- if (e1 instanceof InvocationTargetException) +- e1 = ((InvocationTargetException) e).getTargetException(); +- +- log.log(Level.FINE, this + " " + e1.toString(), e1); +- +- out.writeFault("ServiceException", +- escapeMessage(e1.getMessage()), +- e1); +- out.close(); +- return; +- } +- +- // The complete call needs to be after the invoke to handle a +- // trailing InputStream +- in.completeCall(); +- +- out.writeReply(result); +- +- out.close(); +- } +- +- private String escapeMessage(String msg) +- { +- if (msg == null) +- return null; +- +- StringBuilder sb = new StringBuilder(); +- +- int length = msg.length(); +- for (int i = 0; i < length; i++) { +- char ch = msg.charAt(i); +- +- switch (ch) { +- case '<': +- sb.append("<"); +- break; +- case '>': +- sb.append(">"); +- break; +- case 0x0: +- sb.append("�"); +- break; +- case '&': +- sb.append("&"); +- break; +- default: +- sb.append(ch); +- break; +- } +- } +- +- return sb.toString(); +- } +- +- protected boolean isDebugInvoke() +- { +- return (log.isLoggable(Level.FINEST) +- || isDebug() && log.isLoggable(Level.FINE)); +- } +- +- /** +- * Creates the PrintWriter for debug output. The default is to +- * write to java.util.Logging. +- */ +- protected PrintWriter createDebugPrintWriter() +- throws IOException +- { +- return new PrintWriter(new LogWriter(log)); +- } +- +- static class LogWriter extends Writer { +- private Logger _log; +- private StringBuilder _sb = new StringBuilder(); +- +- LogWriter(Logger log) +- { +- _log = log; +- } +- +- public void write(char ch) +- { +- if (ch == '\n' && _sb.length() > 0) { +- _log.fine(_sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- +- public void write(char []buffer, int offset, int length) +- { +- for (int i = 0; i < length; i++) { +- char ch = buffer[offset + i]; +- +- if (ch == '\n' && _sb.length() > 0) { +- _log.fine(_sb.toString()); +- _sb.setLength(0); +- } +- else +- _sb.append((char) ch); +- } +- } +- +- public void flush() +- { +- } +- +- public void close() +- { +- } +- } +-} ++/* ++ * Copyright (c) 2001-2009 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.server; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.PrintWriter; ++import java.io.Writer; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import com.caucho.hessian.io.AbstractHessianInput; ++import com.caucho.hessian.io.AbstractHessianOutput; ++import com.caucho.hessian.io.HessianDebugInputStream; ++import com.caucho.hessian.io.HessianDebugOutputStream; ++import com.caucho.hessian.io.HessianFactory; ++import com.caucho.hessian.io.HessianInputFactory; ++import com.caucho.hessian.io.SerializerFactory; ++import com.caucho.services.server.AbstractSkeleton; ++import com.caucho.services.server.ServiceContext; ++ ++/** ++ * Proxy class for Hessian services. ++ */ ++public class HessianSkeleton extends AbstractSkeleton { ++ private static final Logger log ++ = Logger.getLogger(HessianSkeleton.class.getName()); ++ ++ private boolean _isDebug; ++ ++ private HessianInputFactory _inputFactory = new HessianInputFactory(); ++ private HessianFactory _hessianFactory = new HessianFactory(); ++ ++ private Object _service; ++ ++ /** ++ * Create a new hessian skeleton. ++ * ++ * @param service the underlying service object. ++ * @param apiClass the API interface ++ */ ++ public HessianSkeleton(Object service, Class apiClass) ++ { ++ super(apiClass); ++ ++ if (service == null) ++ service = this; ++ ++ _service = service; ++ ++ if (! apiClass.isAssignableFrom(service.getClass())) ++ throw new IllegalArgumentException("Service " + service + " must be an instance of " + apiClass.getName()); ++ } ++ ++ /** ++ * Create a new hessian skeleton. ++ * ++ * @param service the underlying service object. ++ * @param apiClass the API interface ++ */ ++ public HessianSkeleton(Class apiClass) ++ { ++ super(apiClass); ++ } ++ ++ public void setDebug(boolean isDebug) ++ { ++ _isDebug = isDebug; ++ } ++ ++ public boolean isDebug() ++ { ++ return _isDebug; ++ } ++ ++ public void setHessianFactory(HessianFactory factory) ++ { ++ _hessianFactory = factory; ++ } ++ ++ /** ++ * Invoke the object with the request from the input stream. ++ * ++ * @param in the Hessian input stream ++ * @param out the Hessian output stream ++ */ ++ public void invoke(InputStream is, OutputStream os) ++ throws Exception ++ { ++ invoke(is, os, null); ++ } ++ ++ /** ++ * Invoke the object with the request from the input stream. ++ * ++ * @param in the Hessian input stream ++ * @param out the Hessian output stream ++ */ ++ public void invoke(InputStream is, OutputStream os, ++ SerializerFactory serializerFactory) ++ throws Exception ++ { ++ boolean isDebug = false; ++ ++ if (isDebugInvoke()) { ++ isDebug = true; ++ ++ PrintWriter dbg = createDebugPrintWriter(); ++ HessianDebugInputStream dIs = new HessianDebugInputStream(is, dbg); ++ dIs.startTop2(); ++ is = dIs; ++ HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); ++ dOs.startTop2(); ++ os = dOs; ++ } ++ ++ HessianInputFactory.HeaderType header = _inputFactory.readHeader(is); ++ ++ AbstractHessianInput in; ++ AbstractHessianOutput out; ++ ++ switch (header) { ++ case CALL_1_REPLY_1: ++ in = _hessianFactory.createHessianInput(is); ++ out = _hessianFactory.createHessianOutput(os); ++ break; ++ ++ case CALL_1_REPLY_2: ++ in = _hessianFactory.createHessianInput(is); ++ out = _hessianFactory.createHessian2Output(os); ++ break; ++ ++ case HESSIAN_2: ++ in = _hessianFactory.createHessian2Input(is); ++ in.readCall(); ++ out = _hessianFactory.createHessian2Output(os); ++ break; ++ ++ default: ++ throw new IllegalStateException(header + " is an unknown Hessian call"); ++ } ++ ++ if (serializerFactory != null) { ++ in.setSerializerFactory(serializerFactory); ++ out.setSerializerFactory(serializerFactory); ++ } ++ ++ try { ++ invoke(_service, in, out); ++ } finally { ++ in.close(); ++ out.close(); ++ ++ if (isDebug) ++ os.close(); ++ } ++ } ++ ++ /** ++ * Invoke the object with the request from the input stream. ++ * ++ * @param in the Hessian input stream ++ * @param out the Hessian output stream ++ */ ++ public void invoke(AbstractHessianInput in, AbstractHessianOutput out) ++ throws Exception ++ { ++ invoke(_service, in, out); ++ } ++ ++ /** ++ * Invoke the object with the request from the input stream. ++ * ++ * @param in the Hessian input stream ++ * @param out the Hessian output stream ++ */ ++ public void invoke(Object service, ++ AbstractHessianInput in, ++ AbstractHessianOutput out) ++ throws Exception ++ { ++ ServiceContext context = ServiceContext.getContext(); ++ ++ // backward compatibility for some frameworks that don't read ++ // the call type first ++ in.skipOptionalCall(); ++ ++ // Hessian 1.0 backward compatibility ++ String header; ++ while ((header = in.readHeader()) != null) { ++ Object value = in.readObject(); ++ ++ context.addHeader(header, value); ++ } ++ ++ String methodName = in.readMethod(); ++ int argLength = in.readMethodArgLength(); ++ ++ Method method; ++ ++ method = getMethod(methodName + "__" + argLength); ++ ++ if (method == null) ++ method = getMethod(methodName); ++ ++ if (method != null) { ++ } ++ else if ("_hessian_getAttribute".equals(methodName)) { ++ String attrName = in.readString(); ++ in.completeCall(); ++ ++ String value = null; ++ ++ if ("java.api.class".equals(attrName)) ++ value = getAPIClassName(); ++ else if ("java.home.class".equals(attrName)) ++ value = getHomeClassName(); ++ else if ("java.object.class".equals(attrName)) ++ value = getObjectClassName(); ++ ++ out.writeReply(value); ++ out.close(); ++ return; ++ } ++ else if (method == null) { ++ out.writeFault("NoSuchMethodException", ++ escapeMessage("The service has no method named: " + in.getMethod()), ++ null); ++ out.close(); ++ return; ++ } ++ ++ Class []args = method.getParameterTypes(); ++ ++ if (argLength != args.length && argLength >= 0) { ++ out.writeFault("NoSuchMethod", ++ escapeMessage("method " + method + " argument length mismatch, received length=" + argLength), ++ null); ++ out.close(); ++ return; ++ } ++ ++ Object []values = new Object[args.length]; ++ ++ for (int i = 0; i < args.length; i++) { ++ // XXX: needs Marshal object ++ values[i] = in.readObject(args[i]); ++ } ++ ++ Object result = null; ++ ++ try { ++ result = method.invoke(service, values); ++ } catch (Exception e) { ++ Throwable e1 = e; ++ if (e1 instanceof InvocationTargetException) ++ e1 = ((InvocationTargetException) e).getTargetException(); ++ ++ log.log(Level.FINE, this + " " + e1.toString(), e1); ++ ++ out.writeFault("ServiceException", ++ escapeMessage(e1.getMessage()), ++ e1); ++ out.close(); ++ return; ++ } ++ ++ // The complete call needs to be after the invoke to handle a ++ // trailing InputStream ++ in.completeCall(); ++ ++ out.writeReply(result); ++ ++ out.close(); ++ } ++ ++ private String escapeMessage(String msg) ++ { ++ if (msg == null) ++ return null; ++ ++ StringBuilder sb = new StringBuilder(); ++ ++ int length = msg.length(); ++ for (int i = 0; i < length; i++) { ++ char ch = msg.charAt(i); ++ ++ switch (ch) { ++ case '<': ++ sb.append("<"); ++ break; ++ case '>': ++ sb.append(">"); ++ break; ++ case 0x0: ++ sb.append("�"); ++ break; ++ case '&': ++ sb.append("&"); ++ break; ++ default: ++ sb.append(ch); ++ break; ++ } ++ } ++ ++ return sb.toString(); ++ } ++ ++ protected boolean isDebugInvoke() ++ { ++ return (log.isLoggable(Level.FINEST) ++ || isDebug() && log.isLoggable(Level.FINE)); ++ } ++ ++ /** ++ * Creates the PrintWriter for debug output. The default is to ++ * write to java.util.Logging. ++ */ ++ protected PrintWriter createDebugPrintWriter() ++ throws IOException ++ { ++ return new PrintWriter(new LogWriter(log)); ++ } ++ ++ static class LogWriter extends Writer { ++ private Logger _log; ++ private StringBuilder _sb = new StringBuilder(); ++ ++ LogWriter(Logger log) ++ { ++ _log = log; ++ } ++ ++ public void write(char ch) ++ { ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ ++ public void write(char []buffer, int offset, int length) ++ { ++ for (int i = 0; i < length; i++) { ++ char ch = buffer[offset + i]; ++ ++ if (ch == '\n' && _sb.length() > 0) { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ } ++ ++ public void flush() ++ { ++ } ++ ++ public void close() ++ { ++ } ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A0.java hessian-4.0.65-fix/com/caucho/hessian/test/A0.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A0.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A0.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A0 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A0 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A1.java hessian-4.0.65-fix/com/caucho/hessian/test/A1.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A1.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A1.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A1 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A1 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A10.java hessian-4.0.65-fix/com/caucho/hessian/test/A10.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A10.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A10.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A10 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A10 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A11.java hessian-4.0.65-fix/com/caucho/hessian/test/A11.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A11.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A11.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A11 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A11 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A12.java hessian-4.0.65-fix/com/caucho/hessian/test/A12.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A12.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A12.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A12 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A12 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A13.java hessian-4.0.65-fix/com/caucho/hessian/test/A13.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A13.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A13.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A13 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A13 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A14.java hessian-4.0.65-fix/com/caucho/hessian/test/A14.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A14.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A14.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A14 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A14 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A15.java hessian-4.0.65-fix/com/caucho/hessian/test/A15.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A15.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A15.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A15 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A15 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A16.java hessian-4.0.65-fix/com/caucho/hessian/test/A16.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A16.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A16.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A16 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A16 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A2.java hessian-4.0.65-fix/com/caucho/hessian/test/A2.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A2.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A2.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A2 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A2 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A3.java hessian-4.0.65-fix/com/caucho/hessian/test/A3.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A3.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A3.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A3 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A3 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A4.java hessian-4.0.65-fix/com/caucho/hessian/test/A4.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A4.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A4.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A4 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A4 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A5.java hessian-4.0.65-fix/com/caucho/hessian/test/A5.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A5.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A5.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A5 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A5 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A6.java hessian-4.0.65-fix/com/caucho/hessian/test/A6.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A6.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A6.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A6 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A6 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A7.java hessian-4.0.65-fix/com/caucho/hessian/test/A7.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A7.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A7.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A7 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A7 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A8.java hessian-4.0.65-fix/com/caucho/hessian/test/A8.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A8.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A8.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A8 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A8 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A9.java hessian-4.0.65-fix/com/caucho/hessian/test/A9.java +--- hessian-4.0.65-src/com/caucho/hessian/test/A9.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/A9.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,18 +1,18 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * Empty object for short-encoding testing +- */ +-public class A9 implements java.io.Serializable { +- public boolean equals(Object v) +- { +- return v != null && getClass().equals(v.getClass()); +- } +- +- public String toString() +- { +- return getClass().getName() + "[]"; +- } +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * Empty object for short-encoding testing ++ */ ++public class A9 implements java.io.Serializable { ++ public boolean equals(Object v) ++ { ++ return v != null && getClass().equals(v.getClass()); ++ } ++ ++ public String toString() ++ { ++ return getClass().getName() + "[]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/Test.java hessian-4.0.65-fix/com/caucho/hessian/test/Test.java +--- hessian-4.0.65-src/com/caucho/hessian/test/Test.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/Test.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,36 +1,36 @@ +-package com.caucho.hessian.test; +- +-import java.io.IOException; +- +-/** +- * The Test service is a quick sanity check service. Developers of a +- * new Hessian implementation can use this service as an initial test. +- */ +-public interface Test { +- /** +- * Does nothing. +- */ +- public void nullCall(); +- +- /** +- * Hello, World. +- */ +- public String hello(); +- +- /** +- * Subtraction +- */ +- public int subtract(int a, int b); +- +- /** +- * Echos the object to the server. +- *
+-   */
+-  public Object echo(Object value);
+-  
+-  /**
+-   * Throws an application fault.
+-   */
+-  public void fault()
+-    throws IOException;
+-}
++package com.caucho.hessian.test;
++
++import java.io.IOException;
++
++/**
++ * The Test service is a quick sanity check service.  Developers of a
++ * new Hessian implementation can use this service as an initial test.
++ */
++public interface Test {
++  /**
++   * Does nothing.
++   */
++  public void nullCall();
++  
++  /**
++   * Hello, World.
++   */
++  public String hello();
++  
++  /**
++   * Subtraction
++   */
++  public int subtract(int a, int b);
++  
++  /**
++   * Echos the object to the server.
++   * 
++   */
++  public Object echo(Object value);
++  
++  /**
++   * Throws an application fault.
++   */
++  public void fault()
++    throws IOException;
++}
+diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestCons.java hessian-4.0.65-fix/com/caucho/hessian/test/TestCons.java
+--- hessian-4.0.65-src/com/caucho/hessian/test/TestCons.java	2020-07-23 12:51:28.000000000 +0800
++++ hessian-4.0.65-fix/com/caucho/hessian/test/TestCons.java	2023-08-15 18:39:22.000000000 +0800
+@@ -1,86 +1,86 @@
+-package com.caucho.hessian.test;
+-
+-import java.io.IOException;
+-import java.util.*;
+-
+-/**
+- * Cons-cell for testing
+- */
+-public class TestCons implements java.io.Serializable {
+-  private Object _first;
+-  private Object _rest;
+-
+-  public TestCons()
+-  {
+-  }
+-
+-  public TestCons(Object first)
+-  {
+-    _first = first;
+-  }
+-
+-  public TestCons(Object first, Object rest)
+-  {
+-    _first = first;
+-    _rest = rest;
+-  }
+-
+-  public Object getFirst()
+-  {
+-    return _first;
+-  }
+-
+-  public void setFirst(Object first)
+-  {
+-    _first = first;
+-  }
+-
+-  public Object getRest()
+-  {
+-    return _rest;
+-  }
+-
+-  public void setRest(Object rest)
+-  {
+-    _rest = rest;
+-  }
+-
+-  public boolean equals(Object o)
+-  {
+-    return toString().equals(o.toString());
+-  }
+-  
+-  public String toString()
+-  {
+-    return toString(new HashMap());
+-  }
+-  
+-  public String toString(HashMap map)
+-  {
+-    Object ref = map.get(this);
+-
+-    if (ref != null)
+-      return "#" + ref;
+-
+-    map.put(this, map.size());
+-
+-    StringBuilder sb = new StringBuilder();
+-    sb.append(getClass().getSimpleName()).append("[");
+-
+-    if (_first instanceof TestCons)
+-      sb.append(((TestCons) _first).toString(map));
+-    else
+-      sb.append(_first);
+-
+-    sb.append(",");
+-
+-    if (_rest instanceof TestCons)
+-      sb.append(((TestCons) _rest).toString(map));
+-    else
+-      sb.append(_rest);
+-
+-    sb.append("[");
+-    
+-    return sb.toString();
+-  }
+-}
++package com.caucho.hessian.test;
++
++import java.io.IOException;
++import java.util.*;
++
++/**
++ * Cons-cell for testing
++ */
++public class TestCons implements java.io.Serializable {
++  private Object _first;
++  private Object _rest;
++
++  public TestCons()
++  {
++  }
++
++  public TestCons(Object first)
++  {
++    _first = first;
++  }
++
++  public TestCons(Object first, Object rest)
++  {
++    _first = first;
++    _rest = rest;
++  }
++
++  public Object getFirst()
++  {
++    return _first;
++  }
++
++  public void setFirst(Object first)
++  {
++    _first = first;
++  }
++
++  public Object getRest()
++  {
++    return _rest;
++  }
++
++  public void setRest(Object rest)
++  {
++    _rest = rest;
++  }
++
++  public boolean equals(Object o)
++  {
++    return toString().equals(o.toString());
++  }
++  
++  public String toString()
++  {
++    return toString(new HashMap());
++  }
++  
++  public String toString(HashMap map)
++  {
++    Object ref = map.get(this);
++
++    if (ref != null)
++      return "#" + ref;
++
++    map.put(this, map.size());
++
++    StringBuilder sb = new StringBuilder();
++    sb.append(getClass().getSimpleName()).append("[");
++
++    if (_first instanceof TestCons)
++      sb.append(((TestCons) _first).toString(map));
++    else
++      sb.append(_first);
++
++    sb.append(",");
++
++    if (_rest instanceof TestCons)
++      sb.append(((TestCons) _rest).toString(map));
++    else
++      sb.append(_rest);
++
++    sb.append("[");
++    
++    return sb.toString();
++  }
++}
+diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2.java hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2.java
+--- hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2.java	2020-07-23 12:51:28.000000000 +0800
++++ hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2.java	2023-08-15 18:39:22.000000000 +0800
+@@ -1,1833 +1,1833 @@
+-package com.caucho.hessian.test;
+-
+-import java.io.IOException;
+-
+-/**
+- * The Test service is a quick sanity check service.  Developers of a
+- * new Hessian implementation can use this service as an initial test.
+- *
+- * http://hessian.caucho.com/test/test2
+- */
+-public interface TestHessian2 {
+-  /**
+-   * trivial null method call
+-   *
+-   * 
+-   * H x02 x00
+-   * C
+-   *   x0a methodNull
+-   *   x90
+-   * 
+- * +- *
+-   * R N
+-   * 
+- */ +- public void methodNull(); +- +- // +- // result values +- // +- +- /** +- * Result of null +- * +- *
+-   * R N
+-   * 
+- */ +- public void replyNull(); +- +- // +- // boolean +- // +- +- /** +- * Boolean true +- * +- *
+-   * T
+-   * 
+- */ +- public Object replyTrue(); +- +- /** +- * Boolean false +- * +- *
+-   * F
+-   * 
+- */ +- public Object replyFalse(); +- +- // +- // integers +- // +- +- /** +- * Result of integer 0 +- * +- *
+-   * R x90
+-   * 
+- */ +- public int replyInt_0(); +- +- /** +- * Result of integer 1 +- * +- *
+-   * R x91
+-   * 
+- */ +- public int replyInt_1(); +- +- /** +- * Result of integer 47 +- * +- *
+-   * R xbf
+-   * 
+- */ +- public int replyInt_47(); +- +- /** +- * Result of integer -16 +- * +- *
+-   * R x80
+-   * 
+- */ +- public int replyInt_m16(); +- +- // two byte integers +- +- /** +- * Result of integer 0x30 +- * +- *
+-   * R xc8 x30
+-   * 
+- */ +- public int replyInt_0x30(); +- +- /** +- * Result of integer x7ff +- * +- *
+-   * R xcf xff
+-   * 
+- */ +- public int replyInt_0x7ff(); +- +- /** +- * Result of integer -17 +- * +- *
+-   * R xc7 xef
+-   * 
+- */ +- public int replyInt_m17(); +- +- /** +- * Result of integer -0x800 +- * +- *
+-   * R xc0 x00
+-   * 
+- */ +- public int replyInt_m0x800(); +- +- /** +- * Result of integer 0x800 +- * +- *
+-   * R xd4 x08 x00
+-   * 
+- */ +- public int replyInt_0x800(); +- +- /** +- * Result of integer 0x3ffff +- * +- *
+-   * R xd7 xff xff
+-   * 
+- */ +- public int replyInt_0x3ffff(); +- +- /** +- * Result of integer -0x801 +- * +- *
+-   * R xd3 xf8 x00
+-   * 
+- */ +- public int replyInt_m0x801(); +- +- /** +- * Result of integer m0x40000 +- * +- *
+-   * R xd0 x00 x00
+-   * 
+- */ +- public int replyInt_m0x40000(); +- +- // 5 byte integers +- +- /** +- * Result of integer 0x40000 +- * +- *
+-   * R I x00 x04 x00 x00
+-   * 
+- */ +- public int replyInt_0x40000(); +- +- /** +- * Result of integer 0x7fffffff +- * +- *
+-   * R I x7f xff xff xff
+-   * 
+- */ +- public int replyInt_0x7fffffff(); +- +- /** +- * Result of integer m0x40001 +- * +- *
+-   * R I xff xf3 xff xf
+-   * 
+- */ +- public int replyInt_m0x40001(); +- +- /** +- * Result of integer -0x80000000 +- * +- *
+-   * R I x80 x00 x00 x00
+-   * 
+- */ +- public int replyInt_m0x80000000(); +- +- // +- // longs +- // +- +- /** +- * Result of long 0 +- * +- *
+-   * R xe0
+-   * 
+- */ +- public long replyLong_0(); +- +- /** +- * Result of long 1 +- * +- *
+-   * R xe1
+-   * 
+- */ +- public long replyLong_1(); +- +- /** +- * Result of long 15 +- * +- *
+-   * R xef
+-   * 
+- */ +- public long replyLong_15(); +- +- /** +- * Result of long -8 +- * +- *
+-   * R xd8
+-   * 
+- */ +- public long replyLong_m8(); +- +- // two byte longs +- +- /** +- * Result of long 0x10 +- * +- *
+-   * R xf8 x10
+-   * 
+- */ +- public long replyLong_0x10(); +- +- /** +- * Result of long x7ff +- * +- *
+-   * R xff xff
+-   * 
+- */ +- public long replyLong_0x7ff(); +- +- /** +- * Result of long -9 +- * +- *
+-   * R xf7 xf7
+-   * 
+- */ +- public long replyLong_m9(); +- +- /** +- * Result of long -0x800 +- * +- *
+-   * R xf0 x00
+-   * 
+- */ +- public long replyLong_m0x800(); +- +- /** +- * Result of long 0x800 +- * +- *
+-   * R x3c x08 x00
+-   * 
+- */ +- public long replyLong_0x800(); +- +- /** +- * Result of long 0x3ffff +- * +- *
+-   * R x3f xff xff
+-   * 
+- */ +- public long replyLong_0x3ffff(); +- +- /** +- * Result of long -0x801 +- * +- *
+-   * R x3b xf7 xff
+-   * 
+- */ +- public long replyLong_m0x801(); +- +- /** +- * Result of long m0x40000 +- * +- *
+-   * R x38 x00 x00
+-   * 
+- */ +- public long replyLong_m0x40000(); +- +- // 5 byte longs +- +- /** +- * Result of long 0x40000 +- * +- *
+-   * R x59 x00 x04 x00 x00
+-   * 
+- */ +- public long replyLong_0x40000(); +- +- /** +- * Result of long 0x7fffffff +- * +- *
+-   * R x59 x7f xff xff xff
+-   * 
+- */ +- public long replyLong_0x7fffffff(); +- +- /** +- * Result of long m0x40001 +- * +- *
+-   * R x59 xff xf3 xff xf
+-   * 
+- */ +- public long replyLong_m0x40001(); +- +- /** +- * Result of long -0x80000000 +- * +- *
+-   * R x59 x80 x00 x00 x00
+-   * 
+- */ +- public long replyLong_m0x80000000(); +- +- /** +- * Result of long 0x80000000 +- * +- *
+-   * R L x00 x00 x00 x00 x80 x00 x00 x00
+-   * 
+- */ +- public long replyLong_0x80000000(); +- +- /** +- * Result of long -0x80000001 +- * +- *
+-   * R L xff xff xff xff x7f xff xff xff
+-   * 
+- */ +- public long replyLong_m0x80000001(); +- +- // +- // doubles +- // +- +- /** +- * Result of double 0.0 +- * +- *
+-   * R x5b
+-   * 
+- */ +- public double replyDouble_0_0(); +- +- /** +- * Result of double 1.0 +- * +- *
+-   * R x5c
+-   * 
+- */ +- public double replyDouble_1_0(); +- +- /** +- * Result of double 2.0 +- * +- *
+-   * R x5d x02
+-   * 
+- */ +- public double replyDouble_2_0(); +- +- /** +- * Result of double 127.0 +- * +- *
+-   * R x5d x7f
+-   * 
+- */ +- public double replyDouble_127_0(); +- +- /** +- * Result of double -128.0 +- * +- *
+-   * R x5d x80
+-   * 
+- */ +- public double replyDouble_m128_0(); +- +- /** +- * Result of double 128.0 +- * +- *
+-   * R x5e x00 x80
+-   * 
+- */ +- public double replyDouble_128_0(); +- +- /** +- * Result of double -129.0 +- * +- *
+-   * R x5e xff x7f
+-   * 
+- */ +- public double replyDouble_m129_0(); +- +- /** +- * Result of double 32767.0 +- * +- *
+-   * R x5e x7f xff
+-   * 
+- */ +- public double replyDouble_32767_0(); +- +- /** +- * Result of double -32768.0 +- * +- *
+-   * R x5e x80 x80
+-   * 
+- */ +- public double replyDouble_m32768_0(); +- +- /** +- * Result of double 0.001 +- * +- *
+-   * R x5f x00 x00 x00 x01
+-   * 
+- */ +- public double replyDouble_0_001(); +- +- /** +- * Result of double -0.001 +- * +- *
+-   * R x5f xff xff xff xff
+-   * 
+- */ +- public double replyDouble_m0_001(); +- +- /** +- * Result of double 65.536 +- * +- *
+-   * R x5f x00 x01 x00 x00
+-   * 
+- */ +- public double replyDouble_65_536(); +- +- /** +- * Result of double 3.14159 +- * +- *
+-   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
+-   * 
+- */ +- public double replyDouble_3_14159(); +- +- // +- // date +- // +- +- /** +- * date 0 (01-01-1970 00:00 GMT) +- * +- *
+-   * x4a x00 x00 x00 x00
+-   * 
+- */ +- public Object replyDate_0(); +- +- /** +- * Date by millisecond (05-08-1998 07:51:31.000 GMT) +- * +- *
+-   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
+-   * 
+- */ +- public Object replyDate_1(); +- +- /** +- * Date by minute (05-08-1998 07:51:00.000 GMT) +- * +- *
+-   * x4b x00 xe3 x83 x8f
+-   * 
+- */ +- public Object replyDate_2(); +- +- // +- // string length +- // +- +- /** +- * A zero-length string +- * +- *
+-   * x00
+-   * 
+- */ +- public String replyString_0(); +- +- /** +- * A null string +- * +- *
+-   * N
+-   * 
+- */ +- public String replyString_null(); +- +- /** +- * A one-length string +- * +- *
+-   * x01 a
+-   * 
+- */ +- public String replyString_1(); +- +- /** +- * A 31-length string +- * +- *
+-   * x0f 0123456789012345678901234567890
+-   * 
+- */ +- public String replyString_31(); +- +- /** +- * A 32-length string +- * +- *
+-   * x30 x02 01234567890123456789012345678901
+-   * 
+- */ +- public String replyString_32(); +- +- /** +- * A 1023-length string +- * +- *
+-   * x33 xff 000 01234567890123456789012345678901...
+-   * 
+- */ +- public String replyString_1023(); +- +- /** +- * A 1024-length string +- * +- *
+-   * S x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public String replyString_1024(); +- +- /** +- * A 65536-length string +- * +- *
+-   * R x80 x00 000 ...
+-   * S x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public String replyString_65536(); +- +- // +- // binary length +- // +- +- /** +- * A zero-length binary +- * +- *
+-   * x20
+-   * 
+- */ +- public Object replyBinary_0(); +- +- /** +- * A null string +- * +- *
+-   * N
+-   * 
+- */ +- public Object replyBinary_null(); +- +- /** +- * A one-length string +- * +- *
+-   * x01 0
+-   * 
+- */ +- public Object replyBinary_1(); +- +- /** +- * A 15-length binary +- * +- *
+-   * x2f 0123456789012345
+-   * 
+- */ +- public Object replyBinary_15(); +- +- /** +- * A 16-length binary +- * +- *
+-   * x34 x10 01234567890123456789012345678901
+-   * 
+- */ +- public Object replyBinary_16(); +- +- /** +- * A 1023-length binary +- * +- *
+-   * x37 xff 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object replyBinary_1023(); +- +- /** +- * A 1024-length binary +- * +- *
+-   * B x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object replyBinary_1024(); +- +- /** +- * A 65536-length binary +- * +- *
+-   * A x80 x00 000 ...
+-   * B x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object replyBinary_65536(); +- +- // +- // lists +- // +- +- /** +- * Zero-length untyped list +- * +- *
+-   * x78
+-   * 
+- */ +- public Object replyUntypedFixedList_0(); +- +- /** +- * 1-length untyped list +- * +- *
+-   * x79 x01 1
+-   * 
+- */ +- public Object replyUntypedFixedList_1(); +- +- /** +- * 7-length untyped list +- * +- *
+-   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
+-   * 
+- */ +- public Object replyUntypedFixedList_7(); +- +- /** +- * 8-length untyped list +- * +- *
+-   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
+-   * 
+- */ +- public Object replyUntypedFixedList_8(); +- +- /** +- * Zero-length typed list (String array) +- * +- *
+-   * x70 x07 [string
+-   * 
+- */ +- public Object replyTypedFixedList_0(); +- +- /** +- * 1-length typed list (String array) +- * +- *
+-   * x71 x07 [string x01 1
+-   * 
+- */ +- public Object replyTypedFixedList_1(); +- +- /** +- * 7-length typed list (String array) +- * +- *
+-   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
+-   * 
+- */ +- public Object replyTypedFixedList_7(); +- +- /** +- * 8-length typed list (String array) +- * +- *
+-   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
+-   * 
+- */ +- public Object replyTypedFixedList_8(); +- +- // +- // untyped maps +- // +- +- /** +- * zero-length untyped map +- * +- *
+-   * H Z
+-   * 
+- */ +- public Object replyUntypedMap_0(); +- +- /** +- * untyped map with string key +- * +- *
+-   * H x01 a x90 Z
+-   * 
+- */ +- public Object replyUntypedMap_1(); +- +- /** +- * untyped map with int key +- * +- *
+-   * H x90 x01 a x91 x01 b Z
+-   * 
+- */ +- public Object replyUntypedMap_2(); +- +- /** +- * untyped map with list key +- * +- *
+-   * H x71 x01 a x90 Z
+-   * 
+- */ +- public Object replyUntypedMap_3(); +- +- // +- // typed maps +- // +- +- /** +- * zero-length typed map +- * +- *
+-   * M x13 java.lang.Hashtable Z
+-   * 
+- */ +- public Object replyTypedMap_0(); +- +- /** +- * untyped map with string key +- * +- *
+-   * M x13 java.lang.Hashtable x01 a x90 Z
+-   * 
+- */ +- public Object replyTypedMap_1(); +- +- /** +- * typed map with int key +- * +- *
+-   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
+-   * 
+- */ +- public Object replyTypedMap_2(); +- +- /** +- * typed map with list key +- * +- *
+-   * M x13 java.lang.Hashtable x71 x01 a x90 Z
+-   * 
+- */ +- public Object replyTypedMap_3(); +- +- // +- // objects +- // +- +- /** +- * Returns a single object +- * +- *
+-   * C x1a com.caucho.hessian.test.A0 x90 x60
+-   * 
+- */ +- public Object replyObject_0(); +- +- /** +- * Returns 16 object types +- * +- *
+-   * X xa0
+-   *  C x1a com.caucho.hessian.test.A0 x90 x60
+-   *  C x1a com.caucho.hessian.test.A1 x90 x61
+-   *  C x1a com.caucho.hessian.test.A2 x90 x62
+-   *  C x1a com.caucho.hessian.test.A3 x90 x63
+-   *  C x1a com.caucho.hessian.test.A4 x90 x64
+-   *  C x1a com.caucho.hessian.test.A5 x90 x65
+-   *  C x1a com.caucho.hessian.test.A6 x90 x66
+-   *  C x1a com.caucho.hessian.test.A7 x90 x67
+-   *  C x1a com.caucho.hessian.test.A8 x90 x68
+-   *  C x1a com.caucho.hessian.test.A9 x90 x69
+-   *  C x1b com.caucho.hessian.test.A10 x90 x6a
+-   *  C x1b com.caucho.hessian.test.A11 x90 x6b
+-   *  C x1b com.caucho.hessian.test.A12 x90 x6c
+-   *  C x1b com.caucho.hessian.test.A13 x90 x6d
+-   *  C x1b com.caucho.hessian.test.A14 x90 x6e
+-   *  C x1b com.caucho.hessian.test.A15 x90 x6f
+-   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
+-   */
+-  public Object replyObject_16();
+-
+-  /**
+-   * Simple object with one field
+-   *
+-   * 
+-   * C x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
+-   * 
+- */ +- public Object replyObject_1(); +- +- /** +- * Simple two objects with one field +- * +- *
+-   * x7a
+-   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
+-   *   x60 x90
+-   *   x60 x91
+-   * 
+- */ +- public Object replyObject_2(); +- +- /** +- * Simple repeated object +- * +- *
+-   * x7a
+-   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
+-   *   x60 x90
+-   *   Q x91
+-   * 
+- */ +- public Object replyObject_2a(); +- +- /** +- * Two object with equals +- * +- *
+-   * x7a
+-   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
+-   *   x60 x90
+-   *   x60 x90
+-   * 
+- */ +- public Object replyObject_2b(); +- +- /** +- * Circular object +- * +- *
+-   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
+-   *   x60 x01 a Q \x90x
+-   * 
+- */ +- public Object replyObject_3(); +- +- // +- // arguments +- // +- +- /** +- * Null +- * +- *
+-   * N
+-   * 
+- */ +- public Object argNull(Object v); +- +- // +- // boolean +- // +- +- /** +- * Boolean true +- * +- *
+-   * T
+-   * 
+- */ +- public Object argTrue(Object v); +- +- /** +- * Boolean false +- * +- *
+-   * F
+-   * 
+- */ +- public Object argFalse(Object v); +- +- // +- // integer +- // +- +- /** +- * Integer 0 +- * +- *
+-   * x90
+-   * 
+- */ +- public Object argInt_0(Object v); +- +- /** +- * Integer 1 +- * +- *
+-   * x91
+-   * 
+- */ +- public Object argInt_1(Object v); +- +- /** +- * integer 47 +- * +- *
+-   * xbf
+-   * 
+- */ +- public Object argInt_47(Object v); +- +- /** +- * Result of integer -16 +- * +- *
+-   * R x80
+-   * 
+- */ +- public Object argInt_m16(Object v); +- +- // two byte integers +- +- /** +- * Integer 0x30 +- * +- *
+-   * xc8 x30
+-   * 
+- */ +- public Object argInt_0x30(Object v); +- +- /** +- * Result of integer x7ff +- * +- *
+-   * xcf xff
+-   * 
+- */ +- public Object argInt_0x7ff(Object v); +- +- /** +- * integer -17 +- * +- *
+-   * xc7 xef
+-   * 
+- */ +- public Object argInt_m17(Object v); +- +- /** +- * Integer -0x800 +- * +- *
+-   * xc0 x00
+-   * 
+- */ +- public Object argInt_m0x800(Object v); +- +- /** +- * Integer 0x800 +- * +- *
+-   * xd4 x08 x00
+-   * 
+- */ +- public Object argInt_0x800(Object v); +- +- /** +- * Integer 0x3ffff +- * +- *
+-   * xd7 xff xff
+-   * 
+- */ +- public Object argInt_0x3ffff(Object v); +- +- /** +- * Integer -0x801 +- * +- *
+-   * xd3 xf8 x00
+-   * 
+- */ +- public Object argInt_m0x801(Object v); +- +- /** +- * Integer m0x40000 +- * +- *
+-   * xd0 x00 x00
+-   * 
+- */ +- public Object argInt_m0x40000(Object v); +- +- // 5 byte integers +- +- /** +- * integer 0x40000 +- * +- *
+-   * I x00 x04 x00 x00
+-   * 
+- */ +- public Object argInt_0x40000(Object v); +- +- /** +- * Integer 0x7fffffff +- * +- *
+-   * I x7f xff xff xff
+-   * 
+- */ +- public Object argInt_0x7fffffff(Object v); +- +- /** +- * Integer m0x40001 +- * +- *
+-   * I xff xfb xff xff
+-   * 
+- */ +- public Object argInt_m0x40001(Object v); +- +- /** +- * Result of integer -0x80000000 +- * +- *
+-   * I x80 x00 x00 x00
+-   * 
+- */ +- public Object argInt_m0x80000000(Object v); +- +- // +- // longs +- // +- +- /** +- * long 0 +- * +- *
+-   * xe0
+-   * 
+- */ +- public Object argLong_0(Object v); +- +- /** +- * long 1 +- * +- *
+-   * xe1
+-   * 
+- */ +- public Object argLong_1(Object v); +- +- /** +- * long 15 +- * +- *
+-   * xef
+-   * 
+- */ +- public Object argLong_15(Object v); +- +- /** +- * long -8 +- * +- *
+-   * xd8
+-   * 
+- */ +- public Object argLong_m8(Object v); +- +- // two byte longs +- +- /** +- * long 0x10 +- * +- *
+-   * xf8 x10
+-   * 
+- */ +- public Object argLong_0x10(Object v); +- +- /** +- * long x7ff +- * +- *
+-   * xff xff
+-   * 
+- */ +- public Object argLong_0x7ff(Object v); +- +- /** +- * long -9 +- * +- *
+-   * xf7 xf7
+-   * 
+- */ +- public Object argLong_m9(Object v); +- +- /** +- * long -0x800 +- * +- *
+-   * xf0 x00
+-   * 
+- */ +- public Object argLong_m0x800(Object v); +- +- /** +- * long 0x800 +- * +- *
+-   * x3c x08 x00
+-   * 
+- */ +- public Object argLong_0x800(Object v); +- +- /** +- * long 0x3ffff +- * +- *
+-   * x3f xff xff
+-   * 
+- */ +- public Object argLong_0x3ffff(Object v); +- +- /** +- * long -0x801 +- * +- *
+-   * x3b xf7 xff
+-   * 
+- */ +- public Object argLong_m0x801(Object v); +- +- /** +- * long m0x40000 +- * +- *
+-   * x38 x00 x00
+-   * 
+- */ +- public Object argLong_m0x40000(Object v); +- +- // 5 byte longs +- +- /** +- * long 0x40000 +- * +- *
+-   * x59 x00 x04 x00 x00
+-   * 
+- */ +- public Object argLong_0x40000(Object v); +- +- /** +- * long 0x7fffffff +- * +- *
+-   * x59 x7f xff xff xff
+-   * 
+- */ +- public Object argLong_0x7fffffff(Object v); +- +- /** +- * long m0x40001 +- * +- *
+-   * x59 xff xfb xff xf
+-   * 
+- */ +- public Object argLong_m0x40001(Object v); +- +- /** +- * long -0x80000000 +- * +- *
+-   * x59 x80 x00 x00 x00
+-   * 
+- */ +- public Object argLong_m0x80000000(Object v); +- +- /** +- * Result of long 0x80000000 +- * +- *
+-   * L x00 x00 x00 x00 x80 x00 x00 x00
+-   * 
+- */ +- public Object argLong_0x80000000(Object v); +- +- /** +- * Result of long -0x80000001 +- * +- *
+-   * L xff xff xff xff x7f xff xff xff
+-   * 
+- */ +- public Object argLong_m0x80000001(Object v); +- +- // +- // doubles +- // +- +- /** +- * double 0.0 +- * +- *
+-   * x5b
+-   * 
+- */ +- public Object argDouble_0_0(Object v); +- +- /** +- * double 1.0 +- * +- *
+-   * x5c
+-   * 
+- */ +- public Object argDouble_1_0(Object v); +- +- /** +- * double 2.0 +- * +- *
+-   * x5d x02
+-   * 
+- */ +- public Object argDouble_2_0(Object v); +- +- /** +- * double 127.0 +- * +- *
+-   * x5d x7f
+-   * 
+- */ +- public Object argDouble_127_0(Object v); +- +- /** +- * double -128.0 +- * +- *
+-   * x5d x80
+-   * 
+- */ +- public Object argDouble_m128_0(Object v); +- +- /** +- * double 128.0 +- * +- *
+-   * x5e x00 x80
+-   * 
+- */ +- public Object argDouble_128_0(Object v); +- +- /** +- * double -129.0 +- * +- *
+-   * x5e xff x7f
+-   * 
+- */ +- public Object argDouble_m129_0(Object v); +- +- /** +- * double 32767.0 +- * +- *
+-   * x5e x7f xff
+-   * 
+- */ +- public Object argDouble_32767_0(Object v); +- +- /** +- * Double -32768.0 +- * +- *
+-   * x5e x80 x80
+-   * 
+- */ +- public Object argDouble_m32768_0(Object v); +- +- /** +- * double 0.001 +- * +- *
+-   * x5f x00 x00 x00 x01
+-   * 
+- */ +- public Object argDouble_0_001(Object v); +- +- /** +- * double -0.001 +- * +- *
+-   * x5f xff xff xff xff
+-   * 
+- */ +- public Object argDouble_m0_001(Object v); +- +- /** +- * double 65.536 +- * +- *
+-   * x5f x00 x01 x00 x00
+-   * 
+- */ +- public Object argDouble_65_536(Object v); +- +- /** +- * Result of double 3.14159 +- * +- *
+-   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
+-   * 
+- */ +- public Object argDouble_3_14159(Object v); +- +- // +- // date +- // +- +- /** +- * date 0 (01-01-1970 00:00 GMT) +- * +- *
+-   * x4a x00 x00 x00 x00
+-   * 
+- */ +- public Object argDate_0(Object v); +- +- /** +- * Date by millisecond (05-08-1998 07:51 GMT) +- * +- *
+-   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
+-   * 
+- */ +- public Object argDate_1(Object v); +- +- /** +- * Date by minute (05-08-1998 07:51 GMT) +- * +- *
+-   * x4b x00 xe3 x83 x8f
+-   * 
+- */ +- public Object argDate_2(Object v); +- +- // +- // string length +- // +- +- /** +- * A zero-length string +- * +- *
+-   * x00
+-   * 
+- */ +- public Object argString_0(Object v); +- +- /** +- * A one-length string +- * +- *
+-   * x01 a
+-   * 
+- */ +- public Object argString_1(Object v); +- +- /** +- * A 31-length string +- * +- *
+-   * x0f 0123456789012345678901234567890
+-   * 
+- */ +- public Object argString_31(Object v); +- +- /** +- * A 32-length string +- * +- *
+-   * x30 x02 01234567890123456789012345678901
+-   * 
+- */ +- public Object argString_32(Object v); +- +- /** +- * A 1023-length string +- * +- *
+-   * x33 xff 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object argString_1023(Object v); +- +- /** +- * A 1024-length string +- * +- *
+-   * S x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object argString_1024(Object v); +- +- /** +- * A 65536-length string +- * +- *
+-   * R x80 x00 000 ...
+-   * S x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object argString_65536(Object v); +- +- // +- // binary length +- // +- +- /** +- * A zero-length binary +- * +- *
+-   * x20
+-   * 
+- */ +- public Object argBinary_0(Object v); +- +- /** +- * A one-length string +- * +- *
+-   * x21 0
+-   * 
+- */ +- public Object argBinary_1(Object v); +- +- /** +- * A 15-length binary +- * +- *
+-   * x2f 0123456789012345
+-   * 
+- */ +- public Object argBinary_15(Object v); +- +- /** +- * A 16-length binary +- * +- *
+-   * x34 x10 01234567890123456789012345678901
+-   * 
+- */ +- public Object argBinary_16(Object v); +- +- /** +- * A 1023-length binary +- * +- *
+-   * x37 xff 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object argBinary_1023(Object v); +- +- /** +- * A 1024-length binary +- * +- *
+-   * B x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object argBinary_1024(Object v); +- +- /** +- * A 65536-length binary +- * +- *
+-   * A x80 x00 000 ...
+-   * B x04 x00 000 01234567890123456789012345678901...
+-   * 
+- */ +- public Object argBinary_65536(Object v); +- +- // +- // lists +- // +- +- /** +- * Zero-length untyped list +- * +- *
+-   * x78
+-   * 
+- */ +- public Object argUntypedFixedList_0(Object v); +- +- /** +- * 1-length untyped list +- * +- *
+-   * x79 x01 1
+-   * 
+- */ +- public Object argUntypedFixedList_1(Object v); +- +- /** +- * 7-length untyped list +- * +- *
+-   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
+-   * 
+- */ +- public Object argUntypedFixedList_7(Object v); +- +- /** +- * 8-length untyped list +- * +- *
+-   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
+-   * 
+- */ +- public Object argUntypedFixedList_8(Object v); +- +- /** +- * Zero-length typed list (String array) +- * +- *
+-   * x70 x07 [string
+-   * 
+- */ +- public Object argTypedFixedList_0(Object v); +- +- /** +- * 1-length typed list (String array) +- * +- *
+-   * x71 x07 [string x01 1
+-   * 
+- */ +- public Object argTypedFixedList_1(Object v); +- +- /** +- * 7-length typed list (String array) +- * +- *
+-   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
+-   * 
+- */ +- public Object argTypedFixedList_7(Object v); +- +- /** +- * 8-length typed list (String array) +- * +- *
+-   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
+-   * 
+- */ +- public Object argTypedFixedList_8(Object v); +- +- // +- // untyped maps +- // +- +- /** +- * zero-length untyped map +- * +- *
+-   * H Z
+-   * 
+- */ +- public Object argUntypedMap_0(Object v); +- +- /** +- * untyped map with string key +- * +- *
+-   * H x01 a x90 Z
+-   * 
+- */ +- public Object argUntypedMap_1(Object v); +- +- /** +- * untyped map with int key +- * +- *
+-   * H x90 x01 a x91 x01 b Z
+-   * 
+- */ +- public Object argUntypedMap_2(Object v); +- +- /** +- * untyped map with list key +- * +- *
+-   * H x71 x01 a x90 Z
+-   * 
+- */ +- public Object argUntypedMap_3(Object v); +- +- // +- // typed maps +- // +- +- /** +- * zero-length typed map +- * +- *
+-   * M x13 java.lang.Hashtable Z
+-   * 
+- */ +- public Object argTypedMap_0(Object v); +- +- /** +- * untyped map with string key +- * +- *
+-   * M x13 java.lang.Hashtable x01 a x90 Z
+-   * 
+- */ +- public Object argTypedMap_1(Object v); +- +- /** +- * typed map with int key +- * +- *
+-   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
+-   * 
+- */ +- public Object argTypedMap_2(Object v); +- +- /** +- * typed map with list key +- * +- *
+-   * M x13 java.lang.Hashtable x79 x01 a x90 Z
+-   * 
+- */ +- public Object argTypedMap_3(Object v); +- +- // +- // objects +- // +- +- /** +- * Returns a single object +- * +- *
+-   * C x1a com.caucho.hessian.test.A0 x90 x60
+-   * 
+- */ +- public Object argObject_0(Object v); +- +- /** +- * Returns 16 object types +- * +- *
+-   * X xa0
+-   *  C x1a com.caucho.hessian.test.A0 x90 x60
+-   *  C x1a com.caucho.hessian.test.A1 x90 x61
+-   *  C x1a com.caucho.hessian.test.A2 x90 x62
+-   *  C x1a com.caucho.hessian.test.A3 x90 x63
+-   *  C x1a com.caucho.hessian.test.A4 x90 x64
+-   *  C x1a com.caucho.hessian.test.A5 x90 x65
+-   *  C x1a com.caucho.hessian.test.A6 x90 x66
+-   *  C x1a com.caucho.hessian.test.A7 x90 x67
+-   *  C x1a com.caucho.hessian.test.A8 x90 x68
+-   *  C x1a com.caucho.hessian.test.A9 x90 x69
+-   *  C x1b com.caucho.hessian.test.A10 x90 x6a
+-   *  C x1b com.caucho.hessian.test.A11 x90 x6b
+-   *  C x1b com.caucho.hessian.test.A12 x90 x6c
+-   *  C x1b com.caucho.hessian.test.A13 x90 x6d
+-   *  C x1b com.caucho.hessian.test.A14 x90 x6e
+-   *  C x1b com.caucho.hessian.test.A15 x90 x6f
+-   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
+-   */
+-  public Object argObject_16(Object v);
+-
+-  /**
+-   * Simple object with one field
+-   *
+-   * 
+-   * C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
+-   * 
+- */ +- public Object argObject_1(Object v); +- +- /** +- * Simple two objects with one field +- * +- *
+-   * x7a
+-   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
+-   *   x60 x90
+-   *   x60 x91
+-   * 
+- */ +- public Object argObject_2(Object v); +- +- /** +- * Simple repeated object +- * +- *
+-   * x7a
+-   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
+-   *   x60 x90
+-   *   Q x91
+-   * 
+- */ +- public Object argObject_2a(Object v); +- +- /** +- * Two object with equals +- * +- *
+-   * x7a
+-   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
+-   *   x60 x90
+-   *   x60 x90
+-   * 
+- */ +- public Object argObject_2b(Object v); +- +- /** +- * Circular object +- * +- *
+-   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
+-   *   x60 x01 a Q x90
+-   * 
+- */ +- public Object argObject_3(Object v); +-} ++package com.caucho.hessian.test; ++ ++import java.io.IOException; ++ ++/** ++ * The Test service is a quick sanity check service. Developers of a ++ * new Hessian implementation can use this service as an initial test. ++ * ++ * http://hessian.caucho.com/test/test2 ++ */ ++public interface TestHessian2 { ++ /** ++ * trivial null method call ++ * ++ *
++   * H x02 x00
++   * C
++   *   x0a methodNull
++   *   x90
++   * 
++ * ++ *
++   * R N
++   * 
++ */ ++ public void methodNull(); ++ ++ // ++ // result values ++ // ++ ++ /** ++ * Result of null ++ * ++ *
++   * R N
++   * 
++ */ ++ public void replyNull(); ++ ++ // ++ // boolean ++ // ++ ++ /** ++ * Boolean true ++ * ++ *
++   * T
++   * 
++ */ ++ public Object replyTrue(); ++ ++ /** ++ * Boolean false ++ * ++ *
++   * F
++   * 
++ */ ++ public Object replyFalse(); ++ ++ // ++ // integers ++ // ++ ++ /** ++ * Result of integer 0 ++ * ++ *
++   * R x90
++   * 
++ */ ++ public int replyInt_0(); ++ ++ /** ++ * Result of integer 1 ++ * ++ *
++   * R x91
++   * 
++ */ ++ public int replyInt_1(); ++ ++ /** ++ * Result of integer 47 ++ * ++ *
++   * R xbf
++   * 
++ */ ++ public int replyInt_47(); ++ ++ /** ++ * Result of integer -16 ++ * ++ *
++   * R x80
++   * 
++ */ ++ public int replyInt_m16(); ++ ++ // two byte integers ++ ++ /** ++ * Result of integer 0x30 ++ * ++ *
++   * R xc8 x30
++   * 
++ */ ++ public int replyInt_0x30(); ++ ++ /** ++ * Result of integer x7ff ++ * ++ *
++   * R xcf xff
++   * 
++ */ ++ public int replyInt_0x7ff(); ++ ++ /** ++ * Result of integer -17 ++ * ++ *
++   * R xc7 xef
++   * 
++ */ ++ public int replyInt_m17(); ++ ++ /** ++ * Result of integer -0x800 ++ * ++ *
++   * R xc0 x00
++   * 
++ */ ++ public int replyInt_m0x800(); ++ ++ /** ++ * Result of integer 0x800 ++ * ++ *
++   * R xd4 x08 x00
++   * 
++ */ ++ public int replyInt_0x800(); ++ ++ /** ++ * Result of integer 0x3ffff ++ * ++ *
++   * R xd7 xff xff
++   * 
++ */ ++ public int replyInt_0x3ffff(); ++ ++ /** ++ * Result of integer -0x801 ++ * ++ *
++   * R xd3 xf8 x00
++   * 
++ */ ++ public int replyInt_m0x801(); ++ ++ /** ++ * Result of integer m0x40000 ++ * ++ *
++   * R xd0 x00 x00
++   * 
++ */ ++ public int replyInt_m0x40000(); ++ ++ // 5 byte integers ++ ++ /** ++ * Result of integer 0x40000 ++ * ++ *
++   * R I x00 x04 x00 x00
++   * 
++ */ ++ public int replyInt_0x40000(); ++ ++ /** ++ * Result of integer 0x7fffffff ++ * ++ *
++   * R I x7f xff xff xff
++   * 
++ */ ++ public int replyInt_0x7fffffff(); ++ ++ /** ++ * Result of integer m0x40001 ++ * ++ *
++   * R I xff xf3 xff xf
++   * 
++ */ ++ public int replyInt_m0x40001(); ++ ++ /** ++ * Result of integer -0x80000000 ++ * ++ *
++   * R I x80 x00 x00 x00
++   * 
++ */ ++ public int replyInt_m0x80000000(); ++ ++ // ++ // longs ++ // ++ ++ /** ++ * Result of long 0 ++ * ++ *
++   * R xe0
++   * 
++ */ ++ public long replyLong_0(); ++ ++ /** ++ * Result of long 1 ++ * ++ *
++   * R xe1
++   * 
++ */ ++ public long replyLong_1(); ++ ++ /** ++ * Result of long 15 ++ * ++ *
++   * R xef
++   * 
++ */ ++ public long replyLong_15(); ++ ++ /** ++ * Result of long -8 ++ * ++ *
++   * R xd8
++   * 
++ */ ++ public long replyLong_m8(); ++ ++ // two byte longs ++ ++ /** ++ * Result of long 0x10 ++ * ++ *
++   * R xf8 x10
++   * 
++ */ ++ public long replyLong_0x10(); ++ ++ /** ++ * Result of long x7ff ++ * ++ *
++   * R xff xff
++   * 
++ */ ++ public long replyLong_0x7ff(); ++ ++ /** ++ * Result of long -9 ++ * ++ *
++   * R xf7 xf7
++   * 
++ */ ++ public long replyLong_m9(); ++ ++ /** ++ * Result of long -0x800 ++ * ++ *
++   * R xf0 x00
++   * 
++ */ ++ public long replyLong_m0x800(); ++ ++ /** ++ * Result of long 0x800 ++ * ++ *
++   * R x3c x08 x00
++   * 
++ */ ++ public long replyLong_0x800(); ++ ++ /** ++ * Result of long 0x3ffff ++ * ++ *
++   * R x3f xff xff
++   * 
++ */ ++ public long replyLong_0x3ffff(); ++ ++ /** ++ * Result of long -0x801 ++ * ++ *
++   * R x3b xf7 xff
++   * 
++ */ ++ public long replyLong_m0x801(); ++ ++ /** ++ * Result of long m0x40000 ++ * ++ *
++   * R x38 x00 x00
++   * 
++ */ ++ public long replyLong_m0x40000(); ++ ++ // 5 byte longs ++ ++ /** ++ * Result of long 0x40000 ++ * ++ *
++   * R x59 x00 x04 x00 x00
++   * 
++ */ ++ public long replyLong_0x40000(); ++ ++ /** ++ * Result of long 0x7fffffff ++ * ++ *
++   * R x59 x7f xff xff xff
++   * 
++ */ ++ public long replyLong_0x7fffffff(); ++ ++ /** ++ * Result of long m0x40001 ++ * ++ *
++   * R x59 xff xf3 xff xf
++   * 
++ */ ++ public long replyLong_m0x40001(); ++ ++ /** ++ * Result of long -0x80000000 ++ * ++ *
++   * R x59 x80 x00 x00 x00
++   * 
++ */ ++ public long replyLong_m0x80000000(); ++ ++ /** ++ * Result of long 0x80000000 ++ * ++ *
++   * R L x00 x00 x00 x00 x80 x00 x00 x00
++   * 
++ */ ++ public long replyLong_0x80000000(); ++ ++ /** ++ * Result of long -0x80000001 ++ * ++ *
++   * R L xff xff xff xff x7f xff xff xff
++   * 
++ */ ++ public long replyLong_m0x80000001(); ++ ++ // ++ // doubles ++ // ++ ++ /** ++ * Result of double 0.0 ++ * ++ *
++   * R x5b
++   * 
++ */ ++ public double replyDouble_0_0(); ++ ++ /** ++ * Result of double 1.0 ++ * ++ *
++   * R x5c
++   * 
++ */ ++ public double replyDouble_1_0(); ++ ++ /** ++ * Result of double 2.0 ++ * ++ *
++   * R x5d x02
++   * 
++ */ ++ public double replyDouble_2_0(); ++ ++ /** ++ * Result of double 127.0 ++ * ++ *
++   * R x5d x7f
++   * 
++ */ ++ public double replyDouble_127_0(); ++ ++ /** ++ * Result of double -128.0 ++ * ++ *
++   * R x5d x80
++   * 
++ */ ++ public double replyDouble_m128_0(); ++ ++ /** ++ * Result of double 128.0 ++ * ++ *
++   * R x5e x00 x80
++   * 
++ */ ++ public double replyDouble_128_0(); ++ ++ /** ++ * Result of double -129.0 ++ * ++ *
++   * R x5e xff x7f
++   * 
++ */ ++ public double replyDouble_m129_0(); ++ ++ /** ++ * Result of double 32767.0 ++ * ++ *
++   * R x5e x7f xff
++   * 
++ */ ++ public double replyDouble_32767_0(); ++ ++ /** ++ * Result of double -32768.0 ++ * ++ *
++   * R x5e x80 x80
++   * 
++ */ ++ public double replyDouble_m32768_0(); ++ ++ /** ++ * Result of double 0.001 ++ * ++ *
++   * R x5f x00 x00 x00 x01
++   * 
++ */ ++ public double replyDouble_0_001(); ++ ++ /** ++ * Result of double -0.001 ++ * ++ *
++   * R x5f xff xff xff xff
++   * 
++ */ ++ public double replyDouble_m0_001(); ++ ++ /** ++ * Result of double 65.536 ++ * ++ *
++   * R x5f x00 x01 x00 x00
++   * 
++ */ ++ public double replyDouble_65_536(); ++ ++ /** ++ * Result of double 3.14159 ++ * ++ *
++   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
++   * 
++ */ ++ public double replyDouble_3_14159(); ++ ++ // ++ // date ++ // ++ ++ /** ++ * date 0 (01-01-1970 00:00 GMT) ++ * ++ *
++   * x4a x00 x00 x00 x00
++   * 
++ */ ++ public Object replyDate_0(); ++ ++ /** ++ * Date by millisecond (05-08-1998 07:51:31.000 GMT) ++ * ++ *
++   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
++   * 
++ */ ++ public Object replyDate_1(); ++ ++ /** ++ * Date by minute (05-08-1998 07:51:00.000 GMT) ++ * ++ *
++   * x4b x00 xe3 x83 x8f
++   * 
++ */ ++ public Object replyDate_2(); ++ ++ // ++ // string length ++ // ++ ++ /** ++ * A zero-length string ++ * ++ *
++   * x00
++   * 
++ */ ++ public String replyString_0(); ++ ++ /** ++ * A null string ++ * ++ *
++   * N
++   * 
++ */ ++ public String replyString_null(); ++ ++ /** ++ * A one-length string ++ * ++ *
++   * x01 a
++   * 
++ */ ++ public String replyString_1(); ++ ++ /** ++ * A 31-length string ++ * ++ *
++   * x0f 0123456789012345678901234567890
++   * 
++ */ ++ public String replyString_31(); ++ ++ /** ++ * A 32-length string ++ * ++ *
++   * x30 x02 01234567890123456789012345678901
++   * 
++ */ ++ public String replyString_32(); ++ ++ /** ++ * A 1023-length string ++ * ++ *
++   * x33 xff 000 01234567890123456789012345678901...
++   * 
++ */ ++ public String replyString_1023(); ++ ++ /** ++ * A 1024-length string ++ * ++ *
++   * S x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public String replyString_1024(); ++ ++ /** ++ * A 65536-length string ++ * ++ *
++   * R x80 x00 000 ...
++   * S x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public String replyString_65536(); ++ ++ // ++ // binary length ++ // ++ ++ /** ++ * A zero-length binary ++ * ++ *
++   * x20
++   * 
++ */ ++ public Object replyBinary_0(); ++ ++ /** ++ * A null string ++ * ++ *
++   * N
++   * 
++ */ ++ public Object replyBinary_null(); ++ ++ /** ++ * A one-length string ++ * ++ *
++   * x01 0
++   * 
++ */ ++ public Object replyBinary_1(); ++ ++ /** ++ * A 15-length binary ++ * ++ *
++   * x2f 0123456789012345
++   * 
++ */ ++ public Object replyBinary_15(); ++ ++ /** ++ * A 16-length binary ++ * ++ *
++   * x34 x10 01234567890123456789012345678901
++   * 
++ */ ++ public Object replyBinary_16(); ++ ++ /** ++ * A 1023-length binary ++ * ++ *
++   * x37 xff 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object replyBinary_1023(); ++ ++ /** ++ * A 1024-length binary ++ * ++ *
++   * B x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object replyBinary_1024(); ++ ++ /** ++ * A 65536-length binary ++ * ++ *
++   * A x80 x00 000 ...
++   * B x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object replyBinary_65536(); ++ ++ // ++ // lists ++ // ++ ++ /** ++ * Zero-length untyped list ++ * ++ *
++   * x78
++   * 
++ */ ++ public Object replyUntypedFixedList_0(); ++ ++ /** ++ * 1-length untyped list ++ * ++ *
++   * x79 x01 1
++   * 
++ */ ++ public Object replyUntypedFixedList_1(); ++ ++ /** ++ * 7-length untyped list ++ * ++ *
++   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
++   * 
++ */ ++ public Object replyUntypedFixedList_7(); ++ ++ /** ++ * 8-length untyped list ++ * ++ *
++   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
++   * 
++ */ ++ public Object replyUntypedFixedList_8(); ++ ++ /** ++ * Zero-length typed list (String array) ++ * ++ *
++   * x70 x07 [string
++   * 
++ */ ++ public Object replyTypedFixedList_0(); ++ ++ /** ++ * 1-length typed list (String array) ++ * ++ *
++   * x71 x07 [string x01 1
++   * 
++ */ ++ public Object replyTypedFixedList_1(); ++ ++ /** ++ * 7-length typed list (String array) ++ * ++ *
++   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
++   * 
++ */ ++ public Object replyTypedFixedList_7(); ++ ++ /** ++ * 8-length typed list (String array) ++ * ++ *
++   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
++   * 
++ */ ++ public Object replyTypedFixedList_8(); ++ ++ // ++ // untyped maps ++ // ++ ++ /** ++ * zero-length untyped map ++ * ++ *
++   * H Z
++   * 
++ */ ++ public Object replyUntypedMap_0(); ++ ++ /** ++ * untyped map with string key ++ * ++ *
++   * H x01 a x90 Z
++   * 
++ */ ++ public Object replyUntypedMap_1(); ++ ++ /** ++ * untyped map with int key ++ * ++ *
++   * H x90 x01 a x91 x01 b Z
++   * 
++ */ ++ public Object replyUntypedMap_2(); ++ ++ /** ++ * untyped map with list key ++ * ++ *
++   * H x71 x01 a x90 Z
++   * 
++ */ ++ public Object replyUntypedMap_3(); ++ ++ // ++ // typed maps ++ // ++ ++ /** ++ * zero-length typed map ++ * ++ *
++   * M x13 java.lang.Hashtable Z
++   * 
++ */ ++ public Object replyTypedMap_0(); ++ ++ /** ++ * untyped map with string key ++ * ++ *
++   * M x13 java.lang.Hashtable x01 a x90 Z
++   * 
++ */ ++ public Object replyTypedMap_1(); ++ ++ /** ++ * typed map with int key ++ * ++ *
++   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
++   * 
++ */ ++ public Object replyTypedMap_2(); ++ ++ /** ++ * typed map with list key ++ * ++ *
++   * M x13 java.lang.Hashtable x71 x01 a x90 Z
++   * 
++ */ ++ public Object replyTypedMap_3(); ++ ++ // ++ // objects ++ // ++ ++ /** ++ * Returns a single object ++ * ++ *
++   * C x1a com.caucho.hessian.test.A0 x90 x60
++   * 
++ */ ++ public Object replyObject_0(); ++ ++ /** ++ * Returns 16 object types ++ * ++ *
++   * X xa0
++   *  C x1a com.caucho.hessian.test.A0 x90 x60
++   *  C x1a com.caucho.hessian.test.A1 x90 x61
++   *  C x1a com.caucho.hessian.test.A2 x90 x62
++   *  C x1a com.caucho.hessian.test.A3 x90 x63
++   *  C x1a com.caucho.hessian.test.A4 x90 x64
++   *  C x1a com.caucho.hessian.test.A5 x90 x65
++   *  C x1a com.caucho.hessian.test.A6 x90 x66
++   *  C x1a com.caucho.hessian.test.A7 x90 x67
++   *  C x1a com.caucho.hessian.test.A8 x90 x68
++   *  C x1a com.caucho.hessian.test.A9 x90 x69
++   *  C x1b com.caucho.hessian.test.A10 x90 x6a
++   *  C x1b com.caucho.hessian.test.A11 x90 x6b
++   *  C x1b com.caucho.hessian.test.A12 x90 x6c
++   *  C x1b com.caucho.hessian.test.A13 x90 x6d
++   *  C x1b com.caucho.hessian.test.A14 x90 x6e
++   *  C x1b com.caucho.hessian.test.A15 x90 x6f
++   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
++   */
++  public Object replyObject_16();
++
++  /**
++   * Simple object with one field
++   *
++   * 
++   * C x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
++   * 
++ */ ++ public Object replyObject_1(); ++ ++ /** ++ * Simple two objects with one field ++ * ++ *
++   * x7a
++   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
++   *   x60 x90
++   *   x60 x91
++   * 
++ */ ++ public Object replyObject_2(); ++ ++ /** ++ * Simple repeated object ++ * ++ *
++   * x7a
++   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
++   *   x60 x90
++   *   Q x91
++   * 
++ */ ++ public Object replyObject_2a(); ++ ++ /** ++ * Two object with equals ++ * ++ *
++   * x7a
++   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
++   *   x60 x90
++   *   x60 x90
++   * 
++ */ ++ public Object replyObject_2b(); ++ ++ /** ++ * Circular object ++ * ++ *
++   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
++   *   x60 x01 a Q \x90x
++   * 
++ */ ++ public Object replyObject_3(); ++ ++ // ++ // arguments ++ // ++ ++ /** ++ * Null ++ * ++ *
++   * N
++   * 
++ */ ++ public Object argNull(Object v); ++ ++ // ++ // boolean ++ // ++ ++ /** ++ * Boolean true ++ * ++ *
++   * T
++   * 
++ */ ++ public Object argTrue(Object v); ++ ++ /** ++ * Boolean false ++ * ++ *
++   * F
++   * 
++ */ ++ public Object argFalse(Object v); ++ ++ // ++ // integer ++ // ++ ++ /** ++ * Integer 0 ++ * ++ *
++   * x90
++   * 
++ */ ++ public Object argInt_0(Object v); ++ ++ /** ++ * Integer 1 ++ * ++ *
++   * x91
++   * 
++ */ ++ public Object argInt_1(Object v); ++ ++ /** ++ * integer 47 ++ * ++ *
++   * xbf
++   * 
++ */ ++ public Object argInt_47(Object v); ++ ++ /** ++ * Result of integer -16 ++ * ++ *
++   * R x80
++   * 
++ */ ++ public Object argInt_m16(Object v); ++ ++ // two byte integers ++ ++ /** ++ * Integer 0x30 ++ * ++ *
++   * xc8 x30
++   * 
++ */ ++ public Object argInt_0x30(Object v); ++ ++ /** ++ * Result of integer x7ff ++ * ++ *
++   * xcf xff
++   * 
++ */ ++ public Object argInt_0x7ff(Object v); ++ ++ /** ++ * integer -17 ++ * ++ *
++   * xc7 xef
++   * 
++ */ ++ public Object argInt_m17(Object v); ++ ++ /** ++ * Integer -0x800 ++ * ++ *
++   * xc0 x00
++   * 
++ */ ++ public Object argInt_m0x800(Object v); ++ ++ /** ++ * Integer 0x800 ++ * ++ *
++   * xd4 x08 x00
++   * 
++ */ ++ public Object argInt_0x800(Object v); ++ ++ /** ++ * Integer 0x3ffff ++ * ++ *
++   * xd7 xff xff
++   * 
++ */ ++ public Object argInt_0x3ffff(Object v); ++ ++ /** ++ * Integer -0x801 ++ * ++ *
++   * xd3 xf8 x00
++   * 
++ */ ++ public Object argInt_m0x801(Object v); ++ ++ /** ++ * Integer m0x40000 ++ * ++ *
++   * xd0 x00 x00
++   * 
++ */ ++ public Object argInt_m0x40000(Object v); ++ ++ // 5 byte integers ++ ++ /** ++ * integer 0x40000 ++ * ++ *
++   * I x00 x04 x00 x00
++   * 
++ */ ++ public Object argInt_0x40000(Object v); ++ ++ /** ++ * Integer 0x7fffffff ++ * ++ *
++   * I x7f xff xff xff
++   * 
++ */ ++ public Object argInt_0x7fffffff(Object v); ++ ++ /** ++ * Integer m0x40001 ++ * ++ *
++   * I xff xfb xff xff
++   * 
++ */ ++ public Object argInt_m0x40001(Object v); ++ ++ /** ++ * Result of integer -0x80000000 ++ * ++ *
++   * I x80 x00 x00 x00
++   * 
++ */ ++ public Object argInt_m0x80000000(Object v); ++ ++ // ++ // longs ++ // ++ ++ /** ++ * long 0 ++ * ++ *
++   * xe0
++   * 
++ */ ++ public Object argLong_0(Object v); ++ ++ /** ++ * long 1 ++ * ++ *
++   * xe1
++   * 
++ */ ++ public Object argLong_1(Object v); ++ ++ /** ++ * long 15 ++ * ++ *
++   * xef
++   * 
++ */ ++ public Object argLong_15(Object v); ++ ++ /** ++ * long -8 ++ * ++ *
++   * xd8
++   * 
++ */ ++ public Object argLong_m8(Object v); ++ ++ // two byte longs ++ ++ /** ++ * long 0x10 ++ * ++ *
++   * xf8 x10
++   * 
++ */ ++ public Object argLong_0x10(Object v); ++ ++ /** ++ * long x7ff ++ * ++ *
++   * xff xff
++   * 
++ */ ++ public Object argLong_0x7ff(Object v); ++ ++ /** ++ * long -9 ++ * ++ *
++   * xf7 xf7
++   * 
++ */ ++ public Object argLong_m9(Object v); ++ ++ /** ++ * long -0x800 ++ * ++ *
++   * xf0 x00
++   * 
++ */ ++ public Object argLong_m0x800(Object v); ++ ++ /** ++ * long 0x800 ++ * ++ *
++   * x3c x08 x00
++   * 
++ */ ++ public Object argLong_0x800(Object v); ++ ++ /** ++ * long 0x3ffff ++ * ++ *
++   * x3f xff xff
++   * 
++ */ ++ public Object argLong_0x3ffff(Object v); ++ ++ /** ++ * long -0x801 ++ * ++ *
++   * x3b xf7 xff
++   * 
++ */ ++ public Object argLong_m0x801(Object v); ++ ++ /** ++ * long m0x40000 ++ * ++ *
++   * x38 x00 x00
++   * 
++ */ ++ public Object argLong_m0x40000(Object v); ++ ++ // 5 byte longs ++ ++ /** ++ * long 0x40000 ++ * ++ *
++   * x59 x00 x04 x00 x00
++   * 
++ */ ++ public Object argLong_0x40000(Object v); ++ ++ /** ++ * long 0x7fffffff ++ * ++ *
++   * x59 x7f xff xff xff
++   * 
++ */ ++ public Object argLong_0x7fffffff(Object v); ++ ++ /** ++ * long m0x40001 ++ * ++ *
++   * x59 xff xfb xff xf
++   * 
++ */ ++ public Object argLong_m0x40001(Object v); ++ ++ /** ++ * long -0x80000000 ++ * ++ *
++   * x59 x80 x00 x00 x00
++   * 
++ */ ++ public Object argLong_m0x80000000(Object v); ++ ++ /** ++ * Result of long 0x80000000 ++ * ++ *
++   * L x00 x00 x00 x00 x80 x00 x00 x00
++   * 
++ */ ++ public Object argLong_0x80000000(Object v); ++ ++ /** ++ * Result of long -0x80000001 ++ * ++ *
++   * L xff xff xff xff x7f xff xff xff
++   * 
++ */ ++ public Object argLong_m0x80000001(Object v); ++ ++ // ++ // doubles ++ // ++ ++ /** ++ * double 0.0 ++ * ++ *
++   * x5b
++   * 
++ */ ++ public Object argDouble_0_0(Object v); ++ ++ /** ++ * double 1.0 ++ * ++ *
++   * x5c
++   * 
++ */ ++ public Object argDouble_1_0(Object v); ++ ++ /** ++ * double 2.0 ++ * ++ *
++   * x5d x02
++   * 
++ */ ++ public Object argDouble_2_0(Object v); ++ ++ /** ++ * double 127.0 ++ * ++ *
++   * x5d x7f
++   * 
++ */ ++ public Object argDouble_127_0(Object v); ++ ++ /** ++ * double -128.0 ++ * ++ *
++   * x5d x80
++   * 
++ */ ++ public Object argDouble_m128_0(Object v); ++ ++ /** ++ * double 128.0 ++ * ++ *
++   * x5e x00 x80
++   * 
++ */ ++ public Object argDouble_128_0(Object v); ++ ++ /** ++ * double -129.0 ++ * ++ *
++   * x5e xff x7f
++   * 
++ */ ++ public Object argDouble_m129_0(Object v); ++ ++ /** ++ * double 32767.0 ++ * ++ *
++   * x5e x7f xff
++   * 
++ */ ++ public Object argDouble_32767_0(Object v); ++ ++ /** ++ * Double -32768.0 ++ * ++ *
++   * x5e x80 x80
++   * 
++ */ ++ public Object argDouble_m32768_0(Object v); ++ ++ /** ++ * double 0.001 ++ * ++ *
++   * x5f x00 x00 x00 x01
++   * 
++ */ ++ public Object argDouble_0_001(Object v); ++ ++ /** ++ * double -0.001 ++ * ++ *
++   * x5f xff xff xff xff
++   * 
++ */ ++ public Object argDouble_m0_001(Object v); ++ ++ /** ++ * double 65.536 ++ * ++ *
++   * x5f x00 x01 x00 x00
++   * 
++ */ ++ public Object argDouble_65_536(Object v); ++ ++ /** ++ * Result of double 3.14159 ++ * ++ *
++   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
++   * 
++ */ ++ public Object argDouble_3_14159(Object v); ++ ++ // ++ // date ++ // ++ ++ /** ++ * date 0 (01-01-1970 00:00 GMT) ++ * ++ *
++   * x4a x00 x00 x00 x00
++   * 
++ */ ++ public Object argDate_0(Object v); ++ ++ /** ++ * Date by millisecond (05-08-1998 07:51 GMT) ++ * ++ *
++   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
++   * 
++ */ ++ public Object argDate_1(Object v); ++ ++ /** ++ * Date by minute (05-08-1998 07:51 GMT) ++ * ++ *
++   * x4b x00 xe3 x83 x8f
++   * 
++ */ ++ public Object argDate_2(Object v); ++ ++ // ++ // string length ++ // ++ ++ /** ++ * A zero-length string ++ * ++ *
++   * x00
++   * 
++ */ ++ public Object argString_0(Object v); ++ ++ /** ++ * A one-length string ++ * ++ *
++   * x01 a
++   * 
++ */ ++ public Object argString_1(Object v); ++ ++ /** ++ * A 31-length string ++ * ++ *
++   * x0f 0123456789012345678901234567890
++   * 
++ */ ++ public Object argString_31(Object v); ++ ++ /** ++ * A 32-length string ++ * ++ *
++   * x30 x02 01234567890123456789012345678901
++   * 
++ */ ++ public Object argString_32(Object v); ++ ++ /** ++ * A 1023-length string ++ * ++ *
++   * x33 xff 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object argString_1023(Object v); ++ ++ /** ++ * A 1024-length string ++ * ++ *
++   * S x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object argString_1024(Object v); ++ ++ /** ++ * A 65536-length string ++ * ++ *
++   * R x80 x00 000 ...
++   * S x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object argString_65536(Object v); ++ ++ // ++ // binary length ++ // ++ ++ /** ++ * A zero-length binary ++ * ++ *
++   * x20
++   * 
++ */ ++ public Object argBinary_0(Object v); ++ ++ /** ++ * A one-length string ++ * ++ *
++   * x21 0
++   * 
++ */ ++ public Object argBinary_1(Object v); ++ ++ /** ++ * A 15-length binary ++ * ++ *
++   * x2f 0123456789012345
++   * 
++ */ ++ public Object argBinary_15(Object v); ++ ++ /** ++ * A 16-length binary ++ * ++ *
++   * x34 x10 01234567890123456789012345678901
++   * 
++ */ ++ public Object argBinary_16(Object v); ++ ++ /** ++ * A 1023-length binary ++ * ++ *
++   * x37 xff 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object argBinary_1023(Object v); ++ ++ /** ++ * A 1024-length binary ++ * ++ *
++   * B x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object argBinary_1024(Object v); ++ ++ /** ++ * A 65536-length binary ++ * ++ *
++   * A x80 x00 000 ...
++   * B x04 x00 000 01234567890123456789012345678901...
++   * 
++ */ ++ public Object argBinary_65536(Object v); ++ ++ // ++ // lists ++ // ++ ++ /** ++ * Zero-length untyped list ++ * ++ *
++   * x78
++   * 
++ */ ++ public Object argUntypedFixedList_0(Object v); ++ ++ /** ++ * 1-length untyped list ++ * ++ *
++   * x79 x01 1
++   * 
++ */ ++ public Object argUntypedFixedList_1(Object v); ++ ++ /** ++ * 7-length untyped list ++ * ++ *
++   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
++   * 
++ */ ++ public Object argUntypedFixedList_7(Object v); ++ ++ /** ++ * 8-length untyped list ++ * ++ *
++   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
++   * 
++ */ ++ public Object argUntypedFixedList_8(Object v); ++ ++ /** ++ * Zero-length typed list (String array) ++ * ++ *
++   * x70 x07 [string
++   * 
++ */ ++ public Object argTypedFixedList_0(Object v); ++ ++ /** ++ * 1-length typed list (String array) ++ * ++ *
++   * x71 x07 [string x01 1
++   * 
++ */ ++ public Object argTypedFixedList_1(Object v); ++ ++ /** ++ * 7-length typed list (String array) ++ * ++ *
++   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
++   * 
++ */ ++ public Object argTypedFixedList_7(Object v); ++ ++ /** ++ * 8-length typed list (String array) ++ * ++ *
++   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
++   * 
++ */ ++ public Object argTypedFixedList_8(Object v); ++ ++ // ++ // untyped maps ++ // ++ ++ /** ++ * zero-length untyped map ++ * ++ *
++   * H Z
++   * 
++ */ ++ public Object argUntypedMap_0(Object v); ++ ++ /** ++ * untyped map with string key ++ * ++ *
++   * H x01 a x90 Z
++   * 
++ */ ++ public Object argUntypedMap_1(Object v); ++ ++ /** ++ * untyped map with int key ++ * ++ *
++   * H x90 x01 a x91 x01 b Z
++   * 
++ */ ++ public Object argUntypedMap_2(Object v); ++ ++ /** ++ * untyped map with list key ++ * ++ *
++   * H x71 x01 a x90 Z
++   * 
++ */ ++ public Object argUntypedMap_3(Object v); ++ ++ // ++ // typed maps ++ // ++ ++ /** ++ * zero-length typed map ++ * ++ *
++   * M x13 java.lang.Hashtable Z
++   * 
++ */ ++ public Object argTypedMap_0(Object v); ++ ++ /** ++ * untyped map with string key ++ * ++ *
++   * M x13 java.lang.Hashtable x01 a x90 Z
++   * 
++ */ ++ public Object argTypedMap_1(Object v); ++ ++ /** ++ * typed map with int key ++ * ++ *
++   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
++   * 
++ */ ++ public Object argTypedMap_2(Object v); ++ ++ /** ++ * typed map with list key ++ * ++ *
++   * M x13 java.lang.Hashtable x79 x01 a x90 Z
++   * 
++ */ ++ public Object argTypedMap_3(Object v); ++ ++ // ++ // objects ++ // ++ ++ /** ++ * Returns a single object ++ * ++ *
++   * C x1a com.caucho.hessian.test.A0 x90 x60
++   * 
++ */ ++ public Object argObject_0(Object v); ++ ++ /** ++ * Returns 16 object types ++ * ++ *
++   * X xa0
++   *  C x1a com.caucho.hessian.test.A0 x90 x60
++   *  C x1a com.caucho.hessian.test.A1 x90 x61
++   *  C x1a com.caucho.hessian.test.A2 x90 x62
++   *  C x1a com.caucho.hessian.test.A3 x90 x63
++   *  C x1a com.caucho.hessian.test.A4 x90 x64
++   *  C x1a com.caucho.hessian.test.A5 x90 x65
++   *  C x1a com.caucho.hessian.test.A6 x90 x66
++   *  C x1a com.caucho.hessian.test.A7 x90 x67
++   *  C x1a com.caucho.hessian.test.A8 x90 x68
++   *  C x1a com.caucho.hessian.test.A9 x90 x69
++   *  C x1b com.caucho.hessian.test.A10 x90 x6a
++   *  C x1b com.caucho.hessian.test.A11 x90 x6b
++   *  C x1b com.caucho.hessian.test.A12 x90 x6c
++   *  C x1b com.caucho.hessian.test.A13 x90 x6d
++   *  C x1b com.caucho.hessian.test.A14 x90 x6e
++   *  C x1b com.caucho.hessian.test.A15 x90 x6f
++   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
++   */
++  public Object argObject_16(Object v);
++
++  /**
++   * Simple object with one field
++   *
++   * 
++   * C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
++   * 
++ */ ++ public Object argObject_1(Object v); ++ ++ /** ++ * Simple two objects with one field ++ * ++ *
++   * x7a
++   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
++   *   x60 x90
++   *   x60 x91
++   * 
++ */ ++ public Object argObject_2(Object v); ++ ++ /** ++ * Simple repeated object ++ * ++ *
++   * x7a
++   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
++   *   x60 x90
++   *   Q x91
++   * 
++ */ ++ public Object argObject_2a(Object v); ++ ++ /** ++ * Two object with equals ++ * ++ *
++   * x7a
++   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
++   *   x60 x90
++   *   x60 x90
++   * 
++ */ ++ public Object argObject_2b(Object v); ++ ++ /** ++ * Circular object ++ * ++ *
++   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
++   *   x60 x01 a Q x90
++   * 
++ */ ++ public Object argObject_3(Object v); ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2Servlet.java hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2Servlet.java +--- hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2Servlet.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2Servlet.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,1805 +1,1805 @@ +-package com.caucho.hessian.test; +- +-import com.caucho.hessian.io.*; +-import com.caucho.hessian.server.HessianServlet; +-import java.io.*; +-import java.util.*; +- +-/** +- * The test service is a Hessian 2.0 protocol test for developers of +- * Hessian 2.0 clients. For a new client the recommended order is: +- * +- *
    +- *
  • methodNull +- *
  • methodHello +- *
+- */ +-public class TestHessian2Servlet +- extends HessianServlet +- implements TestHessian2 +-{ +- private ThreadLocal _threadWriter +- = new ThreadLocal(); +- +- public void methodNull() +- { +- } +- +- // +- // reply tests, testing serialization output +- // +- +- public void replyNull() +- { +- } +- +- // +- // boolean +- // +- +- public Object replyTrue() +- { +- return true; +- } +- +- public Object replyFalse() +- { +- return false; +- } +- +- // +- // integers +- // +- +- // single byte integers +- +- public int replyInt_0() +- { +- return 0; +- } +- +- public int replyInt_1() +- { +- return 1; +- } +- +- public int replyInt_47() +- { +- return 47; +- } +- +- public int replyInt_m16() +- { +- return -16; +- } +- +- // two byte integers +- +- public int replyInt_0x30() +- { +- return 0x30; +- } +- +- public int replyInt_0x7ff() +- { +- return 0x7ff; +- } +- +- public int replyInt_m17() +- { +- return -17; +- } +- +- public int replyInt_m0x800() +- { +- return -0x800; +- } +- +- // three byte integers +- +- public int replyInt_0x800() +- { +- return 0x800; +- } +- +- public int replyInt_0x3ffff() +- { +- return 0x3ffff; +- } +- +- public int replyInt_m0x801() +- { +- return -0x801; +- } +- +- public int replyInt_m0x40000() +- { +- return - 0x40000; +- } +- +- // 5 byte integers +- +- public int replyInt_0x40000() +- { +- return 0x40000; +- } +- +- public int replyInt_0x7fffffff() +- { +- return 0x7fffffff; +- } +- +- public int replyInt_m0x40001() +- { +- return - 0x40001; +- } +- +- public int replyInt_m0x80000000() +- { +- return - 0x80000000; +- } +- +- // +- // longs +- // +- +- // single byte longs +- +- public long replyLong_0() +- { +- return 0; +- } +- +- public long replyLong_1() +- { +- return 1; +- } +- +- public long replyLong_15() +- { +- return 15; +- } +- +- public long replyLong_m8() +- { +- return -8; +- } +- +- // two byte longs +- +- public long replyLong_0x10() +- { +- return 0x10; +- } +- +- public long replyLong_0x7ff() +- { +- return 0x7ff; +- } +- +- public long replyLong_m9() +- { +- return -9; +- } +- +- public long replyLong_m0x800() +- { +- return -0x800; +- } +- +- // three byte longs +- +- public long replyLong_0x800() +- { +- return 0x800; +- } +- +- public long replyLong_0x3ffff() +- { +- return 0x3ffff; +- } +- +- public long replyLong_m0x801() +- { +- return -0x801; +- } +- +- public long replyLong_m0x40000() +- { +- return - 0x40000; +- } +- +- // 5 byte longs +- +- public long replyLong_0x40000() +- { +- return 0x40000; +- } +- +- public long replyLong_0x7fffffff() +- { +- return 0x7fffffff; +- } +- +- public long replyLong_m0x40001() +- { +- return - 0x40001; +- } +- +- public long replyLong_m0x80000000() +- { +- return - 0x80000000; +- } +- +- public long replyLong_0x80000000() +- { +- return 0x80000000L; +- } +- +- public long replyLong_m0x80000001() +- { +- return - 0x80000001L; +- } +- +- // +- // doubles +- // +- +- public double replyDouble_0_0() +- { +- return 0; +- } +- +- public double replyDouble_1_0() +- { +- return 1; +- } +- +- public double replyDouble_2_0() +- { +- return 2; +- } +- +- public double replyDouble_127_0() +- { +- return 127; +- } +- +- public double replyDouble_m128_0() +- { +- return -128; +- } +- +- public double replyDouble_128_0() +- { +- return 128; +- } +- +- public double replyDouble_m129_0() +- { +- return -129; +- } +- +- public double replyDouble_32767_0() +- { +- return 32767; +- } +- +- public double replyDouble_m32768_0() +- { +- return -32768; +- } +- +- public double replyDouble_0_001() +- { +- return 0.001; +- } +- +- public double replyDouble_m0_001() +- { +- return - 0.001; +- } +- +- public double replyDouble_65_536() +- { +- return 65.536; +- } +- +- public double replyDouble_3_14159() +- { +- return 3.14159; +- } +- +- // date +- +- public Object replyDate_0() +- { +- return new Date(0); +- } +- +- public Object replyDate_1() +- { +- long time = 894621091000L; +- +- return new Date(time); +- } +- +- public Object replyDate_2() +- { +- long time = 894621091000L; +- +- time -= time % 60000L; +- +- return new Date(time); +- } +- +- // strings by length +- +- public String replyString_0() +- { +- return ""; +- } +- +- public String replyString_null() +- { +- return null; +- } +- +- public String replyString_1() +- { +- return "0"; +- } +- +- public String replyString_31() +- { +- return "0123456789012345678901234567890"; +- } +- +- public String replyString_32() +- { +- return "01234567890123456789012345678901"; +- } +- +- public String replyString_1023() +- { +- StringBuilder sb = new StringBuilder(); +- +- for (int i = 0; i < 16; i++) { +- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); +- } +- +- sb.setLength(1023); +- +- return sb.toString(); +- } +- +- public String replyString_1024() +- { +- StringBuilder sb = new StringBuilder(); +- +- for (int i = 0; i < 16; i++) { +- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); +- } +- +- sb.setLength(1024); +- +- return sb.toString(); +- } +- +- public String replyString_65536() +- { +- StringBuilder sb = new StringBuilder(); +- +- for (int i = 0; i < 64 * 16; i++) { +- sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); +- } +- +- sb.setLength(65536); +- +- return sb.toString(); +- } +- +- // binarys by length +- +- public Object replyBinary_0() +- { +- return new byte[0]; +- } +- +- public Object replyBinary_null() +- { +- return null; +- } +- +- public Object replyBinary_1() +- { +- return toBinary("0"); +- } +- +- public Object replyBinary_15() +- { +- return toBinary("012345678901234"); +- } +- +- public Object replyBinary_16() +- { +- return toBinary("0123456789012345"); +- } +- +- public Object replyBinary_1023() +- { +- StringBuilder sb = new StringBuilder(); +- +- for (int i = 0; i < 16; i++) { +- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); +- } +- +- sb.setLength(1023); +- +- return toBinary(sb.toString()); +- } +- +- public Object replyBinary_1024() +- { +- StringBuilder sb = new StringBuilder(); +- +- for (int i = 0; i < 16; i++) { +- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); +- } +- +- sb.setLength(1024); +- +- return toBinary(sb.toString()); +- } +- +- public Object replyBinary_65536() +- { +- StringBuilder sb = new StringBuilder(); +- +- for (int i = 0; i < 64 * 16; i++) { +- sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); +- } +- +- sb.setLength(65536); +- +- return toBinary(sb.toString()); +- } +- +- private byte []toBinary(String s) +- { +- byte []buffer = new byte[s.length()]; +- +- for (int i = 0; i < s.length(); i++) +- buffer[i] = (byte) s.charAt(i); +- +- return buffer; +- } +- +- // +- // lists +- // +- +- public Object replyUntypedFixedList_0() +- { +- ArrayList list = new ArrayList(); +- +- return list; +- } +- +- public Object replyUntypedFixedList_1() +- { +- ArrayList list = new ArrayList(); +- +- list.add("1"); +- +- return list; +- } +- +- public Object replyUntypedFixedList_7() +- { +- ArrayList list = new ArrayList(); +- +- list.add("1"); +- list.add("2"); +- list.add("3"); +- list.add("4"); +- list.add("5"); +- list.add("6"); +- list.add("7"); +- +- return list; +- } +- +- public Object replyUntypedFixedList_8() +- { +- ArrayList list = new ArrayList(); +- +- list.add("1"); +- list.add("2"); +- list.add("3"); +- list.add("4"); +- list.add("5"); +- list.add("6"); +- list.add("7"); +- list.add("8"); +- +- return list; +- } +- +- public Object replyTypedFixedList_0() +- { +- return new String[] {}; +- } +- +- public Object replyTypedFixedList_1() +- { +- return new String[] { "1" }; +- } +- +- public Object replyTypedFixedList_7() +- { +- return new String[] { "1", "2", "3", "4", "5", "6", "7" }; +- } +- +- public Object replyTypedFixedList_8() +- { +- return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }; +- } +- +- // untyped map +- +- public Object replyUntypedMap_0() +- { +- return new HashMap(); +- } +- +- public Object replyUntypedMap_1() +- { +- HashMap map = new HashMap(); +- map.put("a", 0); +- +- return map; +- } +- +- public Object replyUntypedMap_2() +- { +- HashMap map = new HashMap(); +- +- map.put(0, "a"); +- map.put(1, "b"); +- +- return map; +- } +- +- public Object replyUntypedMap_3() +- { +- HashMap map = new HashMap(); +- +- ArrayList list = new ArrayList(); +- list.add("a"); +- +- map.put(list, 0); +- +- return map; +- } +- +- // typed map +- +- public Object replyTypedMap_0() +- { +- Hashtable map = new Hashtable(); +- +- return map; +- } +- +- public Object replyTypedMap_1() +- { +- Map map = new Hashtable(); +- +- map.put("a", 0); +- +- return map; +- } +- +- public Object replyTypedMap_2() +- { +- Map map = new Hashtable(); +- +- map.put(0, "a"); +- map.put(1, "b"); +- +- return map; +- } +- +- public Object replyTypedMap_3() +- { +- Map map = new Hashtable(); +- +- ArrayList list = new ArrayList(); +- list.add("a"); +- +- map.put(list, 0); +- +- return map; +- } +- +- // +- // objects +- // +- +- public Object replyObject_0() +- { +- return new A0(); +- } +- +- public Object replyObject_16() +- { +- ArrayList list = new ArrayList(); +- +- list.add(new A0()); +- list.add(new A1()); +- list.add(new A2()); +- list.add(new A3()); +- list.add(new A4()); +- list.add(new A5()); +- list.add(new A6()); +- list.add(new A7()); +- list.add(new A8()); +- list.add(new A9()); +- list.add(new A10()); +- list.add(new A11()); +- list.add(new A12()); +- list.add(new A13()); +- list.add(new A14()); +- list.add(new A15()); +- list.add(new A16()); +- +- return list; +- } +- +- public Object replyObject_1() +- { +- return new TestObject(0); +- } +- +- public Object replyObject_2() +- { +- ArrayList list = new ArrayList(); +- +- list.add(new TestObject(0)); +- list.add(new TestObject(1)); +- +- return list; +- } +- +- public Object replyObject_2a() +- { +- ArrayList list = new ArrayList(); +- +- TestObject obj = new TestObject(0); +- +- list.add(obj); +- list.add(obj); +- +- return list; +- } +- +- public Object replyObject_2b() +- { +- ArrayList list = new ArrayList(); +- +- list.add(new TestObject(0)); +- list.add(new TestObject(0)); +- +- return list; +- } +- +- public Object replyObject_3() +- { +- TestCons cons = new TestCons(); +- +- cons.setFirst("a"); +- cons.setRest(cons); +- +- return cons; +- } +- +- // +- // arguments +- // +- +- public Object argNull(Object v) +- { +- if (v == null) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argTrue(Object v) +- { +- if (Boolean.TRUE.equals(v)) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argFalse(Object v) +- { +- if (Boolean.FALSE.equals(v)) +- return true; +- +- return getInputDebug(); +- } +- +- // integers +- +- public Object argInt_0(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 0) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_1(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 1) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_47(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 47) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_m16(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == -16) +- return true; +- } +- +- return getInputDebug(); +- } +- +- // two byte integers +- +- public Object argInt_0x30(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 0x30) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_0x7ff(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 0x7ff) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_m17(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == -17) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_m0x800(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == -0x800) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_0x800(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 0x800) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_0x3ffff(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 0x3ffff) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_m0x801(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == -0x801) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_m0x40000(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == -0x40000) +- return true; +- } +- +- return getInputDebug(); +- } +- +- // 5 byte integers +- +- public Object argInt_0x40000(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 0x40000) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_0x7fffffff(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == 0x7fffffff) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_m0x40001(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == -0x40001) +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argInt_m0x80000000(Object v) +- { +- if (v instanceof Integer) { +- Integer value = (Integer) v; +- +- if (value == -0x80000000) +- return true; +- } +- +- return getInputDebug(); +- } +- +- // +- // longs +- // +- +- public Object argLong_0(Object v) +- { +- if (v.equals(replyLong_0())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_1(Object v) +- { +- if (v.equals(replyLong_1())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_15(Object v) +- { +- if (v.equals(replyLong_15())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m8(Object v) +- { +- if (v.equals(replyLong_m8())) +- return true; +- +- return getInputDebug(); +- } +- +- // two byte longs +- +- public Object argLong_0x10(Object v) +- { +- if (v.equals(replyLong_0x10())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_0x7ff(Object v) +- { +- if (v.equals(replyLong_0x7ff())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m9(Object v) +- { +- if (v.equals(replyLong_m9())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m0x800(Object v) +- { +- if (v.equals(replyLong_m0x800())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_0x800(Object v) +- { +- if (v.equals(replyLong_0x800())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_0x3ffff(Object v) +- { +- if (v.equals(replyLong_0x3ffff())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m0x801(Object v) +- { +- if (v.equals(replyLong_m0x801())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m0x40000(Object v) +- { +- if (v.equals(replyLong_m0x40000())) +- return true; +- +- return getInputDebug(); +- } +- +- // 5 byte longs +- +- public Object argLong_0x40000(Object v) +- { +- if (v.equals(replyLong_0x40000())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_0x7fffffff(Object v) +- { +- if (v.equals(replyLong_0x7fffffff())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m0x40001(Object v) +- { +- if (v.equals(replyLong_m0x40001())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m0x80000000(Object v) +- { +- if (v.equals(replyLong_m0x80000000())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_0x80000000(Object v) +- { +- if (v.equals(replyLong_0x80000000())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argLong_m0x80000001(Object v) +- { +- if (v.equals(replyLong_m0x80000001())) +- return true; +- +- return getInputDebug(); +- } +- +- // +- // doubles +- // +- +- /** +- * double 0.0 +- * +- *
+-   * x5b
+-   * 
+- */ +- public Object argDouble_0_0(Object v) +- { +- if (v.equals(replyDouble_0_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double 1.0 +- * +- *
+-   * x5c
+-   * 
+- */ +- public Object argDouble_1_0(Object v) +- { +- if (v.equals(replyDouble_1_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double 2.0 +- * +- *
+-   * x5d x02
+-   * 
+- */ +- public Object argDouble_2_0(Object v) +- { +- if (v.equals(replyDouble_2_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double 127.0 +- * +- *
+-   * x5d x7f
+-   * 
+- */ +- public Object argDouble_127_0(Object v) +- { +- if (v.equals(replyDouble_127_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double -128.0 +- * +- *
+-   * x5d x80
+-   * 
+- */ +- public Object argDouble_m128_0(Object v) +- { +- if (v.equals(replyDouble_m128_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double 128.0 +- * +- *
+-   * x5e x00 x80
+-   * 
+- */ +- public Object argDouble_128_0(Object v) +- { +- if (v.equals(replyDouble_128_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double -129.0 +- * +- *
+-   * x5e xff x7f
+-   * 
+- */ +- public Object argDouble_m129_0(Object v) +- { +- if (v.equals(replyDouble_m129_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double 32767.0 +- * +- *
+-   * x5e x7f xff
+-   * 
+- */ +- public Object argDouble_32767_0(Object v) +- { +- if (v.equals(replyDouble_32767_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * Double -32768.0 +- * +- *
+-   * x5e x80 x80
+-   * 
+- */ +- public Object argDouble_m32768_0(Object v) +- { +- if (v.equals(replyDouble_m32768_0())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double 0.001 +- * +- *
+-   * x5f x00 x00 x00 x01
+-   * 
+- */ +- public Object argDouble_0_001(Object v) +- { +- if (v.equals(replyDouble_0_001())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double -0.001 +- * +- *
+-   * x5f xff xff xff xff
+-   * 
+- */ +- public Object argDouble_m0_001(Object v) +- { +- if (v.equals(replyDouble_m0_001())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * double 65.536 +- * +- *
+-   * x5f x00 x01 x00 x00
+-   * 
+- */ +- public Object argDouble_65_536(Object v) +- { +- if (v.equals(replyDouble_65_536())) +- return true; +- +- return getInputDebug(); +- } +- +- /** +- * Result of double 3.14159 +- * +- *
+-   * D x00 x01 x00 x00 x00 x00 x00 x00
+-   * 
+- */ +- public Object argDouble_3_14159(Object v) +- { +- if (v.equals(replyDouble_3_14159())) +- return true; +- +- return getInputDebug(); +- } +- +- // +- // date +- // +- +- public Object argDate_0(Object v) +- { +- if (v.equals(replyDate_0())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argDate_1(Object v) +- { +- if (v.equals(replyDate_1())) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argDate_2(Object v) +- { +- if (v.equals(replyDate_2())) +- return true; +- +- return getInputDebug(); +- } +- +- // +- // string length +- // +- +- public Object argString_0(Object v) +- { +- String expect = ""; +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argString_1(Object v) +- { +- String expect = "0"; +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argString_31(Object v) +- { +- String expect = "0123456789012345678901234567890"; +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argString_32(Object v) +- { +- String expect = "01234567890123456789012345678901"; +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argString_1023(Object v) +- { +- String expect = replyString_1023(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argString_1024(Object v) +- { +- String expect = replyString_1024(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argString_65536(Object v) +- { +- String expect = replyString_65536(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- // +- // binary length +- // +- +- public Object argBinary_0(Object v) +- { +- byte []expect = (byte []) replyBinary_0(); +- +- if (equals(expect, v)) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argBinary_1(Object v) +- { +- byte []expect = (byte []) replyBinary_1(); +- +- if (equals(expect, v)) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argBinary_15(Object v) +- { +- byte []expect = (byte []) replyBinary_15(); +- +- if (equals(expect, v)) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argBinary_16(Object v) +- { +- byte []expect = (byte []) replyBinary_16(); +- +- if (equals(expect, v)) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argBinary_1023(Object v) +- { +- byte []expect = (byte []) replyBinary_1023(); +- +- if (equals(expect, v)) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argBinary_1024(Object v) +- { +- byte []expect = (byte []) replyBinary_1024(); +- +- if (equals(expect, v)) +- return true; +- +- return getInputDebug(); +- } +- +- public Object argBinary_65536(Object v) +- { +- byte []expect = (byte []) replyBinary_65536(); +- +- if (equals(expect, v)) +- return true; +- +- return getInputDebug(); +- } +- +- // +- // lists +- // +- +- public Object argUntypedFixedList_0(Object v) +- { +- Object expect = replyUntypedFixedList_0(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argUntypedFixedList_1(Object v) +- { +- Object expect = replyUntypedFixedList_1(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argUntypedFixedList_7(Object v) +- { +- Object expect = replyUntypedFixedList_7(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argUntypedFixedList_8(Object v) +- { +- Object expect = replyUntypedFixedList_8(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argTypedFixedList_0(Object v) +- { +- String []expect = (String []) replyTypedFixedList_0(); +- +- if (v instanceof String[] && equals(expect, (String []) v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argTypedFixedList_1(Object v) +- { +- String []expect = (String []) replyTypedFixedList_1(); +- +- if (v instanceof String[] && equals(expect, (String []) v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argTypedFixedList_7(Object v) +- { +- String []expect = (String []) replyTypedFixedList_7(); +- +- if (v instanceof String[] && equals(expect, (String []) v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argTypedFixedList_8(Object v) +- { +- String []expect = (String []) replyTypedFixedList_8(); +- +- if (v instanceof String[] && equals(expect, (String []) v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- // +- // untyped maps +- // +- +- public Object argUntypedMap_0(Object v) +- { +- Object expect = replyUntypedMap_0(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argUntypedMap_1(Object v) +- { +- Object expect = replyUntypedMap_1(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argUntypedMap_2(Object v) +- { +- Object expect = replyUntypedMap_2(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argUntypedMap_3(Object v) +- { +- Object expect = replyUntypedMap_3(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- // +- // typed maps +- // +- +- public Object argTypedMap_0(Object v) +- { +- Object expect = replyTypedMap_0(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argTypedMap_1(Object v) +- { +- Object expect = replyTypedMap_1(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argTypedMap_2(Object v) +- { +- Object expect = replyTypedMap_2(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argTypedMap_3(Object v) +- { +- Object expect = replyTypedMap_3(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- // +- // objects +- // +- +- public Object argObject_0(Object v) +- { +- Object expect = replyObject_0(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argObject_16(Object v) +- { +- Object expect = replyObject_16(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argObject_1(Object v) +- { +- Object expect = replyObject_1(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argObject_2(Object v) +- { +- Object expect = replyObject_2(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argObject_2a(Object v) +- { +- Object expect = replyObject_2a(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argObject_2b(Object v) +- { +- Object expect = replyObject_2b(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- public Object argObject_3(Object v) +- { +- Object expect = replyObject_3(); +- +- if (expect.equals(v)) { +- return true; +- } +- +- return getInputDebug(); +- } +- +- private boolean equals(String []a, String []b) +- { +- if (a == null || b == null) +- return false; +- +- if (a.length != b.length) +- return false; +- +- for (int i = 0; i < a.length; i++) { +- if (! a[i].equals(b[i])) +- return false; +- } +- +- return true; +- } +- +- private boolean equals(byte []a, Object obj) +- { +- if (! (obj instanceof byte[])) +- return false; +- +- byte []b = (byte []) obj; +- +- if (a == null || b == null) +- return false; +- +- if (a.length != b.length) +- return false; +- +- for (int i = 0; i < a.length; i++) { +- if (a[i] != b[i]) { +- return false; +- } +- } +- +- return true; +- } +- +- protected String getInputDebug() +- { +- CharArrayWriter writer = _threadWriter.get(); +- if (writer != null) +- return writer.toString(); +- else +- return null; +- } +- +- /** +- * Invoke the object with the request from the input stream. +- * +- * @param in the Hessian input stream +- * @param out the Hessian output stream +- */ +- @Override +- public void invoke(InputStream is, OutputStream os, String objectId, +- SerializerFactory serializerFactory) +- throws Exception +- { +- CharArrayWriter writer = new CharArrayWriter(); +- +- _threadWriter.set(writer); +- +- PrintWriter dbg = new PrintWriter(writer); +- +- HessianDebugInputStream debug = new HessianDebugInputStream(is, dbg); +- debug.startTop2(); +- +- super.invoke(debug, os, objectId, serializerFactory); +- } +-} ++package com.caucho.hessian.test; ++ ++import com.caucho.hessian.io.*; ++import com.caucho.hessian.server.HessianServlet; ++import java.io.*; ++import java.util.*; ++ ++/** ++ * The test service is a Hessian 2.0 protocol test for developers of ++ * Hessian 2.0 clients. For a new client the recommended order is: ++ * ++ *
    ++ *
  • methodNull ++ *
  • methodHello ++ *
++ */ ++public class TestHessian2Servlet ++ extends HessianServlet ++ implements TestHessian2 ++{ ++ private ThreadLocal _threadWriter ++ = new ThreadLocal(); ++ ++ public void methodNull() ++ { ++ } ++ ++ // ++ // reply tests, testing serialization output ++ // ++ ++ public void replyNull() ++ { ++ } ++ ++ // ++ // boolean ++ // ++ ++ public Object replyTrue() ++ { ++ return true; ++ } ++ ++ public Object replyFalse() ++ { ++ return false; ++ } ++ ++ // ++ // integers ++ // ++ ++ // single byte integers ++ ++ public int replyInt_0() ++ { ++ return 0; ++ } ++ ++ public int replyInt_1() ++ { ++ return 1; ++ } ++ ++ public int replyInt_47() ++ { ++ return 47; ++ } ++ ++ public int replyInt_m16() ++ { ++ return -16; ++ } ++ ++ // two byte integers ++ ++ public int replyInt_0x30() ++ { ++ return 0x30; ++ } ++ ++ public int replyInt_0x7ff() ++ { ++ return 0x7ff; ++ } ++ ++ public int replyInt_m17() ++ { ++ return -17; ++ } ++ ++ public int replyInt_m0x800() ++ { ++ return -0x800; ++ } ++ ++ // three byte integers ++ ++ public int replyInt_0x800() ++ { ++ return 0x800; ++ } ++ ++ public int replyInt_0x3ffff() ++ { ++ return 0x3ffff; ++ } ++ ++ public int replyInt_m0x801() ++ { ++ return -0x801; ++ } ++ ++ public int replyInt_m0x40000() ++ { ++ return - 0x40000; ++ } ++ ++ // 5 byte integers ++ ++ public int replyInt_0x40000() ++ { ++ return 0x40000; ++ } ++ ++ public int replyInt_0x7fffffff() ++ { ++ return 0x7fffffff; ++ } ++ ++ public int replyInt_m0x40001() ++ { ++ return - 0x40001; ++ } ++ ++ public int replyInt_m0x80000000() ++ { ++ return - 0x80000000; ++ } ++ ++ // ++ // longs ++ // ++ ++ // single byte longs ++ ++ public long replyLong_0() ++ { ++ return 0; ++ } ++ ++ public long replyLong_1() ++ { ++ return 1; ++ } ++ ++ public long replyLong_15() ++ { ++ return 15; ++ } ++ ++ public long replyLong_m8() ++ { ++ return -8; ++ } ++ ++ // two byte longs ++ ++ public long replyLong_0x10() ++ { ++ return 0x10; ++ } ++ ++ public long replyLong_0x7ff() ++ { ++ return 0x7ff; ++ } ++ ++ public long replyLong_m9() ++ { ++ return -9; ++ } ++ ++ public long replyLong_m0x800() ++ { ++ return -0x800; ++ } ++ ++ // three byte longs ++ ++ public long replyLong_0x800() ++ { ++ return 0x800; ++ } ++ ++ public long replyLong_0x3ffff() ++ { ++ return 0x3ffff; ++ } ++ ++ public long replyLong_m0x801() ++ { ++ return -0x801; ++ } ++ ++ public long replyLong_m0x40000() ++ { ++ return - 0x40000; ++ } ++ ++ // 5 byte longs ++ ++ public long replyLong_0x40000() ++ { ++ return 0x40000; ++ } ++ ++ public long replyLong_0x7fffffff() ++ { ++ return 0x7fffffff; ++ } ++ ++ public long replyLong_m0x40001() ++ { ++ return - 0x40001; ++ } ++ ++ public long replyLong_m0x80000000() ++ { ++ return - 0x80000000; ++ } ++ ++ public long replyLong_0x80000000() ++ { ++ return 0x80000000L; ++ } ++ ++ public long replyLong_m0x80000001() ++ { ++ return - 0x80000001L; ++ } ++ ++ // ++ // doubles ++ // ++ ++ public double replyDouble_0_0() ++ { ++ return 0; ++ } ++ ++ public double replyDouble_1_0() ++ { ++ return 1; ++ } ++ ++ public double replyDouble_2_0() ++ { ++ return 2; ++ } ++ ++ public double replyDouble_127_0() ++ { ++ return 127; ++ } ++ ++ public double replyDouble_m128_0() ++ { ++ return -128; ++ } ++ ++ public double replyDouble_128_0() ++ { ++ return 128; ++ } ++ ++ public double replyDouble_m129_0() ++ { ++ return -129; ++ } ++ ++ public double replyDouble_32767_0() ++ { ++ return 32767; ++ } ++ ++ public double replyDouble_m32768_0() ++ { ++ return -32768; ++ } ++ ++ public double replyDouble_0_001() ++ { ++ return 0.001; ++ } ++ ++ public double replyDouble_m0_001() ++ { ++ return - 0.001; ++ } ++ ++ public double replyDouble_65_536() ++ { ++ return 65.536; ++ } ++ ++ public double replyDouble_3_14159() ++ { ++ return 3.14159; ++ } ++ ++ // date ++ ++ public Object replyDate_0() ++ { ++ return new Date(0); ++ } ++ ++ public Object replyDate_1() ++ { ++ long time = 894621091000L; ++ ++ return new Date(time); ++ } ++ ++ public Object replyDate_2() ++ { ++ long time = 894621091000L; ++ ++ time -= time % 60000L; ++ ++ return new Date(time); ++ } ++ ++ // strings by length ++ ++ public String replyString_0() ++ { ++ return ""; ++ } ++ ++ public String replyString_null() ++ { ++ return null; ++ } ++ ++ public String replyString_1() ++ { ++ return "0"; ++ } ++ ++ public String replyString_31() ++ { ++ return "0123456789012345678901234567890"; ++ } ++ ++ public String replyString_32() ++ { ++ return "01234567890123456789012345678901"; ++ } ++ ++ public String replyString_1023() ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ for (int i = 0; i < 16; i++) { ++ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); ++ } ++ ++ sb.setLength(1023); ++ ++ return sb.toString(); ++ } ++ ++ public String replyString_1024() ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ for (int i = 0; i < 16; i++) { ++ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); ++ } ++ ++ sb.setLength(1024); ++ ++ return sb.toString(); ++ } ++ ++ public String replyString_65536() ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ for (int i = 0; i < 64 * 16; i++) { ++ sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); ++ } ++ ++ sb.setLength(65536); ++ ++ return sb.toString(); ++ } ++ ++ // binarys by length ++ ++ public Object replyBinary_0() ++ { ++ return new byte[0]; ++ } ++ ++ public Object replyBinary_null() ++ { ++ return null; ++ } ++ ++ public Object replyBinary_1() ++ { ++ return toBinary("0"); ++ } ++ ++ public Object replyBinary_15() ++ { ++ return toBinary("012345678901234"); ++ } ++ ++ public Object replyBinary_16() ++ { ++ return toBinary("0123456789012345"); ++ } ++ ++ public Object replyBinary_1023() ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ for (int i = 0; i < 16; i++) { ++ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); ++ } ++ ++ sb.setLength(1023); ++ ++ return toBinary(sb.toString()); ++ } ++ ++ public Object replyBinary_1024() ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ for (int i = 0; i < 16; i++) { ++ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); ++ } ++ ++ sb.setLength(1024); ++ ++ return toBinary(sb.toString()); ++ } ++ ++ public Object replyBinary_65536() ++ { ++ StringBuilder sb = new StringBuilder(); ++ ++ for (int i = 0; i < 64 * 16; i++) { ++ sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); ++ } ++ ++ sb.setLength(65536); ++ ++ return toBinary(sb.toString()); ++ } ++ ++ private byte []toBinary(String s) ++ { ++ byte []buffer = new byte[s.length()]; ++ ++ for (int i = 0; i < s.length(); i++) ++ buffer[i] = (byte) s.charAt(i); ++ ++ return buffer; ++ } ++ ++ // ++ // lists ++ // ++ ++ public Object replyUntypedFixedList_0() ++ { ++ ArrayList list = new ArrayList(); ++ ++ return list; ++ } ++ ++ public Object replyUntypedFixedList_1() ++ { ++ ArrayList list = new ArrayList(); ++ ++ list.add("1"); ++ ++ return list; ++ } ++ ++ public Object replyUntypedFixedList_7() ++ { ++ ArrayList list = new ArrayList(); ++ ++ list.add("1"); ++ list.add("2"); ++ list.add("3"); ++ list.add("4"); ++ list.add("5"); ++ list.add("6"); ++ list.add("7"); ++ ++ return list; ++ } ++ ++ public Object replyUntypedFixedList_8() ++ { ++ ArrayList list = new ArrayList(); ++ ++ list.add("1"); ++ list.add("2"); ++ list.add("3"); ++ list.add("4"); ++ list.add("5"); ++ list.add("6"); ++ list.add("7"); ++ list.add("8"); ++ ++ return list; ++ } ++ ++ public Object replyTypedFixedList_0() ++ { ++ return new String[] {}; ++ } ++ ++ public Object replyTypedFixedList_1() ++ { ++ return new String[] { "1" }; ++ } ++ ++ public Object replyTypedFixedList_7() ++ { ++ return new String[] { "1", "2", "3", "4", "5", "6", "7" }; ++ } ++ ++ public Object replyTypedFixedList_8() ++ { ++ return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }; ++ } ++ ++ // untyped map ++ ++ public Object replyUntypedMap_0() ++ { ++ return new HashMap(); ++ } ++ ++ public Object replyUntypedMap_1() ++ { ++ HashMap map = new HashMap(); ++ map.put("a", 0); ++ ++ return map; ++ } ++ ++ public Object replyUntypedMap_2() ++ { ++ HashMap map = new HashMap(); ++ ++ map.put(0, "a"); ++ map.put(1, "b"); ++ ++ return map; ++ } ++ ++ public Object replyUntypedMap_3() ++ { ++ HashMap map = new HashMap(); ++ ++ ArrayList list = new ArrayList(); ++ list.add("a"); ++ ++ map.put(list, 0); ++ ++ return map; ++ } ++ ++ // typed map ++ ++ public Object replyTypedMap_0() ++ { ++ Hashtable map = new Hashtable(); ++ ++ return map; ++ } ++ ++ public Object replyTypedMap_1() ++ { ++ Map map = new Hashtable(); ++ ++ map.put("a", 0); ++ ++ return map; ++ } ++ ++ public Object replyTypedMap_2() ++ { ++ Map map = new Hashtable(); ++ ++ map.put(0, "a"); ++ map.put(1, "b"); ++ ++ return map; ++ } ++ ++ public Object replyTypedMap_3() ++ { ++ Map map = new Hashtable(); ++ ++ ArrayList list = new ArrayList(); ++ list.add("a"); ++ ++ map.put(list, 0); ++ ++ return map; ++ } ++ ++ // ++ // objects ++ // ++ ++ public Object replyObject_0() ++ { ++ return new A0(); ++ } ++ ++ public Object replyObject_16() ++ { ++ ArrayList list = new ArrayList(); ++ ++ list.add(new A0()); ++ list.add(new A1()); ++ list.add(new A2()); ++ list.add(new A3()); ++ list.add(new A4()); ++ list.add(new A5()); ++ list.add(new A6()); ++ list.add(new A7()); ++ list.add(new A8()); ++ list.add(new A9()); ++ list.add(new A10()); ++ list.add(new A11()); ++ list.add(new A12()); ++ list.add(new A13()); ++ list.add(new A14()); ++ list.add(new A15()); ++ list.add(new A16()); ++ ++ return list; ++ } ++ ++ public Object replyObject_1() ++ { ++ return new TestObject(0); ++ } ++ ++ public Object replyObject_2() ++ { ++ ArrayList list = new ArrayList(); ++ ++ list.add(new TestObject(0)); ++ list.add(new TestObject(1)); ++ ++ return list; ++ } ++ ++ public Object replyObject_2a() ++ { ++ ArrayList list = new ArrayList(); ++ ++ TestObject obj = new TestObject(0); ++ ++ list.add(obj); ++ list.add(obj); ++ ++ return list; ++ } ++ ++ public Object replyObject_2b() ++ { ++ ArrayList list = new ArrayList(); ++ ++ list.add(new TestObject(0)); ++ list.add(new TestObject(0)); ++ ++ return list; ++ } ++ ++ public Object replyObject_3() ++ { ++ TestCons cons = new TestCons(); ++ ++ cons.setFirst("a"); ++ cons.setRest(cons); ++ ++ return cons; ++ } ++ ++ // ++ // arguments ++ // ++ ++ public Object argNull(Object v) ++ { ++ if (v == null) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTrue(Object v) ++ { ++ if (Boolean.TRUE.equals(v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argFalse(Object v) ++ { ++ if (Boolean.FALSE.equals(v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ // integers ++ ++ public Object argInt_0(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 0) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_1(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 1) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_47(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 47) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_m16(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == -16) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ // two byte integers ++ ++ public Object argInt_0x30(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 0x30) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_0x7ff(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 0x7ff) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_m17(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == -17) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_m0x800(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == -0x800) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_0x800(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 0x800) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_0x3ffff(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 0x3ffff) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_m0x801(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == -0x801) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_m0x40000(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == -0x40000) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ // 5 byte integers ++ ++ public Object argInt_0x40000(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 0x40000) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_0x7fffffff(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == 0x7fffffff) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_m0x40001(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == -0x40001) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argInt_m0x80000000(Object v) ++ { ++ if (v instanceof Integer) { ++ Integer value = (Integer) v; ++ ++ if (value == -0x80000000) ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // longs ++ // ++ ++ public Object argLong_0(Object v) ++ { ++ if (v.equals(replyLong_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_1(Object v) ++ { ++ if (v.equals(replyLong_1())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_15(Object v) ++ { ++ if (v.equals(replyLong_15())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m8(Object v) ++ { ++ if (v.equals(replyLong_m8())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ // two byte longs ++ ++ public Object argLong_0x10(Object v) ++ { ++ if (v.equals(replyLong_0x10())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_0x7ff(Object v) ++ { ++ if (v.equals(replyLong_0x7ff())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m9(Object v) ++ { ++ if (v.equals(replyLong_m9())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m0x800(Object v) ++ { ++ if (v.equals(replyLong_m0x800())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_0x800(Object v) ++ { ++ if (v.equals(replyLong_0x800())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_0x3ffff(Object v) ++ { ++ if (v.equals(replyLong_0x3ffff())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m0x801(Object v) ++ { ++ if (v.equals(replyLong_m0x801())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m0x40000(Object v) ++ { ++ if (v.equals(replyLong_m0x40000())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ // 5 byte longs ++ ++ public Object argLong_0x40000(Object v) ++ { ++ if (v.equals(replyLong_0x40000())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_0x7fffffff(Object v) ++ { ++ if (v.equals(replyLong_0x7fffffff())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m0x40001(Object v) ++ { ++ if (v.equals(replyLong_m0x40001())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m0x80000000(Object v) ++ { ++ if (v.equals(replyLong_m0x80000000())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_0x80000000(Object v) ++ { ++ if (v.equals(replyLong_0x80000000())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argLong_m0x80000001(Object v) ++ { ++ if (v.equals(replyLong_m0x80000001())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // doubles ++ // ++ ++ /** ++ * double 0.0 ++ * ++ *
++   * x5b
++   * 
++ */ ++ public Object argDouble_0_0(Object v) ++ { ++ if (v.equals(replyDouble_0_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double 1.0 ++ * ++ *
++   * x5c
++   * 
++ */ ++ public Object argDouble_1_0(Object v) ++ { ++ if (v.equals(replyDouble_1_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double 2.0 ++ * ++ *
++   * x5d x02
++   * 
++ */ ++ public Object argDouble_2_0(Object v) ++ { ++ if (v.equals(replyDouble_2_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double 127.0 ++ * ++ *
++   * x5d x7f
++   * 
++ */ ++ public Object argDouble_127_0(Object v) ++ { ++ if (v.equals(replyDouble_127_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double -128.0 ++ * ++ *
++   * x5d x80
++   * 
++ */ ++ public Object argDouble_m128_0(Object v) ++ { ++ if (v.equals(replyDouble_m128_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double 128.0 ++ * ++ *
++   * x5e x00 x80
++   * 
++ */ ++ public Object argDouble_128_0(Object v) ++ { ++ if (v.equals(replyDouble_128_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double -129.0 ++ * ++ *
++   * x5e xff x7f
++   * 
++ */ ++ public Object argDouble_m129_0(Object v) ++ { ++ if (v.equals(replyDouble_m129_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double 32767.0 ++ * ++ *
++   * x5e x7f xff
++   * 
++ */ ++ public Object argDouble_32767_0(Object v) ++ { ++ if (v.equals(replyDouble_32767_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * Double -32768.0 ++ * ++ *
++   * x5e x80 x80
++   * 
++ */ ++ public Object argDouble_m32768_0(Object v) ++ { ++ if (v.equals(replyDouble_m32768_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double 0.001 ++ * ++ *
++   * x5f x00 x00 x00 x01
++   * 
++ */ ++ public Object argDouble_0_001(Object v) ++ { ++ if (v.equals(replyDouble_0_001())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double -0.001 ++ * ++ *
++   * x5f xff xff xff xff
++   * 
++ */ ++ public Object argDouble_m0_001(Object v) ++ { ++ if (v.equals(replyDouble_m0_001())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * double 65.536 ++ * ++ *
++   * x5f x00 x01 x00 x00
++   * 
++ */ ++ public Object argDouble_65_536(Object v) ++ { ++ if (v.equals(replyDouble_65_536())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ /** ++ * Result of double 3.14159 ++ * ++ *
++   * D x00 x01 x00 x00 x00 x00 x00 x00
++   * 
++ */ ++ public Object argDouble_3_14159(Object v) ++ { ++ if (v.equals(replyDouble_3_14159())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // date ++ // ++ ++ public Object argDate_0(Object v) ++ { ++ if (v.equals(replyDate_0())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argDate_1(Object v) ++ { ++ if (v.equals(replyDate_1())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argDate_2(Object v) ++ { ++ if (v.equals(replyDate_2())) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // string length ++ // ++ ++ public Object argString_0(Object v) ++ { ++ String expect = ""; ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argString_1(Object v) ++ { ++ String expect = "0"; ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argString_31(Object v) ++ { ++ String expect = "0123456789012345678901234567890"; ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argString_32(Object v) ++ { ++ String expect = "01234567890123456789012345678901"; ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argString_1023(Object v) ++ { ++ String expect = replyString_1023(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argString_1024(Object v) ++ { ++ String expect = replyString_1024(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argString_65536(Object v) ++ { ++ String expect = replyString_65536(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // binary length ++ // ++ ++ public Object argBinary_0(Object v) ++ { ++ byte []expect = (byte []) replyBinary_0(); ++ ++ if (equals(expect, v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argBinary_1(Object v) ++ { ++ byte []expect = (byte []) replyBinary_1(); ++ ++ if (equals(expect, v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argBinary_15(Object v) ++ { ++ byte []expect = (byte []) replyBinary_15(); ++ ++ if (equals(expect, v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argBinary_16(Object v) ++ { ++ byte []expect = (byte []) replyBinary_16(); ++ ++ if (equals(expect, v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argBinary_1023(Object v) ++ { ++ byte []expect = (byte []) replyBinary_1023(); ++ ++ if (equals(expect, v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argBinary_1024(Object v) ++ { ++ byte []expect = (byte []) replyBinary_1024(); ++ ++ if (equals(expect, v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ public Object argBinary_65536(Object v) ++ { ++ byte []expect = (byte []) replyBinary_65536(); ++ ++ if (equals(expect, v)) ++ return true; ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // lists ++ // ++ ++ public Object argUntypedFixedList_0(Object v) ++ { ++ Object expect = replyUntypedFixedList_0(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argUntypedFixedList_1(Object v) ++ { ++ Object expect = replyUntypedFixedList_1(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argUntypedFixedList_7(Object v) ++ { ++ Object expect = replyUntypedFixedList_7(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argUntypedFixedList_8(Object v) ++ { ++ Object expect = replyUntypedFixedList_8(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTypedFixedList_0(Object v) ++ { ++ String []expect = (String []) replyTypedFixedList_0(); ++ ++ if (v instanceof String[] && equals(expect, (String []) v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTypedFixedList_1(Object v) ++ { ++ String []expect = (String []) replyTypedFixedList_1(); ++ ++ if (v instanceof String[] && equals(expect, (String []) v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTypedFixedList_7(Object v) ++ { ++ String []expect = (String []) replyTypedFixedList_7(); ++ ++ if (v instanceof String[] && equals(expect, (String []) v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTypedFixedList_8(Object v) ++ { ++ String []expect = (String []) replyTypedFixedList_8(); ++ ++ if (v instanceof String[] && equals(expect, (String []) v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // untyped maps ++ // ++ ++ public Object argUntypedMap_0(Object v) ++ { ++ Object expect = replyUntypedMap_0(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argUntypedMap_1(Object v) ++ { ++ Object expect = replyUntypedMap_1(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argUntypedMap_2(Object v) ++ { ++ Object expect = replyUntypedMap_2(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argUntypedMap_3(Object v) ++ { ++ Object expect = replyUntypedMap_3(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // typed maps ++ // ++ ++ public Object argTypedMap_0(Object v) ++ { ++ Object expect = replyTypedMap_0(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTypedMap_1(Object v) ++ { ++ Object expect = replyTypedMap_1(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTypedMap_2(Object v) ++ { ++ Object expect = replyTypedMap_2(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argTypedMap_3(Object v) ++ { ++ Object expect = replyTypedMap_3(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ // ++ // objects ++ // ++ ++ public Object argObject_0(Object v) ++ { ++ Object expect = replyObject_0(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argObject_16(Object v) ++ { ++ Object expect = replyObject_16(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argObject_1(Object v) ++ { ++ Object expect = replyObject_1(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argObject_2(Object v) ++ { ++ Object expect = replyObject_2(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argObject_2a(Object v) ++ { ++ Object expect = replyObject_2a(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argObject_2b(Object v) ++ { ++ Object expect = replyObject_2b(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ public Object argObject_3(Object v) ++ { ++ Object expect = replyObject_3(); ++ ++ if (expect.equals(v)) { ++ return true; ++ } ++ ++ return getInputDebug(); ++ } ++ ++ private boolean equals(String []a, String []b) ++ { ++ if (a == null || b == null) ++ return false; ++ ++ if (a.length != b.length) ++ return false; ++ ++ for (int i = 0; i < a.length; i++) { ++ if (! a[i].equals(b[i])) ++ return false; ++ } ++ ++ return true; ++ } ++ ++ private boolean equals(byte []a, Object obj) ++ { ++ if (! (obj instanceof byte[])) ++ return false; ++ ++ byte []b = (byte []) obj; ++ ++ if (a == null || b == null) ++ return false; ++ ++ if (a.length != b.length) ++ return false; ++ ++ for (int i = 0; i < a.length; i++) { ++ if (a[i] != b[i]) { ++ return false; ++ } ++ } ++ ++ return true; ++ } ++ ++ protected String getInputDebug() ++ { ++ CharArrayWriter writer = _threadWriter.get(); ++ if (writer != null) ++ return writer.toString(); ++ else ++ return null; ++ } ++ ++ /** ++ * Invoke the object with the request from the input stream. ++ * ++ * @param in the Hessian input stream ++ * @param out the Hessian output stream ++ */ ++ @Override ++ public void invoke(InputStream is, OutputStream os, String objectId, ++ SerializerFactory serializerFactory) ++ throws Exception ++ { ++ CharArrayWriter writer = new CharArrayWriter(); ++ ++ _threadWriter.set(writer); ++ ++ PrintWriter dbg = new PrintWriter(writer); ++ ++ HessianDebugInputStream debug = new HessianDebugInputStream(is, dbg); ++ debug.startTop2(); ++ ++ super.invoke(debug, os, objectId, serializerFactory); ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestHessianServlet.java hessian-4.0.65-fix/com/caucho/hessian/test/TestHessianServlet.java +--- hessian-4.0.65-src/com/caucho/hessian/test/TestHessianServlet.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/test/TestHessianServlet.java 2023-08-15 18:39:22.000000000 +0800 +@@ -1,64 +1,64 @@ +-package com.caucho.hessian.test; +- +-import com.caucho.hessian.io.*; +-import com.caucho.hessian.server.HessianServlet; +-import java.io.*; +-import java.util.*; +- +-/** +- * The test service is a Hessian 2.0 protocol test for developers of +- * Hessian 2.0 clients. For a new client the recommended order is: +- * +- *
    +- *
  • methodNull +- *
  • methodHello +- *
+- */ +-public class TestHessianServlet +- extends HessianServlet +- implements Test +-{ +- private ThreadLocal _threadWriter +- = new ThreadLocal(); +- +- /** +- * Does nothing. +- */ +- public void nullCall() +- { +- } +- +- /** +- * Hello, World. +- */ +- public String hello() +- { +- return "Hello, World"; +- } +- +- /** +- * Subtraction +- */ +- public int subtract(int a, int b) +- { +- return a - b; +- } +- +- /** +- * Echos the object to the server. +- *
+-   */
+-  public Object echo(Object value)
+-  {
+-    return value;
+-  }
+-  
+-  /**
+-   * Throws an application fault.
+-   */
+-  public void fault()
+-    throws IOException
+-  {
+-    throw new NullPointerException("sample exception");
+-  }
+-}
++package com.caucho.hessian.test;
++
++import com.caucho.hessian.io.*;
++import com.caucho.hessian.server.HessianServlet;
++import java.io.*;
++import java.util.*;
++
++/**
++ * The test service is a Hessian 2.0 protocol test for developers of
++ * Hessian 2.0 clients.  For a new client the recommended order is:
++ *
++ * 
    ++ *
  • methodNull ++ *
  • methodHello ++ *
++ */ ++public class TestHessianServlet ++ extends HessianServlet ++ implements Test ++{ ++ private ThreadLocal _threadWriter ++ = new ThreadLocal(); ++ ++ /** ++ * Does nothing. ++ */ ++ public void nullCall() ++ { ++ } ++ ++ /** ++ * Hello, World. ++ */ ++ public String hello() ++ { ++ return "Hello, World"; ++ } ++ ++ /** ++ * Subtraction ++ */ ++ public int subtract(int a, int b) ++ { ++ return a - b; ++ } ++ ++ /** ++ * Echos the object to the server. ++ *
++   */
++  public Object echo(Object value)
++  {
++    return value;
++  }
++  
++  /**
++   * Throws an application fault.
++   */
++  public void fault()
++    throws IOException
++  {
++    throw new NullPointerException("sample exception");
++  }
++}
+diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestObject.java hessian-4.0.65-fix/com/caucho/hessian/test/TestObject.java
+--- hessian-4.0.65-src/com/caucho/hessian/test/TestObject.java	2020-07-23 12:51:28.000000000 +0800
++++ hessian-4.0.65-fix/com/caucho/hessian/test/TestObject.java	2023-08-15 18:39:22.000000000 +0800
+@@ -1,50 +1,50 @@
+-package com.caucho.hessian.test;
+-
+-import java.io.IOException;
+-
+-/**
+- * Empty object for short-encoding testing
+- */
+-public class TestObject implements java.io.Serializable {
+-  private Object _value;
+-
+-  public TestObject()
+-  {
+-  }
+-
+-  public TestObject(Object value)
+-  {
+-    _value = value;
+-  }
+-
+-  public Object getValue()
+-  {
+-    return _value;
+-  }
+-
+-  public int hashCode()
+-  {
+-    if (_value != null)
+-      return _value.hashCode();
+-    else
+-      return 0;
+-  }
+-
+-  public boolean equals(Object o)
+-  {
+-    if (! (o instanceof TestObject))
+-      return false;
+-
+-    TestObject obj = (TestObject) o;
+-
+-    if (_value != null)
+-      return _value.equals(obj._value);
+-    else
+-      return _value == obj._value;
+-  }
+-  
+-  public String toString()
+-  {
+-    return getClass().getName() + "[" + _value + "]";
+-  }
+-}
++package com.caucho.hessian.test;
++
++import java.io.IOException;
++
++/**
++ * Empty object for short-encoding testing
++ */
++public class TestObject implements java.io.Serializable {
++  private Object _value;
++
++  public TestObject()
++  {
++  }
++
++  public TestObject(Object value)
++  {
++    _value = value;
++  }
++
++  public Object getValue()
++  {
++    return _value;
++  }
++
++  public int hashCode()
++  {
++    if (_value != null)
++      return _value.hashCode();
++    else
++      return 0;
++  }
++
++  public boolean equals(Object o)
++  {
++    if (! (o instanceof TestObject))
++      return false;
++
++    TestObject obj = (TestObject) o;
++
++    if (_value != null)
++      return _value.equals(obj._value);
++    else
++      return _value == obj._value;
++  }
++  
++  public String toString()
++  {
++    return getClass().getName() + "[" + _value + "]";
++  }
++}
+diff -uNr hessian-4.0.65-src/com/caucho/hessian/util/HessianFreeList.java hessian-4.0.65-fix/com/caucho/hessian/util/HessianFreeList.java
+--- hessian-4.0.65-src/com/caucho/hessian/util/HessianFreeList.java	2020-07-23 12:51:28.000000000 +0800
++++ hessian-4.0.65-fix/com/caucho/hessian/util/HessianFreeList.java	2023-08-15 18:39:22.000000000 +0800
+@@ -1,145 +1,145 @@
+-/*
+- * Copyright (c) 2001-2008 Caucho Technology, Inc.  All rights reserved.
+- *
+- * The Apache Software License, Version 1.1
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- *
+- * 1. Redistributions of source code must retain the above copyright
+- *    notice, this list of conditions and the following disclaimer.
+- *
+- * 2. Redistributions in binary form must reproduce the above copyright
+- *    notice, this list of conditions and the following disclaimer in
+- *    the documentation and/or other materials provided with the
+- *    distribution.
+- *
+- * 3. The end-user documentation included with the redistribution, if
+- *    any, must include the following acknowlegement:
+- *       "This product includes software developed by the
+- *        Caucho Technology (http://www.caucho.com/)."
+- *    Alternately, this acknowlegement may appear in the software itself,
+- *    if and wherever such third-party acknowlegements normally appear.
+- *
+- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to
+- *    endorse or promote products derived from this software without prior
+- *    written permission. For written permission, please contact
+- *    info@caucho.com.
+- *
+- * 5. Products derived from this software may not be called "Resin"
+- *    nor may "Resin" appear in their names without prior written
+- *    permission of Caucho Technology.
+- *
+- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+- * DISCLAIMED.  IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
+- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- *
+- * @author Scott Ferguson
+- */
+-
+-package com.caucho.hessian.util;
+-
+-import java.util.concurrent.atomic.AtomicInteger;
+-import java.util.concurrent.atomic.AtomicReferenceArray;
+-
+-/**
+- * FreeList provides a simple class to manage free objects.  This is useful
+- * for large data structures that otherwise would gobble up huge GC time.
+- *
+- * 

The free list is bounded. Freeing an object when the list is full will +- * do nothing. +- */ +-public final class HessianFreeList { +- private final AtomicReferenceArray _freeStack; +- private final AtomicInteger _top = new AtomicInteger(); +- +- /** +- * Create a new free list. +- * +- * @param initialSize maximum number of free objects to store. +- */ +- public HessianFreeList(int size) +- { +- _freeStack = new AtomicReferenceArray(size); +- } +- +- /** +- * Try to get an object from the free list. Returns null if the free list +- * is empty. +- * +- * @return the new object or null. +- */ +- public T allocate() +- { +- int top = _top.get(); +- +- if (top > 0 && _top.compareAndSet(top, top - 1)) +- return _freeStack.getAndSet(top - 1, null); +- else +- return null; +- } +- +- /** +- * Frees the object. If the free list is full, the object will be garbage +- * collected. +- * +- * @param obj the object to be freed. +- */ +- public boolean free(T obj) +- { +- int top = _top.get(); +- +- if (top < _freeStack.length()) { +- boolean isFree = _freeStack.compareAndSet(top, null, obj); +- +- _top.compareAndSet(top, top + 1); +- +- return isFree; +- } +- else +- return false; +- } +- +- public boolean allowFree(T obj) +- { +- return _top.get() < _freeStack.length(); +- } +- +- /** +- * Frees the object. If the free list is full, the object will be garbage +- * collected. +- * +- * @param obj the object to be freed. +- */ +- public void freeCareful(T obj) +- { +- if (checkDuplicate(obj)) +- throw new IllegalStateException("tried to free object twice: " + obj); +- +- free(obj); +- } +- +- /** +- * Debugging to see if the object has already been freed. +- */ +- public boolean checkDuplicate(T obj) +- { +- int top = _top.get(); +- +- for (int i = top - 1; i >= 0; i--) { +- if (_freeStack.get(i) == obj) +- return true; +- } +- +- return false; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.util; ++ ++import java.util.concurrent.atomic.AtomicInteger; ++import java.util.concurrent.atomic.AtomicReferenceArray; ++ ++/** ++ * FreeList provides a simple class to manage free objects. This is useful ++ * for large data structures that otherwise would gobble up huge GC time. ++ * ++ *

The free list is bounded. Freeing an object when the list is full will ++ * do nothing. ++ */ ++public final class HessianFreeList { ++ private final AtomicReferenceArray _freeStack; ++ private final AtomicInteger _top = new AtomicInteger(); ++ ++ /** ++ * Create a new free list. ++ * ++ * @param initialSize maximum number of free objects to store. ++ */ ++ public HessianFreeList(int size) ++ { ++ _freeStack = new AtomicReferenceArray(size); ++ } ++ ++ /** ++ * Try to get an object from the free list. Returns null if the free list ++ * is empty. ++ * ++ * @return the new object or null. ++ */ ++ public T allocate() ++ { ++ int top = _top.get(); ++ ++ if (top > 0 && _top.compareAndSet(top, top - 1)) ++ return _freeStack.getAndSet(top - 1, null); ++ else ++ return null; ++ } ++ ++ /** ++ * Frees the object. If the free list is full, the object will be garbage ++ * collected. ++ * ++ * @param obj the object to be freed. ++ */ ++ public boolean free(T obj) ++ { ++ int top = _top.get(); ++ ++ if (top < _freeStack.length()) { ++ boolean isFree = _freeStack.compareAndSet(top, null, obj); ++ ++ _top.compareAndSet(top, top + 1); ++ ++ return isFree; ++ } ++ else ++ return false; ++ } ++ ++ public boolean allowFree(T obj) ++ { ++ return _top.get() < _freeStack.length(); ++ } ++ ++ /** ++ * Frees the object. If the free list is full, the object will be garbage ++ * collected. ++ * ++ * @param obj the object to be freed. ++ */ ++ public void freeCareful(T obj) ++ { ++ if (checkDuplicate(obj)) ++ throw new IllegalStateException("tried to free object twice: " + obj); ++ ++ free(obj); ++ } ++ ++ /** ++ * Debugging to see if the object has already been freed. ++ */ ++ public boolean checkDuplicate(T obj) ++ { ++ int top = _top.get(); ++ ++ for (int i = top - 1; i >= 0; i--) { ++ if (_freeStack.get(i) == obj) ++ return true; ++ } ++ ++ return false; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/util/IdentityIntMap.java hessian-4.0.65-fix/com/caucho/hessian/util/IdentityIntMap.java +--- hessian-4.0.65-src/com/caucho/hessian/util/IdentityIntMap.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/util/IdentityIntMap.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,276 +1,276 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.util; +- +-/** +- * The IntMap provides a simple hashmap from keys to integers. The API is +- * an abbreviation of the HashMap collection API. +- * +- *

The convenience of IntMap is avoiding all the silly wrapping of +- * integers. +- */ +-public class IdentityIntMap { +- /** +- * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, +- * it's impossible to distinguish between the two. +- */ +- public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; +- +- private Object []_keys; +- private int []_values; +- +- private int _size; +- private int _prime; +- +- /** +- * Create a new IntMap. Default size is 16. +- */ +- public IdentityIntMap(int capacity) +- { +- _keys = new Object[capacity]; +- _values = new int[capacity]; +- +- _prime = getBiggestPrime(_keys.length); +- _size = 0; +- } +- +- /** +- * Clear the hashmap. +- */ +- public void clear() +- { +- final Object []keys = _keys; +- final int []values = _values; +- +- for (int i = keys.length - 1; i >= 0; i--) { +- keys[i] = null; +- values[i] = 0; +- } +- +- _size = 0; +- } +- /** +- * Returns the current number of entries in the map. +- */ +- public final int size() +- { +- return _size; +- } +- +- /** +- * Puts a new value in the property table with the appropriate flags +- */ +- public final int get(Object key) +- { +- int prime = _prime; +- int hash = System.identityHashCode(key) % prime; +- // int hash = key.hashCode() & mask; +- +- final Object []keys = _keys; +- +- while (true) { +- Object mapKey = keys[hash]; +- +- if (mapKey == null) +- return NULL; +- else if (mapKey == key) +- return _values[hash]; +- +- hash = (hash + 1) % prime; +- } +- } +- +- /** +- * Puts a new value in the property table with the appropriate flags +- */ +- public final int put(Object key, int value, boolean isReplace) +- { +- int prime = _prime; +- int hash = Math.abs(System.identityHashCode(key) % prime); +- // int hash = key.hashCode() % prime; +- +- Object []keys = _keys; +- +- while (true) { +- Object testKey = keys[hash]; +- +- if (testKey == null) { +- keys[hash] = key; +- _values[hash] = value; +- +- _size++; +- +- if (keys.length <= 4 * _size) +- resize(4 * keys.length); +- +- return value; +- } +- else if (key != testKey) { +- hash = (hash + 1) % prime; +- +- continue; +- } +- else if (isReplace){ +- int old = _values[hash]; +- +- _values[hash] = value; +- +- return old; +- } +- else { +- return _values[hash]; +- } +- } +- } +- +- /** +- * Removes a value in the property table. +- */ +- public final void remove(Object key) +- { +- if (put(key, NULL, true) != NULL) { +- _size--; +- } +- } +- +- /** +- * Expands the property table +- */ +- private void resize(int newSize) +- { +- Object []keys = _keys; +- int values[] = _values; +- +- _keys = new Object[newSize]; +- _values = new int[newSize]; +- _size = 0; +- +- _prime = getBiggestPrime(_keys.length); +- +- for (int i = keys.length - 1; i >= 0; i--) { +- Object key = keys[i]; +- int value = values[i]; +- +- if (key != null && value != NULL) { +- put(key, value, true); +- } +- } +- } +- +- protected int hashCode(Object value) +- { +- return System.identityHashCode(value); +- } +- +- public String toString() +- { +- StringBuffer sbuf = new StringBuffer(); +- +- sbuf.append("IntMap["); +- boolean isFirst = true; +- +- for (int i = 0; i <= _keys.length; i++) { +- if (_keys[i] != null) { +- if (! isFirst) +- sbuf.append(", "); +- +- isFirst = false; +- sbuf.append(_keys[i]); +- sbuf.append(":"); +- sbuf.append(_values[i]); +- } +- } +- sbuf.append("]"); +- +- return sbuf.toString(); +- } +- +- public static final int []PRIMES = +- { +- 1, /* 1<< 0 = 1 */ +- 2, /* 1<< 1 = 2 */ +- 3, /* 1<< 2 = 4 */ +- 7, /* 1<< 3 = 8 */ +- 13, /* 1<< 4 = 16 */ +- 31, /* 1<< 5 = 32 */ +- 61, /* 1<< 6 = 64 */ +- 127, /* 1<< 7 = 128 */ +- 251, /* 1<< 8 = 256 */ +- 509, /* 1<< 9 = 512 */ +- 1021, /* 1<<10 = 1024 */ +- 2039, /* 1<<11 = 2048 */ +- 4093, /* 1<<12 = 4096 */ +- 8191, /* 1<<13 = 8192 */ +- 16381, /* 1<<14 = 16384 */ +- 32749, /* 1<<15 = 32768 */ +- 65521, /* 1<<16 = 65536 */ +- 131071, /* 1<<17 = 131072 */ +- 262139, /* 1<<18 = 262144 */ +- 524287, /* 1<<19 = 524288 */ +- 1048573, /* 1<<20 = 1048576 */ +- 2097143, /* 1<<21 = 2097152 */ +- 4194301, /* 1<<22 = 4194304 */ +- 8388593, /* 1<<23 = 8388608 */ +- 16777213, /* 1<<24 = 16777216 */ +- 33554393, /* 1<<25 = 33554432 */ +- 67108859, /* 1<<26 = 67108864 */ +- 134217689, /* 1<<27 = 134217728 */ +- 268435399, /* 1<<28 = 268435456 */ +- }; +- +- public static int getBiggestPrime(int value) +- { +- for (int i = PRIMES.length - 1; i >= 0; i--) { +- if (PRIMES[i] <= value) +- return PRIMES[i]; +- } +- +- return 2; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.util; ++ ++/** ++ * The IntMap provides a simple hashmap from keys to integers. The API is ++ * an abbreviation of the HashMap collection API. ++ * ++ *

The convenience of IntMap is avoiding all the silly wrapping of ++ * integers. ++ */ ++public class IdentityIntMap { ++ /** ++ * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, ++ * it's impossible to distinguish between the two. ++ */ ++ public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; ++ ++ private Object []_keys; ++ private int []_values; ++ ++ private int _size; ++ private int _prime; ++ ++ /** ++ * Create a new IntMap. Default size is 16. ++ */ ++ public IdentityIntMap(int capacity) ++ { ++ _keys = new Object[capacity]; ++ _values = new int[capacity]; ++ ++ _prime = getBiggestPrime(_keys.length); ++ _size = 0; ++ } ++ ++ /** ++ * Clear the hashmap. ++ */ ++ public void clear() ++ { ++ final Object []keys = _keys; ++ final int []values = _values; ++ ++ for (int i = keys.length - 1; i >= 0; i--) { ++ keys[i] = null; ++ values[i] = 0; ++ } ++ ++ _size = 0; ++ } ++ /** ++ * Returns the current number of entries in the map. ++ */ ++ public final int size() ++ { ++ return _size; ++ } ++ ++ /** ++ * Puts a new value in the property table with the appropriate flags ++ */ ++ public final int get(Object key) ++ { ++ int prime = _prime; ++ int hash = System.identityHashCode(key) % prime; ++ // int hash = key.hashCode() & mask; ++ ++ final Object []keys = _keys; ++ ++ while (true) { ++ Object mapKey = keys[hash]; ++ ++ if (mapKey == null) ++ return NULL; ++ else if (mapKey == key) ++ return _values[hash]; ++ ++ hash = (hash + 1) % prime; ++ } ++ } ++ ++ /** ++ * Puts a new value in the property table with the appropriate flags ++ */ ++ public final int put(Object key, int value, boolean isReplace) ++ { ++ int prime = _prime; ++ int hash = Math.abs(System.identityHashCode(key) % prime); ++ // int hash = key.hashCode() % prime; ++ ++ Object []keys = _keys; ++ ++ while (true) { ++ Object testKey = keys[hash]; ++ ++ if (testKey == null) { ++ keys[hash] = key; ++ _values[hash] = value; ++ ++ _size++; ++ ++ if (keys.length <= 4 * _size) ++ resize(4 * keys.length); ++ ++ return value; ++ } ++ else if (key != testKey) { ++ hash = (hash + 1) % prime; ++ ++ continue; ++ } ++ else if (isReplace){ ++ int old = _values[hash]; ++ ++ _values[hash] = value; ++ ++ return old; ++ } ++ else { ++ return _values[hash]; ++ } ++ } ++ } ++ ++ /** ++ * Removes a value in the property table. ++ */ ++ public final void remove(Object key) ++ { ++ if (put(key, NULL, true) != NULL) { ++ _size--; ++ } ++ } ++ ++ /** ++ * Expands the property table ++ */ ++ private void resize(int newSize) ++ { ++ Object []keys = _keys; ++ int values[] = _values; ++ ++ _keys = new Object[newSize]; ++ _values = new int[newSize]; ++ _size = 0; ++ ++ _prime = getBiggestPrime(_keys.length); ++ ++ for (int i = keys.length - 1; i >= 0; i--) { ++ Object key = keys[i]; ++ int value = values[i]; ++ ++ if (key != null && value != NULL) { ++ put(key, value, true); ++ } ++ } ++ } ++ ++ protected int hashCode(Object value) ++ { ++ return System.identityHashCode(value); ++ } ++ ++ public String toString() ++ { ++ StringBuffer sbuf = new StringBuffer(); ++ ++ sbuf.append("IntMap["); ++ boolean isFirst = true; ++ ++ for (int i = 0; i <= _keys.length; i++) { ++ if (_keys[i] != null) { ++ if (! isFirst) ++ sbuf.append(", "); ++ ++ isFirst = false; ++ sbuf.append(_keys[i]); ++ sbuf.append(":"); ++ sbuf.append(_values[i]); ++ } ++ } ++ sbuf.append("]"); ++ ++ return sbuf.toString(); ++ } ++ ++ public static final int []PRIMES = ++ { ++ 1, /* 1<< 0 = 1 */ ++ 2, /* 1<< 1 = 2 */ ++ 3, /* 1<< 2 = 4 */ ++ 7, /* 1<< 3 = 8 */ ++ 13, /* 1<< 4 = 16 */ ++ 31, /* 1<< 5 = 32 */ ++ 61, /* 1<< 6 = 64 */ ++ 127, /* 1<< 7 = 128 */ ++ 251, /* 1<< 8 = 256 */ ++ 509, /* 1<< 9 = 512 */ ++ 1021, /* 1<<10 = 1024 */ ++ 2039, /* 1<<11 = 2048 */ ++ 4093, /* 1<<12 = 4096 */ ++ 8191, /* 1<<13 = 8192 */ ++ 16381, /* 1<<14 = 16384 */ ++ 32749, /* 1<<15 = 32768 */ ++ 65521, /* 1<<16 = 65536 */ ++ 131071, /* 1<<17 = 131072 */ ++ 262139, /* 1<<18 = 262144 */ ++ 524287, /* 1<<19 = 524288 */ ++ 1048573, /* 1<<20 = 1048576 */ ++ 2097143, /* 1<<21 = 2097152 */ ++ 4194301, /* 1<<22 = 4194304 */ ++ 8388593, /* 1<<23 = 8388608 */ ++ 16777213, /* 1<<24 = 16777216 */ ++ 33554393, /* 1<<25 = 33554432 */ ++ 67108859, /* 1<<26 = 67108864 */ ++ 134217689, /* 1<<27 = 134217728 */ ++ 268435399, /* 1<<28 = 268435456 */ ++ }; ++ ++ public static int getBiggestPrime(int value) ++ { ++ for (int i = PRIMES.length - 1; i >= 0; i--) { ++ if (PRIMES[i] <= value) ++ return PRIMES[i]; ++ } ++ ++ return 2; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/hessian/util/IntMap.java hessian-4.0.65-fix/com/caucho/hessian/util/IntMap.java +--- hessian-4.0.65-src/com/caucho/hessian/util/IntMap.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/util/IntMap.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,267 +1,267 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.hessian.util; +- +-/** +- * The IntMap provides a simple hashmap from keys to integers. The API is +- * an abbreviation of the HashMap collection API. +- * +- *

The convenience of IntMap is avoiding all the silly wrapping of +- * integers. +- */ +-public class IntMap { +- /** +- * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, +- * it's impossible to distinguish between the two. +- */ +- public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; +- +- private Object []_keys; +- private int []_values; +- +- private int _size; +- private int _prime; +- +- /** +- * Create a new IntMap. Default size is 16. +- */ +- public IntMap() +- { +- int capacity = 1024; +- +- _keys = new Object[capacity]; +- _values = new int[capacity]; +- +- _prime = getBiggestPrime(_keys.length); +- _size = 0; +- } +- +- /** +- * Clear the hashmap. +- */ +- public void clear() +- { +- final Object []keys = _keys; +- final int []values = _values; +- +- for (int i = keys.length - 1; i >= 0; i--) { +- keys[i] = null; +- values[i] = 0; +- } +- +- _size = 0; +- } +- /** +- * Returns the current number of entries in the map. +- */ +- public final int size() +- { +- return _size; +- } +- +- /** +- * Puts a new value in the property table with the appropriate flags +- */ +- public final int get(Object key) +- { +- int prime = _prime; +- int hash = hashCode(key) % prime; +- // int hash = key.hashCode() & mask; +- +- final Object []keys = _keys; +- +- while (true) { +- Object mapKey = keys[hash]; +- +- if (mapKey == null) +- return NULL; +- else if (mapKey == key) +- return _values[hash]; +- +- hash = (hash + 1) % prime; +- } +- } +- +- /** +- * Puts a new value in the property table with the appropriate flags +- */ +- public final int put(Object key, int value, boolean isReplace) +- { +- int prime = _prime; +- int hash = hashCode(key) % prime; +- // int hash = key.hashCode() % prime; +- +- Object []keys = _keys; +- +- while (true) { +- Object testKey = keys[hash]; +- +- if (testKey == null) { +- keys[hash] = key; +- _values[hash] = value; +- +- _size++; +- +- if (keys.length <= 4 * _size) +- resize(4 * keys.length); +- +- return NULL; +- } +- else if (key != testKey) { +- hash = (hash + 1) % prime; +- +- continue; +- } +- else if (isReplace){ +- int old = _values[hash]; +- +- _values[hash] = value; +- +- return old; +- } +- else { +- return _values[hash]; +- } +- } +- } +- +- /** +- * Expands the property table +- */ +- private void resize(int newSize) +- { +- Object []keys = _keys; +- int values[] = _values; +- +- _keys = new Object[newSize]; +- _values = new int[newSize]; +- _size = 0; +- +- _prime = getBiggestPrime(_keys.length); +- +- for (int i = keys.length - 1; i >= 0; i--) { +- Object key = keys[i]; +- +- if (key != null) { +- put(key, values[i], true); +- } +- } +- } +- +- protected int hashCode(Object value) +- { +- return value.hashCode(); +- } +- +- public String toString() +- { +- StringBuffer sbuf = new StringBuffer(); +- +- sbuf.append("IntMap["); +- boolean isFirst = true; +- +- for (int i = 0; i <= _keys.length; i++) { +- if (_keys[i] != null) { +- if (! isFirst) +- sbuf.append(", "); +- +- isFirst = false; +- sbuf.append(_keys[i]); +- sbuf.append(":"); +- sbuf.append(_values[i]); +- } +- } +- sbuf.append("]"); +- +- return sbuf.toString(); +- } +- +- public static final int []PRIMES = +- { +- 1, /* 1<< 0 = 1 */ +- 2, /* 1<< 1 = 2 */ +- 3, /* 1<< 2 = 4 */ +- 7, /* 1<< 3 = 8 */ +- 13, /* 1<< 4 = 16 */ +- 31, /* 1<< 5 = 32 */ +- 61, /* 1<< 6 = 64 */ +- 127, /* 1<< 7 = 128 */ +- 251, /* 1<< 8 = 256 */ +- 509, /* 1<< 9 = 512 */ +- 1021, /* 1<<10 = 1024 */ +- 2039, /* 1<<11 = 2048 */ +- 4093, /* 1<<12 = 4096 */ +- 8191, /* 1<<13 = 8192 */ +- 16381, /* 1<<14 = 16384 */ +- 32749, /* 1<<15 = 32768 */ +- 65521, /* 1<<16 = 65536 */ +- 131071, /* 1<<17 = 131072 */ +- 262139, /* 1<<18 = 262144 */ +- 524287, /* 1<<19 = 524288 */ +- 1048573, /* 1<<20 = 1048576 */ +- 2097143, /* 1<<21 = 2097152 */ +- 4194301, /* 1<<22 = 4194304 */ +- 8388593, /* 1<<23 = 8388608 */ +- 16777213, /* 1<<24 = 16777216 */ +- 33554393, /* 1<<25 = 33554432 */ +- 67108859, /* 1<<26 = 67108864 */ +- 134217689, /* 1<<27 = 134217728 */ +- 268435399, /* 1<<28 = 268435456 */ +- }; +- +- public static int getBiggestPrime(int value) +- { +- for (int i = PRIMES.length - 1; i >= 0; i--) { +- if (PRIMES[i] <= value) +- return PRIMES[i]; +- } +- +- return 2; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.hessian.util; ++ ++/** ++ * The IntMap provides a simple hashmap from keys to integers. The API is ++ * an abbreviation of the HashMap collection API. ++ * ++ *

The convenience of IntMap is avoiding all the silly wrapping of ++ * integers. ++ */ ++public class IntMap { ++ /** ++ * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, ++ * it's impossible to distinguish between the two. ++ */ ++ public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; ++ ++ private Object []_keys; ++ private int []_values; ++ ++ private int _size; ++ private int _prime; ++ ++ /** ++ * Create a new IntMap. Default size is 16. ++ */ ++ public IntMap() ++ { ++ int capacity = 1024; ++ ++ _keys = new Object[capacity]; ++ _values = new int[capacity]; ++ ++ _prime = getBiggestPrime(_keys.length); ++ _size = 0; ++ } ++ ++ /** ++ * Clear the hashmap. ++ */ ++ public void clear() ++ { ++ final Object []keys = _keys; ++ final int []values = _values; ++ ++ for (int i = keys.length - 1; i >= 0; i--) { ++ keys[i] = null; ++ values[i] = 0; ++ } ++ ++ _size = 0; ++ } ++ /** ++ * Returns the current number of entries in the map. ++ */ ++ public final int size() ++ { ++ return _size; ++ } ++ ++ /** ++ * Puts a new value in the property table with the appropriate flags ++ */ ++ public final int get(Object key) ++ { ++ int prime = _prime; ++ int hash = hashCode(key) % prime; ++ // int hash = key.hashCode() & mask; ++ ++ final Object []keys = _keys; ++ ++ while (true) { ++ Object mapKey = keys[hash]; ++ ++ if (mapKey == null) ++ return NULL; ++ else if (mapKey == key) ++ return _values[hash]; ++ ++ hash = (hash + 1) % prime; ++ } ++ } ++ ++ /** ++ * Puts a new value in the property table with the appropriate flags ++ */ ++ public final int put(Object key, int value, boolean isReplace) ++ { ++ int prime = _prime; ++ int hash = hashCode(key) % prime; ++ // int hash = key.hashCode() % prime; ++ ++ Object []keys = _keys; ++ ++ while (true) { ++ Object testKey = keys[hash]; ++ ++ if (testKey == null) { ++ keys[hash] = key; ++ _values[hash] = value; ++ ++ _size++; ++ ++ if (keys.length <= 4 * _size) ++ resize(4 * keys.length); ++ ++ return NULL; ++ } ++ else if (key != testKey) { ++ hash = (hash + 1) % prime; ++ ++ continue; ++ } ++ else if (isReplace){ ++ int old = _values[hash]; ++ ++ _values[hash] = value; ++ ++ return old; ++ } ++ else { ++ return _values[hash]; ++ } ++ } ++ } ++ ++ /** ++ * Expands the property table ++ */ ++ private void resize(int newSize) ++ { ++ Object []keys = _keys; ++ int values[] = _values; ++ ++ _keys = new Object[newSize]; ++ _values = new int[newSize]; ++ _size = 0; ++ ++ _prime = getBiggestPrime(_keys.length); ++ ++ for (int i = keys.length - 1; i >= 0; i--) { ++ Object key = keys[i]; ++ ++ if (key != null) { ++ put(key, values[i], true); ++ } ++ } ++ } ++ ++ protected int hashCode(Object value) ++ { ++ return value.hashCode(); ++ } ++ ++ public String toString() ++ { ++ StringBuffer sbuf = new StringBuffer(); ++ ++ sbuf.append("IntMap["); ++ boolean isFirst = true; ++ ++ for (int i = 0; i <= _keys.length; i++) { ++ if (_keys[i] != null) { ++ if (! isFirst) ++ sbuf.append(", "); ++ ++ isFirst = false; ++ sbuf.append(_keys[i]); ++ sbuf.append(":"); ++ sbuf.append(_values[i]); ++ } ++ } ++ sbuf.append("]"); ++ ++ return sbuf.toString(); ++ } ++ ++ public static final int []PRIMES = ++ { ++ 1, /* 1<< 0 = 1 */ ++ 2, /* 1<< 1 = 2 */ ++ 3, /* 1<< 2 = 4 */ ++ 7, /* 1<< 3 = 8 */ ++ 13, /* 1<< 4 = 16 */ ++ 31, /* 1<< 5 = 32 */ ++ 61, /* 1<< 6 = 64 */ ++ 127, /* 1<< 7 = 128 */ ++ 251, /* 1<< 8 = 256 */ ++ 509, /* 1<< 9 = 512 */ ++ 1021, /* 1<<10 = 1024 */ ++ 2039, /* 1<<11 = 2048 */ ++ 4093, /* 1<<12 = 4096 */ ++ 8191, /* 1<<13 = 8192 */ ++ 16381, /* 1<<14 = 16384 */ ++ 32749, /* 1<<15 = 32768 */ ++ 65521, /* 1<<16 = 65536 */ ++ 131071, /* 1<<17 = 131072 */ ++ 262139, /* 1<<18 = 262144 */ ++ 524287, /* 1<<19 = 524288 */ ++ 1048573, /* 1<<20 = 1048576 */ ++ 2097143, /* 1<<21 = 2097152 */ ++ 4194301, /* 1<<22 = 4194304 */ ++ 8388593, /* 1<<23 = 8388608 */ ++ 16777213, /* 1<<24 = 16777216 */ ++ 33554393, /* 1<<25 = 33554432 */ ++ 67108859, /* 1<<26 = 67108864 */ ++ 134217689, /* 1<<27 = 134217728 */ ++ 268435399, /* 1<<28 = 268435456 */ ++ }; ++ ++ public static int getBiggestPrime(int value) ++ { ++ for (int i = PRIMES.length - 1; i >= 0; i--) { ++ if (PRIMES[i] <= value) ++ return PRIMES[i]; ++ } ++ ++ return 2; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/client/ServiceProxyFactory.java hessian-4.0.65-fix/com/caucho/services/client/ServiceProxyFactory.java +--- hessian-4.0.65-src/com/caucho/services/client/ServiceProxyFactory.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/client/ServiceProxyFactory.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,81 +1,81 @@ +-/* +- * The Apache Software License, Version 1.1 +- * +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.client; +- +-/** +- * Factory for creating client stubs. The returned stub will +- * call the remote object for all methods. +- * +- *

+- * URL url = new URL("http://localhost:8080/ejb/hello");
+- * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+- * 
+- * +- * After creation, the stub can be like a regular Java class. Because +- * it makes remote calls, it can throw more exceptions than a Java class. +- * In particular, it may throw protocol exceptions. +- */ +-public interface ServiceProxyFactory { +- /** +- * Creates a new proxy with the specified URL. The returned object +- * is a proxy with the interface specified by api. +- * +- *
+-   * String url = "http://localhost:8080/ejb/hello");
+-   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
+-   * 
+- * +- * @param api the interface the proxy class needs to implement +- * @param url the URL where the client object is located. +- * +- * @return a proxy to the object with the specified interface. +- */ +- public Object create(Class api, String url) +- throws java.net.MalformedURLException; +-} ++/* ++ * The Apache Software License, Version 1.1 ++ * ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.client; ++ ++/** ++ * Factory for creating client stubs. The returned stub will ++ * call the remote object for all methods. ++ * ++ *
++ * URL url = new URL("http://localhost:8080/ejb/hello");
++ * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++ * 
++ * ++ * After creation, the stub can be like a regular Java class. Because ++ * it makes remote calls, it can throw more exceptions than a Java class. ++ * In particular, it may throw protocol exceptions. ++ */ ++public interface ServiceProxyFactory { ++ /** ++ * Creates a new proxy with the specified URL. The returned object ++ * is a proxy with the interface specified by api. ++ * ++ *
++   * String url = "http://localhost:8080/ejb/hello");
++   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
++   * 
++ * ++ * @param api the interface the proxy class needs to implement ++ * @param url the URL where the client object is located. ++ * ++ * @return a proxy to the object with the specified interface. ++ */ ++ public Object create(Class api, String url) ++ throws java.net.MalformedURLException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/message/MessageSender.java hessian-4.0.65-fix/com/caucho/services/message/MessageSender.java +--- hessian-4.0.65-src/com/caucho/services/message/MessageSender.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/message/MessageSender.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,85 +1,85 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be +- * used to endorse or promote products derived from this software +- * without prior written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.message; +- +-import java.util.HashMap; +- +-/** +- * Service API for a bare-bones message server. +- * +- *

A minimal message server only needs to implement the MessageSender +- * interface. Keeping the server API simple makes it easier for +- * implementations to start up message servers. +- * +- *

The MessageSender service is queue or topic specific. So there's no +- * need for a To header if there's no routing involved. +- * In other words, the service URL generally includes the queue +- * or topic identifier, e.g. +- * +- *

+- * http://www.caucho.com/hessian/hessian/message?ejbid=topic-a
+- * 
+- *
+- * 

More complicated messaging topologies, including configurations +- * with routing mesaging servers, will use the headers to define the +- * final destination. The headers have the same functional purpose as +- * RFC-822 mail headers. +- */ +-public interface MessageSender { +- /** +- * Send a message to the server. +- * +- * @param headers any message headers +- * @param message the message data +- * +- * @exception MessageServiceException if the message cannot be delivered +- */ +- public void send(HashMap headers, Object message) +- throws MessageServiceException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be ++ * used to endorse or promote products derived from this software ++ * without prior written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.message; ++ ++import java.util.HashMap; ++ ++/** ++ * Service API for a bare-bones message server. ++ * ++ *

A minimal message server only needs to implement the MessageSender ++ * interface. Keeping the server API simple makes it easier for ++ * implementations to start up message servers. ++ * ++ *

The MessageSender service is queue or topic specific. So there's no ++ * need for a To header if there's no routing involved. ++ * In other words, the service URL generally includes the queue ++ * or topic identifier, e.g. ++ * ++ *

++ * http://www.caucho.com/hessian/hessian/message?ejbid=topic-a
++ * 
++ *
++ * 

More complicated messaging topologies, including configurations ++ * with routing mesaging servers, will use the headers to define the ++ * final destination. The headers have the same functional purpose as ++ * RFC-822 mail headers. ++ */ ++public interface MessageSender { ++ /** ++ * Send a message to the server. ++ * ++ * @param headers any message headers ++ * @param message the message data ++ * ++ * @exception MessageServiceException if the message cannot be delivered ++ */ ++ public void send(HashMap headers, Object message) ++ throws MessageServiceException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/message/MessageServiceException.java hessian-4.0.65-fix/com/caucho/services/message/MessageServiceException.java +--- hessian-4.0.65-src/com/caucho/services/message/MessageServiceException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/message/MessageServiceException.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,110 +1,110 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.message; +- +-import java.io.IOException; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroHessianInput. +- */ +-public class MessageServiceException extends IOException { +- private Throwable _rootCause; +- +- /** +- * Zero-arg constructor. +- */ +- public MessageServiceException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public MessageServiceException(String message) +- { +- super(message); +- } +- +- /** +- * Create the exception. +- */ +- public MessageServiceException(String message, Throwable rootCause) +- { +- super(message); +- +- _rootCause = rootCause; +- } +- +- /** +- * Create the exception. +- */ +- public MessageServiceException(Throwable rootCause) +- { +- super(String.valueOf(rootCause)); +- +- _rootCause = rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getRootCause() +- { +- return getCause(); +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getCause() +- { +- return _rootCause; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.message; ++ ++import java.io.IOException; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroHessianInput. ++ */ ++public class MessageServiceException extends IOException { ++ private Throwable _rootCause; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public MessageServiceException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public MessageServiceException(String message) ++ { ++ super(message); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public MessageServiceException(String message, Throwable rootCause) ++ { ++ super(message); ++ ++ _rootCause = rootCause; ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public MessageServiceException(Throwable rootCause) ++ { ++ super(String.valueOf(rootCause)); ++ ++ _rootCause = rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getRootCause() ++ { ++ return getCause(); ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getCause() ++ { ++ return _rootCause; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/name/NameServer.java hessian-4.0.65-fix/com/caucho/services/name/NameServer.java +--- hessian-4.0.65-src/com/caucho/services/name/NameServer.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/name/NameServer.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,100 +1,100 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be +- * used to endorse or promote products derived from this software +- * without prior written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.name; +- +-/** +- * A read-only name service. The name service provides hierarchical +- * object lookup. The path names are separated by '/'. +- * +- *

Because the name service is hierarchical, a lookup of an intermediate +- * node will return a NameServer instance. +- * +- *

The following example is a simple use of the NameServer: +- *

+- * /dir-1/1 - where foo contains the string "foo-1"
+- * /dir-1/2 - where foo contains the string "foo-2"
+- * /dir-2/1 - where foo contains the string "foo-1"
+- * /dir-2/2 - where foo contains the string "foo-2"
+- * 
+- * +- *

The root server might have a URL like: +- *

+- * http://www.caucho.com/hessian/hessian/name?ejbid=/
+- * 
+- * +- *

So root.lookup("/dir-1/1") will return the string +- * "foo-1", and root.lookup("/dir-1") will return the +- * NameServer with the URL: +- *

+- * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
+- * 
+- */ +-public interface NameServer { +- /** +- * Lookup an object from the name server. +- * +- * @param name the relative path name +- * +- * @return the matching object or null if no object maches +- * +- * @exception NameServiceException if there's an error +- */ +- public Object lookup(String name) +- throws NameServiceException; +- +- /** +- * Lists all the object name components directly below the current context. +- * The names are the relative compent name. +- * +- *

For example, if the name server context is "/dir-1", the returned +- * values will be ["1", "2"]. +- */ +- public String []list() +- throws NameServiceException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be ++ * used to endorse or promote products derived from this software ++ * without prior written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.name; ++ ++/** ++ * A read-only name service. The name service provides hierarchical ++ * object lookup. The path names are separated by '/'. ++ * ++ *

Because the name service is hierarchical, a lookup of an intermediate ++ * node will return a NameServer instance. ++ * ++ *

The following example is a simple use of the NameServer: ++ *

++ * /dir-1/1 - where foo contains the string "foo-1"
++ * /dir-1/2 - where foo contains the string "foo-2"
++ * /dir-2/1 - where foo contains the string "foo-1"
++ * /dir-2/2 - where foo contains the string "foo-2"
++ * 
++ * ++ *

The root server might have a URL like: ++ *

++ * http://www.caucho.com/hessian/hessian/name?ejbid=/
++ * 
++ * ++ *

So root.lookup("/dir-1/1") will return the string ++ * "foo-1", and root.lookup("/dir-1") will return the ++ * NameServer with the URL: ++ *

++ * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
++ * 
++ */ ++public interface NameServer { ++ /** ++ * Lookup an object from the name server. ++ * ++ * @param name the relative path name ++ * ++ * @return the matching object or null if no object maches ++ * ++ * @exception NameServiceException if there's an error ++ */ ++ public Object lookup(String name) ++ throws NameServiceException; ++ ++ /** ++ * Lists all the object name components directly below the current context. ++ * The names are the relative compent name. ++ * ++ *

For example, if the name server context is "/dir-1", the returned ++ * values will be ["1", "2"]. ++ */ ++ public String []list() ++ throws NameServiceException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/name/NameServerRemote.java hessian-4.0.65-fix/com/caucho/services/name/NameServerRemote.java +--- hessian-4.0.65-src/com/caucho/services/name/NameServerRemote.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/name/NameServerRemote.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,102 +1,102 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be +- * used to endorse or promote products derived from this software +- * without prior written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.name; +- +-import java.rmi.RemoteException; +- +-/** +- * A read-only name service. The name service provides hierarchical +- * object lookup. The path names are separated by '/'. +- * +- *

Because the name service is hierarchical, a lookup of an intermediate +- * node will return a NameServer instance. +- * +- *

The following example is a simple use of the NameServer: +- *

+- * /dir-1/1 - where foo contains the string "foo-1"
+- * /dir-1/2 - where foo contains the string "foo-2"
+- * /dir-2/1 - where foo contains the string "foo-1"
+- * /dir-2/2 - where foo contains the string "foo-2"
+- * 
+- * +- *

The root server might have a URL like: +- *

+- * http://www.caucho.com/hessian/hessian/name?ejbid=/
+- * 
+- * +- *

So root.lookup("/dir-1/1") will return the string +- * "foo-1", and root.lookup("/dir-1") will return the +- * NameServer with the URL: +- *

+- * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
+- * 
+- */ +-public interface NameServerRemote { +- /** +- * Lookup an object from the name server. +- * +- * @param name the relative path name +- * +- * @return the matching object or null if no object maches +- * +- * @exception NameServiceException if there's an error +- */ +- public Object lookup(String name) +- throws NameServiceException, RemoteException; +- +- /** +- * Lists all the object name components directly below the current context. +- * The names are the relative compent name. +- * +- *

For example, if the name server context is "/dir-1", the returned +- * values will be ["1", "2"]. +- */ +- public String []list() +- throws NameServiceException, RemoteException; +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be ++ * used to endorse or promote products derived from this software ++ * without prior written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.name; ++ ++import java.rmi.RemoteException; ++ ++/** ++ * A read-only name service. The name service provides hierarchical ++ * object lookup. The path names are separated by '/'. ++ * ++ *

Because the name service is hierarchical, a lookup of an intermediate ++ * node will return a NameServer instance. ++ * ++ *

The following example is a simple use of the NameServer: ++ *

++ * /dir-1/1 - where foo contains the string "foo-1"
++ * /dir-1/2 - where foo contains the string "foo-2"
++ * /dir-2/1 - where foo contains the string "foo-1"
++ * /dir-2/2 - where foo contains the string "foo-2"
++ * 
++ * ++ *

The root server might have a URL like: ++ *

++ * http://www.caucho.com/hessian/hessian/name?ejbid=/
++ * 
++ * ++ *

So root.lookup("/dir-1/1") will return the string ++ * "foo-1", and root.lookup("/dir-1") will return the ++ * NameServer with the URL: ++ *

++ * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
++ * 
++ */ ++public interface NameServerRemote { ++ /** ++ * Lookup an object from the name server. ++ * ++ * @param name the relative path name ++ * ++ * @return the matching object or null if no object maches ++ * ++ * @exception NameServiceException if there's an error ++ */ ++ public Object lookup(String name) ++ throws NameServiceException, RemoteException; ++ ++ /** ++ * Lists all the object name components directly below the current context. ++ * The names are the relative compent name. ++ * ++ *

For example, if the name server context is "/dir-1", the returned ++ * values will be ["1", "2"]. ++ */ ++ public String []list() ++ throws NameServiceException, RemoteException; ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/name/NameServiceException.java hessian-4.0.65-fix/com/caucho/services/name/NameServiceException.java +--- hessian-4.0.65-src/com/caucho/services/name/NameServiceException.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/name/NameServiceException.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,102 +1,102 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.name; +- +-import java.io.IOException; +- +-/** +- * Exception for faults when the fault doesn't return a java exception. +- * This exception is required for MicroHessianInput. +- */ +-public class NameServiceException extends IOException { +- private Throwable rootCause; +- +- /** +- * Zero-arg constructor. +- */ +- public NameServiceException() +- { +- } +- +- /** +- * Create the exception. +- */ +- public NameServiceException(String name) +- { +- super(name); +- } +- +- /** +- * Create the exception. +- */ +- public NameServiceException(String name, Throwable rootCause) +- { +- super(name); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Create the exception. +- */ +- public NameServiceException(Throwable rootCause) +- { +- super(String.valueOf(rootCause)); +- +- this.rootCause = rootCause; +- } +- +- /** +- * Returns the underlying cause. +- */ +- public Throwable getRootCause() +- { +- return rootCause; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.name; ++ ++import java.io.IOException; ++ ++/** ++ * Exception for faults when the fault doesn't return a java exception. ++ * This exception is required for MicroHessianInput. ++ */ ++public class NameServiceException extends IOException { ++ private Throwable rootCause; ++ ++ /** ++ * Zero-arg constructor. ++ */ ++ public NameServiceException() ++ { ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public NameServiceException(String name) ++ { ++ super(name); ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public NameServiceException(String name, Throwable rootCause) ++ { ++ super(name); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Create the exception. ++ */ ++ public NameServiceException(Throwable rootCause) ++ { ++ super(String.valueOf(rootCause)); ++ ++ this.rootCause = rootCause; ++ } ++ ++ /** ++ * Returns the underlying cause. ++ */ ++ public Throwable getRootCause() ++ { ++ return rootCause; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/server/AbstractSkeleton.java hessian-4.0.65-fix/com/caucho/services/server/AbstractSkeleton.java +--- hessian-4.0.65-src/com/caucho/services/server/AbstractSkeleton.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/server/AbstractSkeleton.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,221 +1,221 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.server; +- +-import java.io.InputStream; +-import java.lang.reflect.Method; +-import java.util.HashMap; +- +-/** +- * Proxy class for Hessian services. +- */ +-abstract public class AbstractSkeleton { +- private Class _apiClass; +- private Class _homeClass; +- private Class _objectClass; +- +- private HashMap _methodMap = new HashMap(); +- +- /** +- * Create a new hessian skeleton. +- * +- * @param apiClass the API interface +- */ +- protected AbstractSkeleton(Class apiClass) +- { +- _apiClass = apiClass; +- +- Method []methodList = apiClass.getMethods(); +- +- for (int i = 0; i < methodList.length; i++) { +- Method method = methodList[i]; +- +- if (_methodMap.get(method.getName()) == null) +- _methodMap.put(method.getName(), methodList[i]); +- +- Class []param = method.getParameterTypes(); +- String mangledName = method.getName() + "__" + param.length; +- _methodMap.put(mangledName, methodList[i]); +- +- _methodMap.put(mangleName(method, false), methodList[i]); +- } +- } +- +- /** +- * Returns the API class of the current object. +- */ +- public String getAPIClassName() +- { +- return _apiClass.getName(); +- } +- +- /** +- * Returns the API class of the factory/home. +- */ +- public String getHomeClassName() +- { +- if (_homeClass != null) +- return _homeClass.getName(); +- else +- return getAPIClassName(); +- } +- +- /** +- * Sets the home API class. +- */ +- public void setHomeClass(Class homeAPI) +- { +- _homeClass = homeAPI; +- } +- +- /** +- * Returns the API class of the object URLs +- */ +- public String getObjectClassName() +- { +- if (_objectClass != null) +- return _objectClass.getName(); +- else +- return getAPIClassName(); +- } +- +- /** +- * Sets the object API class. +- */ +- public void setObjectClass(Class objectAPI) +- { +- _objectClass = objectAPI; +- } +- +- /** +- * Returns the method by the mangled name. +- * +- * @param mangledName the name passed by the protocol +- */ +- protected Method getMethod(String mangledName) +- { +- return (Method) _methodMap.get(mangledName); +- } +- +- /** +- * Creates a unique mangled method name based on the method name and +- * the method parameters. +- * +- * @param method the method to mangle +- * @param isFull if true, mangle the full classname +- * +- * @return a mangled string. +- */ +- public static String mangleName(Method method, boolean isFull) +- { +- StringBuffer sb = new StringBuffer(); +- +- sb.append(method.getName()); +- +- Class []params = method.getParameterTypes(); +- for (int i = 0; i < params.length; i++) { +- sb.append('_'); +- sb.append(mangleClass(params[i], isFull)); +- } +- +- return sb.toString(); +- } +- +- /** +- * Mangles a classname. +- */ +- public static String mangleClass(Class cl, boolean isFull) +- { +- String name = cl.getName(); +- +- if (name.equals("boolean") || name.equals("java.lang.Boolean")) +- return "boolean"; +- else if (name.equals("int") || name.equals("java.lang.Integer") +- || name.equals("short") || name.equals("java.lang.Short") +- || name.equals("byte") || name.equals("java.lang.Byte")) +- return "int"; +- else if (name.equals("long") || name.equals("java.lang.Long")) +- return "long"; +- else if (name.equals("float") || name.equals("java.lang.Float") +- || name.equals("double") || name.equals("java.lang.Double")) +- return "double"; +- else if (name.equals("java.lang.String") +- || name.equals("com.caucho.util.CharBuffer") +- || name.equals("char") || name.equals("java.lang.Character") +- || name.equals("java.io.Reader")) +- return "string"; +- else if (name.equals("java.util.Date") +- || name.equals("com.caucho.util.QDate")) +- return "date"; +- else if (InputStream.class.isAssignableFrom(cl) +- || name.equals("[B")) +- return "binary"; +- else if (cl.isArray()) { +- return "[" + mangleClass(cl.getComponentType(), isFull); +- } +- else if (name.equals("org.w3c.dom.Node") +- || name.equals("org.w3c.dom.Element") +- || name.equals("org.w3c.dom.Document")) +- return "xml"; +- else if (isFull) +- return name; +- else { +- int p = name.lastIndexOf('.'); +- if (p > 0) +- return name.substring(p + 1); +- else +- return name; +- } +- } +- +- public String toString() +- { +- return getClass().getSimpleName() + "[" + _apiClass.getName() + "]"; +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.server; ++ ++import java.io.InputStream; ++import java.lang.reflect.Method; ++import java.util.HashMap; ++ ++/** ++ * Proxy class for Hessian services. ++ */ ++abstract public class AbstractSkeleton { ++ private Class _apiClass; ++ private Class _homeClass; ++ private Class _objectClass; ++ ++ private HashMap _methodMap = new HashMap(); ++ ++ /** ++ * Create a new hessian skeleton. ++ * ++ * @param apiClass the API interface ++ */ ++ protected AbstractSkeleton(Class apiClass) ++ { ++ _apiClass = apiClass; ++ ++ Method []methodList = apiClass.getMethods(); ++ ++ for (int i = 0; i < methodList.length; i++) { ++ Method method = methodList[i]; ++ ++ if (_methodMap.get(method.getName()) == null) ++ _methodMap.put(method.getName(), methodList[i]); ++ ++ Class []param = method.getParameterTypes(); ++ String mangledName = method.getName() + "__" + param.length; ++ _methodMap.put(mangledName, methodList[i]); ++ ++ _methodMap.put(mangleName(method, false), methodList[i]); ++ } ++ } ++ ++ /** ++ * Returns the API class of the current object. ++ */ ++ public String getAPIClassName() ++ { ++ return _apiClass.getName(); ++ } ++ ++ /** ++ * Returns the API class of the factory/home. ++ */ ++ public String getHomeClassName() ++ { ++ if (_homeClass != null) ++ return _homeClass.getName(); ++ else ++ return getAPIClassName(); ++ } ++ ++ /** ++ * Sets the home API class. ++ */ ++ public void setHomeClass(Class homeAPI) ++ { ++ _homeClass = homeAPI; ++ } ++ ++ /** ++ * Returns the API class of the object URLs ++ */ ++ public String getObjectClassName() ++ { ++ if (_objectClass != null) ++ return _objectClass.getName(); ++ else ++ return getAPIClassName(); ++ } ++ ++ /** ++ * Sets the object API class. ++ */ ++ public void setObjectClass(Class objectAPI) ++ { ++ _objectClass = objectAPI; ++ } ++ ++ /** ++ * Returns the method by the mangled name. ++ * ++ * @param mangledName the name passed by the protocol ++ */ ++ protected Method getMethod(String mangledName) ++ { ++ return (Method) _methodMap.get(mangledName); ++ } ++ ++ /** ++ * Creates a unique mangled method name based on the method name and ++ * the method parameters. ++ * ++ * @param method the method to mangle ++ * @param isFull if true, mangle the full classname ++ * ++ * @return a mangled string. ++ */ ++ public static String mangleName(Method method, boolean isFull) ++ { ++ StringBuffer sb = new StringBuffer(); ++ ++ sb.append(method.getName()); ++ ++ Class []params = method.getParameterTypes(); ++ for (int i = 0; i < params.length; i++) { ++ sb.append('_'); ++ sb.append(mangleClass(params[i], isFull)); ++ } ++ ++ return sb.toString(); ++ } ++ ++ /** ++ * Mangles a classname. ++ */ ++ public static String mangleClass(Class cl, boolean isFull) ++ { ++ String name = cl.getName(); ++ ++ if (name.equals("boolean") || name.equals("java.lang.Boolean")) ++ return "boolean"; ++ else if (name.equals("int") || name.equals("java.lang.Integer") ++ || name.equals("short") || name.equals("java.lang.Short") ++ || name.equals("byte") || name.equals("java.lang.Byte")) ++ return "int"; ++ else if (name.equals("long") || name.equals("java.lang.Long")) ++ return "long"; ++ else if (name.equals("float") || name.equals("java.lang.Float") ++ || name.equals("double") || name.equals("java.lang.Double")) ++ return "double"; ++ else if (name.equals("java.lang.String") ++ || name.equals("com.caucho.util.CharBuffer") ++ || name.equals("char") || name.equals("java.lang.Character") ++ || name.equals("java.io.Reader")) ++ return "string"; ++ else if (name.equals("java.util.Date") ++ || name.equals("com.caucho.util.QDate")) ++ return "date"; ++ else if (InputStream.class.isAssignableFrom(cl) ++ || name.equals("[B")) ++ return "binary"; ++ else if (cl.isArray()) { ++ return "[" + mangleClass(cl.getComponentType(), isFull); ++ } ++ else if (name.equals("org.w3c.dom.Node") ++ || name.equals("org.w3c.dom.Element") ++ || name.equals("org.w3c.dom.Document")) ++ return "xml"; ++ else if (isFull) ++ return name; ++ else { ++ int p = name.lastIndexOf('.'); ++ if (p > 0) ++ return name.substring(p + 1); ++ else ++ return name; ++ } ++ } ++ ++ public String toString() ++ { ++ return getClass().getSimpleName() + "[" + _apiClass.getName() + "]"; ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/server/GenericService.java hessian-4.0.65-fix/com/caucho/services/server/GenericService.java +--- hessian-4.0.65-src/com/caucho/services/server/GenericService.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/server/GenericService.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,153 +1,153 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.server; +- +-import javax.servlet.ServletConfig; +-import javax.servlet.ServletContext; +-import javax.servlet.ServletException; +-import javax.servlet.ServletRequest; +- +-/** +- * Interface for a service, including lifecycle. +- */ +-public class GenericService implements Service { +- protected ServletConfig config; +- +- /** +- * Initialize the service instance. +- */ +- public void init(ServletConfig config) +- throws ServletException +- { +- this.config = config; +- +- init(); +- } +- +- /** +- * Initialize the service instance. +- */ +- public void init() +- throws ServletException +- { +- } +- +- /** +- * Returns the named initialization parameter. +- */ +- public String getInitParameter(String name) +- { +- return this.config.getInitParameter(name); +- } +- +- /** +- * Returns the servlet context. +- */ +- public ServletConfig getServletConfig() +- { +- return this.config; +- } +- +- /** +- * Returns the servlet context. +- */ +- public ServletContext getServletContext() +- { +- return this.config.getServletContext(); +- } +- +- /** +- * Logs a message to the error stream. +- */ +- public void log(String message) +- { +- getServletContext().log(message); +- } +- +- /** +- * Returns the servlet request object for the request. +- */ +- public ServletRequest getRequest() +- { +- return ServiceContext.getRequest(); +- } +- +- /** +- * Returns the service identifier for the request. +- */ +- public String getServiceName() +- { +- return ServiceContext.getServiceName(); +- } +- +- /** +- * Returns the service identifier for the request. +- * +- * @deprecated +- */ +- public String getServiceId() +- { +- return getServiceName(); +- } +- +- /** +- * Returns the object identifier for the request. +- */ +- public String getObjectId() +- { +- return ServiceContext.getObjectId(); +- } +- +- /** +- * Cleanup the service instance. +- */ +- public void destroy() +- { +- } +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.server; ++ ++import javax.servlet.ServletConfig; ++import javax.servlet.ServletContext; ++import javax.servlet.ServletException; ++import javax.servlet.ServletRequest; ++ ++/** ++ * Interface for a service, including lifecycle. ++ */ ++public class GenericService implements Service { ++ protected ServletConfig config; ++ ++ /** ++ * Initialize the service instance. ++ */ ++ public void init(ServletConfig config) ++ throws ServletException ++ { ++ this.config = config; ++ ++ init(); ++ } ++ ++ /** ++ * Initialize the service instance. ++ */ ++ public void init() ++ throws ServletException ++ { ++ } ++ ++ /** ++ * Returns the named initialization parameter. ++ */ ++ public String getInitParameter(String name) ++ { ++ return this.config.getInitParameter(name); ++ } ++ ++ /** ++ * Returns the servlet context. ++ */ ++ public ServletConfig getServletConfig() ++ { ++ return this.config; ++ } ++ ++ /** ++ * Returns the servlet context. ++ */ ++ public ServletContext getServletContext() ++ { ++ return this.config.getServletContext(); ++ } ++ ++ /** ++ * Logs a message to the error stream. ++ */ ++ public void log(String message) ++ { ++ getServletContext().log(message); ++ } ++ ++ /** ++ * Returns the servlet request object for the request. ++ */ ++ public ServletRequest getRequest() ++ { ++ return ServiceContext.getRequest(); ++ } ++ ++ /** ++ * Returns the service identifier for the request. ++ */ ++ public String getServiceName() ++ { ++ return ServiceContext.getServiceName(); ++ } ++ ++ /** ++ * Returns the service identifier for the request. ++ * ++ * @deprecated ++ */ ++ public String getServiceId() ++ { ++ return getServiceName(); ++ } ++ ++ /** ++ * Returns the object identifier for the request. ++ */ ++ public String getObjectId() ++ { ++ return ServiceContext.getObjectId(); ++ } ++ ++ /** ++ * Cleanup the service instance. ++ */ ++ public void destroy() ++ { ++ } ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/server/Service.java hessian-4.0.65-fix/com/caucho/services/server/Service.java +--- hessian-4.0.65-src/com/caucho/services/server/Service.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/server/Service.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,83 +1,83 @@ +-/* +- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.server; +- +-import javax.servlet.ServletConfig; +-import javax.servlet.ServletException; +- +-/** +- * Interface for a service lifecycle. +- * +- *

The lifecycle for a service starts with the init +- * method when the service starts. +- * +- *

+- * myService.init(config);
+- * ...
+- * myService.hello();
+- * ...
+- * myService.hello();
+- * ...
+- * myService.destroy();
+- * 
+- */ +-public interface Service { +- /** +- * Initialize the service instance. +- * +- * @param config the configuration for the service. +- */ +- public void init(ServletConfig config) +- throws ServletException; +- +- /** +- * Cleanup the service instance. +- */ +- public void destroy(); +-} ++/* ++ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.server; ++ ++import javax.servlet.ServletConfig; ++import javax.servlet.ServletException; ++ ++/** ++ * Interface for a service lifecycle. ++ * ++ *

The lifecycle for a service starts with the init ++ * method when the service starts. ++ * ++ *

++ * myService.init(config);
++ * ...
++ * myService.hello();
++ * ...
++ * myService.hello();
++ * ...
++ * myService.destroy();
++ * 
++ */ ++public interface Service { ++ /** ++ * Initialize the service instance. ++ * ++ * @param config the configuration for the service. ++ */ ++ public void init(ServletConfig config) ++ throws ServletException; ++ ++ /** ++ * Cleanup the service instance. ++ */ ++ public void destroy(); ++} +diff -uNr hessian-4.0.65-src/com/caucho/services/server/ServiceContext.java hessian-4.0.65-fix/com/caucho/services/server/ServiceContext.java +--- hessian-4.0.65-src/com/caucho/services/server/ServiceContext.java 2020-07-23 12:51:28.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/services/server/ServiceContext.java 2023-08-15 18:39:24.000000000 +0800 +@@ -1,259 +1,274 @@ +-/* +- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. +- * +- * The Apache Software License, Version 1.1 +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in +- * the documentation and/or other materials provided with the +- * distribution. +- * +- * 3. The end-user documentation included with the redistribution, if +- * any, must include the following acknowlegement: +- * "This product includes software developed by the +- * Caucho Technology (http://www.caucho.com/)." +- * Alternately, this acknowlegement may appear in the software itself, +- * if and wherever such third-party acknowlegements normally appear. +- * +- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to +- * endorse or promote products derived from this software without prior +- * written permission. For written permission, please contact +- * info@caucho.com. +- * +- * 5. Products derived from this software may not be called "Resin" +- * nor may "Resin" appear in their names without prior written +- * permission of Caucho Technology. +- * +- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS +- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * @author Scott Ferguson +- */ +- +-package com.caucho.services.server; +- +-import javax.servlet.ServletException; +-import javax.servlet.ServletRequest; +-import javax.servlet.ServletResponse; +- +-import java.util.HashMap; +- +-/** +- * Context for a service, to handle request-specific information. +- * +- * Applications can use the ServiceContext to get servlet session ids or +- * HTTP headers. +- * +- *
+- * ServletRequest req = ServiceContext.getContext().getRequest();
+- * 
+- */ +-public class ServiceContext { +- private static final ThreadLocal _localContext +- = new ThreadLocal(); +- +- private ServletRequest _request; +- private ServletResponse _response; +- private String _serviceName; +- private String _objectId; +- private int _count; +- private HashMap _headers = new HashMap(); +- +- private ServiceContext() +- { +- } +- +- /** +- * Sets the request object prior to calling the service's method. +- * +- * @param request the calling servlet request +- * @param serviceId the service identifier +- * @param objectId the object identifier +- */ +- public static void begin(ServletRequest request, +- ServletResponse response, +- String serviceName, +- String objectId) +- throws ServletException +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context == null) { +- context = new ServiceContext(); +- _localContext.set(context); +- } +- +- context._request = request; +- context._response = response; +- context._serviceName = serviceName; +- context._objectId = objectId; +- context._count++; +- } +- +- /** +- * Returns the service request. +- */ +- public static ServiceContext getContext() +- { +- return (ServiceContext) _localContext.get(); +- } +- +- /** +- * Adds a header. +- */ +- public void addHeader(String header, Object value) +- { +- _headers.put(header, value); +- } +- +- /** +- * Gets a header. +- */ +- public Object getHeader(String header) +- { +- return _headers.get(header); +- } +- +- /** +- * Gets a header from the context. +- */ +- public static Object getContextHeader(String header) +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context.getHeader(header); +- else +- return null; +- } +- +- /** +- * Returns the service request. +- */ +- public static ServletRequest getContextRequest() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context._request; +- else +- return null; +- } +- +- /** +- * Returns the service request. +- */ +- public static ServletResponse getContextResponse() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context._response; +- else +- return null; +- } +- +- /** +- * Returns the service id, corresponding to the pathInfo of the URL. +- */ +- public static String getContextServiceName() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context._serviceName; +- else +- return null; +- } +- +- /** +- * Returns the object id, corresponding to the ?id= of the URL. +- */ +- public static String getContextObjectId() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context._objectId; +- else +- return null; +- } +- +- /** +- * Cleanup at the end of a request. +- */ +- public static void end() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null && --context._count == 0) { +- context._request = null; +- context._response = null; +- +- context._headers.clear(); +- +- _localContext.set(null); +- } +- } +- +- /** +- * Returns the service request. +- * +- * @deprecated +- */ +- public static ServletRequest getRequest() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context._request; +- else +- return null; +- } +- +- /** +- * Returns the service id, corresponding to the pathInfo of the URL. +- * +- * @deprecated +- */ +- public static String getServiceName() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context._serviceName; +- else +- return null; +- } +- +- /** +- * Returns the object id, corresponding to the ?id= of the URL. +- * +- * @deprecated +- */ +- public static String getObjectId() +- { +- ServiceContext context = (ServiceContext) _localContext.get(); +- +- if (context != null) +- return context._objectId; +- else +- return null; +- } +-} ++/* ++ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. ++ * ++ * The Apache Software License, Version 1.1 ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * 3. The end-user documentation included with the redistribution, if ++ * any, must include the following acknowlegement: ++ * "This product includes software developed by the ++ * Caucho Technology (http://www.caucho.com/)." ++ * Alternately, this acknowlegement may appear in the software itself, ++ * if and wherever such third-party acknowlegements normally appear. ++ * ++ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to ++ * endorse or promote products derived from this software without prior ++ * written permission. For written permission, please contact ++ * info@caucho.com. ++ * ++ * 5. Products derived from this software may not be called "Resin" ++ * nor may "Resin" appear in their names without prior written ++ * permission of Caucho Technology. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS ++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ++ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ++ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ++ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * @author Scott Ferguson ++ */ ++ ++package com.caucho.services.server; ++ ++import javax.servlet.ServletException; ++import javax.servlet.ServletRequest; ++import javax.servlet.ServletResponse; ++ ++import java.util.HashMap; ++ ++/** ++ * Context for a service, to handle request-specific information. ++ * ++ * Applications can use the ServiceContext to get servlet session ids or ++ * HTTP headers. ++ * ++ *
++ * ServletRequest req = ServiceContext.getContext().getRequest();
++ * 
++ */ ++public class ServiceContext { ++ private static final ThreadLocal _localContext ++ = new ThreadLocal(); ++ ++ private ServletRequest _request; ++ private ServletResponse _response; ++ private String _serviceName; ++ private String _objectId; ++ private int _count; ++ private HashMap _headers = new HashMap(); ++ ++ private ServiceContext() ++ { ++ } ++ ++ /** ++ * Sets the request object prior to calling the service's method. ++ * ++ * @param request the calling servlet request ++ * @param serviceId the service identifier ++ * @param objectId the object identifier ++ */ ++ public static void begin(ServletRequest request, ++ ServletResponse response, ++ String serviceName, ++ String objectId) ++ throws ServletException ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context == null) { ++ context = new ServiceContext(); ++ _localContext.set(context); ++ } ++ ++ context._request = request; ++ context._response = response; ++ context._serviceName = serviceName; ++ context._objectId = objectId; ++ context._count++; ++ } ++ ++ public static void begin(ServletRequest request, String serviceName, ++ String objectId) throws ServletException { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context == null) { ++ context = new ServiceContext(); ++ _localContext.set(context); ++ } ++ ++ context._request = request; ++ context._serviceName = serviceName; ++ context._objectId = objectId; ++ context._count++; ++ } ++ ++ /** ++ * Returns the service request. ++ */ ++ public static ServiceContext getContext() ++ { ++ return (ServiceContext) _localContext.get(); ++ } ++ ++ /** ++ * Adds a header. ++ */ ++ public void addHeader(String header, Object value) ++ { ++ _headers.put(header, value); ++ } ++ ++ /** ++ * Gets a header. ++ */ ++ public Object getHeader(String header) ++ { ++ return _headers.get(header); ++ } ++ ++ /** ++ * Gets a header from the context. ++ */ ++ public static Object getContextHeader(String header) ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context.getHeader(header); ++ else ++ return null; ++ } ++ ++ /** ++ * Returns the service request. ++ */ ++ public static ServletRequest getContextRequest() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context._request; ++ else ++ return null; ++ } ++ ++ /** ++ * Returns the service request. ++ */ ++ public static ServletResponse getContextResponse() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context._response; ++ else ++ return null; ++ } ++ ++ /** ++ * Returns the service id, corresponding to the pathInfo of the URL. ++ */ ++ public static String getContextServiceName() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context._serviceName; ++ else ++ return null; ++ } ++ ++ /** ++ * Returns the object id, corresponding to the ?id= of the URL. ++ */ ++ public static String getContextObjectId() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context._objectId; ++ else ++ return null; ++ } ++ ++ /** ++ * Cleanup at the end of a request. ++ */ ++ public static void end() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null && --context._count == 0) { ++ context._request = null; ++ context._response = null; ++ ++ context._headers.clear(); ++ ++ _localContext.set(null); ++ } ++ } ++ ++ /** ++ * Returns the service request. ++ * ++ * @deprecated ++ */ ++ public static ServletRequest getRequest() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context._request; ++ else ++ return null; ++ } ++ ++ /** ++ * Returns the service id, corresponding to the pathInfo of the URL. ++ * ++ * @deprecated ++ */ ++ public static String getServiceName() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context._serviceName; ++ else ++ return null; ++ } ++ ++ /** ++ * Returns the object id, corresponding to the ?id= of the URL. ++ * ++ * @deprecated ++ */ ++ public static String getObjectId() ++ { ++ ServiceContext context = (ServiceContext) _localContext.get(); ++ ++ if (context != null) ++ return context._objectId; ++ else ++ return null; ++ } ++} diff --git a/hessian.spec b/hessian.spec index 8f93372..846079d 100644 --- a/hessian.spec +++ b/hessian.spec @@ -1,7 +1,7 @@ Name: hessian Summary: Java implementation of a binary protocol for web services Version: 4.0.65 -Release: 1 +Release: 2 Epoch: 0 License: ASL 1.1 URL: http://hessian.caucho.com/ @@ -10,6 +10,9 @@ Source1: https://repo1.maven.org/maven2/com/caucho/%{name}/%{version Source2: https://opensource.org/licenses/Apache-1.1#/Apache-1.1.html#/Apache-1.1 BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) + +Patch1: %{name}-202308291450.patch + BuildArch: noarch %description This is the Java implementation of Caucho's Hession binary transport @@ -21,7 +24,8 @@ Summary: API documentation for %{name} API documentation for %{name}. %prep -%setup -q -c +%autosetup -n %{name}-%{version} -p1 + mkdir src mv com src/ rm -r META-INF @@ -69,6 +73,9 @@ cp -p %{SOURCE2} apache.license.html %license apache.license.html %changelog +* Tue Aug 29 2023 Bin Huang - 0:4.0.65-2 +- commit patch + * Mon Aug 21 2023 Bin Huang - 0:4.0.65-1 - Package update version to 4.0.65 -- Gitee From a88cf52a275e119e4cf98775305392969454a275 Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 1 Sep 2023 00:04:13 +0800 Subject: [PATCH 02/16] change spec --- hessian.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hessian.spec b/hessian.spec index 846079d..9d2dd70 100644 --- a/hessian.spec +++ b/hessian.spec @@ -24,7 +24,8 @@ Summary: API documentation for %{name} API documentation for %{name}. %prep -%autosetup -n %{name}-%{version} -p1 +%setup -q -c +%patch -p1 mkdir src mv com src/ -- Gitee From d5d3dbf780d2825a18387714057ae4ded656a49a Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 1 Sep 2023 00:23:51 +0800 Subject: [PATCH 03/16] change spec --- hessian.spec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hessian.spec b/hessian.spec index 9d2dd70..45f30ef 100644 --- a/hessian.spec +++ b/hessian.spec @@ -24,8 +24,7 @@ Summary: API documentation for %{name} API documentation for %{name}. %prep -%setup -q -c -%patch -p1 +%setup -c -p1 mkdir src mv com src/ -- Gitee From bb39160df96dd9fb9544ea47a8d59e89136c2d7d Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 1 Sep 2023 00:40:18 +0800 Subject: [PATCH 04/16] change spec --- hessian.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hessian.spec b/hessian.spec index 45f30ef..9ba203a 100644 --- a/hessian.spec +++ b/hessian.spec @@ -24,7 +24,7 @@ Summary: API documentation for %{name} API documentation for %{name}. %prep -%setup -c -p1 +%autosetup -c -p1 mkdir src mv com src/ -- Gitee From 6a734a2549cc050dec716699d596eab09013454f Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Thu, 7 Sep 2023 15:27:32 +0800 Subject: [PATCH 05/16] change patch --- hessian-202308291450.patch | 95186 ----------------------------------- hessian-20230907.patch | 1798 + hessian.spec | 2 +- 3 files changed, 1799 insertions(+), 95187 deletions(-) delete mode 100644 hessian-202308291450.patch create mode 100644 hessian-20230907.patch diff --git a/hessian-202308291450.patch b/hessian-202308291450.patch deleted file mode 100644 index 9cd30bf..0000000 --- a/hessian-202308291450.patch +++ /dev/null @@ -1,95186 +0,0 @@ -diff -uNr hessian-4.0.65-src/META-INF/MANIFEST.MF hessian-4.0.65-fix/META-INF/MANIFEST.MF ---- hessian-4.0.65-src/META-INF/MANIFEST.MF 2020-07-23 12:54:20.000000000 +0800 -+++ hessian-4.0.65-fix/META-INF/MANIFEST.MF 2023-08-15 18:39:22.000000000 +0800 -@@ -1,4 +1,5 @@ - Manifest-Version: 1.0 --Ant-Version: Apache Ant 1.10.5 --Created-By: 1.8.0_252-8u252-b09-1~18.04-b09 (Private Build) -+Implementation-Vendor: Caucho Technology, Inc. -+Implementation-Version: 3.1.0 -+Created-By: 1.7.0_25 (Oracle Corporation) - -diff -uNr hessian-4.0.65-src/META-INF/hessian/deserializers hessian-4.0.65-fix/META-INF/hessian/deserializers ---- hessian-4.0.65-src/META-INF/hessian/deserializers 1970-01-01 08:00:00.000000000 +0800 -+++ hessian-4.0.65-fix/META-INF/hessian/deserializers 2023-08-15 18:39:22.000000000 +0800 -@@ -0,0 +1,3 @@ -+java.io.File=com.caucho.hessian.io.FileDeserializer -+java.math.BigDecimal=com.caucho.hessian.io.BigDecimalDeserializer -+javax.management.ObjectName=com.caucho.hessian.io.ObjectNameDeserializer -diff -uNr hessian-4.0.65-src/META-INF/hessian/serializers hessian-4.0.65-fix/META-INF/hessian/serializers ---- hessian-4.0.65-src/META-INF/hessian/serializers 1970-01-01 08:00:00.000000000 +0800 -+++ hessian-4.0.65-fix/META-INF/hessian/serializers 2023-08-15 18:39:22.000000000 +0800 -@@ -0,0 +1,6 @@ -+com.caucho.hessian.io.HessianRemoteObject=com.caucho.hessian.io.RemoteSerializer -+com.caucho.burlap.io.BurlapRemoteObject=com.caucho.hessian.io.RemoteSerializer -+java.io.File=com.caucho.hessian.io.StringValueSerializer -+java.math.BigDecimal=com.caucho.hessian.io.StringValueSerializer -+java.util.Locale=com.caucho.hessian.io.LocaleSerializer -+javax.management.ObjectName=com.caucho.hessian.io.StringValueSerializer -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapMetaInfoAPI.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapMetaInfoAPI.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapMetaInfoAPI.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapMetaInfoAPI.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,66 +1,66 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --/** -- * API retrieving burlap meta information. -- */ --public interface BurlapMetaInfoAPI { -- /** -- * Returns a service attribute. -- * -- *
    -- *
  • java.api.class - the Java interface for the object interface. -- *
  • java.ejb.home.class - the EJB home interface -- *
  • java.ejb.remote.class - the EJB remote interface -- *
  • java.primary.key.class - the EJB primary key class -- *
-- */ -- public Object _burlap_getAttribute(String name); --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+/** -+ * API retrieving burlap meta information. -+ */ -+public interface BurlapMetaInfoAPI { -+ /** -+ * Returns a service attribute. -+ * -+ *
    -+ *
  • java.api.class - the Java interface for the object interface. -+ *
  • java.ejb.home.class - the EJB home interface -+ *
  • java.ejb.remote.class - the EJB remote interface -+ *
  • java.primary.key.class - the EJB primary key class -+ *
-+ */ -+ public Object _burlap_getAttribute(String name); -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProtocolException.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProtocolException.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProtocolException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProtocolException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,102 +1,102 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --import java.io.IOException; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroBurlapInput. -- */ --public class BurlapProtocolException extends IOException { -- private Throwable rootCause; -- -- /** -- * Zero-arg constructor. -- */ -- public BurlapProtocolException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public BurlapProtocolException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public BurlapProtocolException(String message, Throwable rootCause) -- { -- super(message); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Create the exception. -- */ -- public BurlapProtocolException(Throwable rootCause) -- { -- super(String.valueOf(rootCause)); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getRootCause() -- { -- return rootCause; -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+import java.io.IOException; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroBurlapInput. -+ */ -+public class BurlapProtocolException extends IOException { -+ private Throwable rootCause; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public BurlapProtocolException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapProtocolException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapProtocolException(String message, Throwable rootCause) -+ { -+ super(message); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapProtocolException(Throwable rootCause) -+ { -+ super(String.valueOf(rootCause)); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getRootCause() -+ { -+ return rootCause; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxy.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxy.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxy.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxy.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,227 +1,227 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --import com.caucho.burlap.io.AbstractBurlapInput; --import com.caucho.burlap.io.BurlapOutput; -- --import java.io.FileNotFoundException; --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; --import java.lang.reflect.InvocationHandler; --import java.lang.reflect.Method; --import java.lang.reflect.Proxy; --import java.net.HttpURLConnection; --import java.net.URL; --import java.net.URLConnection; --import java.util.logging.*; -- --/** -- * Proxy implementation for Burlap clients. Applications will generally -- * use BurlapProxyFactory to create proxy clients. -- */ --public class BurlapProxy implements InvocationHandler { -- private static final Logger log -- = Logger.getLogger(BurlapProxy.class.getName()); -- -- private BurlapProxyFactory _factory; -- private URL _url; -- -- BurlapProxy(BurlapProxyFactory factory, URL url) -- { -- _factory = factory; -- _url = url; -- } -- -- /** -- * Returns the proxy's URL. -- */ -- public URL getURL() -- { -- return _url; -- } -- -- /** -- * Handles the object invocation. -- * -- * @param proxy the proxy object to invoke -- * @param method the method to call -- * @param args the arguments to the proxy object -- */ -- public Object invoke(Object proxy, Method method, Object []args) -- throws Throwable -- { -- String methodName = method.getName(); -- Class []params = method.getParameterTypes(); -- -- // equals and hashCode are special cased -- if (methodName.equals("equals") && -- params.length == 1 && params[0].equals(Object.class)) { -- Object value = args[0]; -- if (value == null || ! Proxy.isProxyClass(value.getClass())) -- return new Boolean(false); -- -- BurlapProxy handler = (BurlapProxy) Proxy.getInvocationHandler(value); -- -- return new Boolean(_url.equals(handler.getURL())); -- } -- else if (methodName.equals("hashCode") && params.length == 0) -- return new Integer(_url.hashCode()); -- else if (methodName.equals("getBurlapType")) -- return proxy.getClass().getInterfaces()[0].getName(); -- else if (methodName.equals("getBurlapURL")) -- return _url.toString(); -- else if (methodName.equals("toString") && params.length == 0) -- return getClass().getSimpleName() + "[" + _url + "]"; -- -- InputStream is = null; -- -- URLConnection conn = null; -- HttpURLConnection httpConn = null; -- try { -- conn = _factory.openConnection(_url); -- -- httpConn = (HttpURLConnection) conn; -- -- httpConn.setRequestMethod("POST"); -- conn.setRequestProperty("Content-Type", "text/xml"); -- -- OutputStream os; -- -- try { -- os = conn.getOutputStream(); -- } catch (Exception e) { -- throw new BurlapRuntimeException(e); -- } -- -- BurlapOutput out = _factory.getBurlapOutput(os); -- -- if (! _factory.isOverloadEnabled()) { -- } -- else if (args != null) -- methodName = methodName + "__" + args.length; -- else -- methodName = methodName + "__0"; -- -- if (log.isLoggable(Level.FINE)) -- log.fine(this + " calling " + methodName + " (" + method + ")"); -- -- out.call(methodName, args); -- -- try { -- os.flush(); -- } catch (Exception e) { -- throw new BurlapRuntimeException(e); -- } -- -- if (conn instanceof HttpURLConnection) { -- httpConn = (HttpURLConnection) conn; -- int code = 500; -- -- try { -- code = httpConn.getResponseCode(); -- } catch (Exception e) { -- } -- -- if (code != 200) { -- StringBuffer sb = new StringBuffer(); -- int ch; -- -- try { -- is = httpConn.getInputStream(); -- -- if (is != null) { -- while ((ch = is.read()) >= 0) -- sb.append((char) ch); -- -- is.close(); -- } -- -- is = httpConn.getErrorStream(); -- if (is != null) { -- while ((ch = is.read()) >= 0) -- sb.append((char) ch); -- } -- } catch (FileNotFoundException e) { -- throw new BurlapRuntimeException(code + ": " + String.valueOf(e)); -- } catch (IOException e) { -- } -- -- if (is != null) -- is.close(); -- -- throw new BurlapProtocolException(code + ": " + sb.toString()); -- } -- } -- -- is = conn.getInputStream(); -- -- AbstractBurlapInput in = _factory.getBurlapInput(is); -- -- return in.readReply(method.getReturnType()); -- } catch (BurlapProtocolException e) { -- throw new BurlapRuntimeException(e); -- } finally { -- try { -- if (is != null) -- is.close(); -- } catch (IOException e) { -- } -- -- if (httpConn != null) -- httpConn.disconnect(); -- } -- } -- -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _url + "]"; -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+import com.caucho.burlap.io.AbstractBurlapInput; -+import com.caucho.burlap.io.BurlapOutput; -+ -+import java.io.FileNotFoundException; -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.lang.reflect.InvocationHandler; -+import java.lang.reflect.Method; -+import java.lang.reflect.Proxy; -+import java.net.HttpURLConnection; -+import java.net.URL; -+import java.net.URLConnection; -+import java.util.logging.*; -+ -+/** -+ * Proxy implementation for Burlap clients. Applications will generally -+ * use BurlapProxyFactory to create proxy clients. -+ */ -+public class BurlapProxy implements InvocationHandler { -+ private static final Logger log -+ = Logger.getLogger(BurlapProxy.class.getName()); -+ -+ private BurlapProxyFactory _factory; -+ private URL _url; -+ -+ BurlapProxy(BurlapProxyFactory factory, URL url) -+ { -+ _factory = factory; -+ _url = url; -+ } -+ -+ /** -+ * Returns the proxy's URL. -+ */ -+ public URL getURL() -+ { -+ return _url; -+ } -+ -+ /** -+ * Handles the object invocation. -+ * -+ * @param proxy the proxy object to invoke -+ * @param method the method to call -+ * @param args the arguments to the proxy object -+ */ -+ public Object invoke(Object proxy, Method method, Object []args) -+ throws Throwable -+ { -+ String methodName = method.getName(); -+ Class []params = method.getParameterTypes(); -+ -+ // equals and hashCode are special cased -+ if (methodName.equals("equals") && -+ params.length == 1 && params[0].equals(Object.class)) { -+ Object value = args[0]; -+ if (value == null || ! Proxy.isProxyClass(value.getClass())) -+ return new Boolean(false); -+ -+ BurlapProxy handler = (BurlapProxy) Proxy.getInvocationHandler(value); -+ -+ return new Boolean(_url.equals(handler.getURL())); -+ } -+ else if (methodName.equals("hashCode") && params.length == 0) -+ return new Integer(_url.hashCode()); -+ else if (methodName.equals("getBurlapType")) -+ return proxy.getClass().getInterfaces()[0].getName(); -+ else if (methodName.equals("getBurlapURL")) -+ return _url.toString(); -+ else if (methodName.equals("toString") && params.length == 0) -+ return getClass().getSimpleName() + "[" + _url + "]"; -+ -+ InputStream is = null; -+ -+ URLConnection conn = null; -+ HttpURLConnection httpConn = null; -+ try { -+ conn = _factory.openConnection(_url); -+ -+ httpConn = (HttpURLConnection) conn; -+ -+ httpConn.setRequestMethod("POST"); -+ conn.setRequestProperty("Content-Type", "text/xml"); -+ -+ OutputStream os; -+ -+ try { -+ os = conn.getOutputStream(); -+ } catch (Exception e) { -+ throw new BurlapRuntimeException(e); -+ } -+ -+ BurlapOutput out = _factory.getBurlapOutput(os); -+ -+ if (! _factory.isOverloadEnabled()) { -+ } -+ else if (args != null) -+ methodName = methodName + "__" + args.length; -+ else -+ methodName = methodName + "__0"; -+ -+ if (log.isLoggable(Level.FINE)) -+ log.fine(this + " calling " + methodName + " (" + method + ")"); -+ -+ out.call(methodName, args); -+ -+ try { -+ os.flush(); -+ } catch (Exception e) { -+ throw new BurlapRuntimeException(e); -+ } -+ -+ if (conn instanceof HttpURLConnection) { -+ httpConn = (HttpURLConnection) conn; -+ int code = 500; -+ -+ try { -+ code = httpConn.getResponseCode(); -+ } catch (Exception e) { -+ } -+ -+ if (code != 200) { -+ StringBuffer sb = new StringBuffer(); -+ int ch; -+ -+ try { -+ is = httpConn.getInputStream(); -+ -+ if (is != null) { -+ while ((ch = is.read()) >= 0) -+ sb.append((char) ch); -+ -+ is.close(); -+ } -+ -+ is = httpConn.getErrorStream(); -+ if (is != null) { -+ while ((ch = is.read()) >= 0) -+ sb.append((char) ch); -+ } -+ } catch (FileNotFoundException e) { -+ throw new BurlapRuntimeException(code + ": " + String.valueOf(e)); -+ } catch (IOException e) { -+ } -+ -+ if (is != null) -+ is.close(); -+ -+ throw new BurlapProtocolException(code + ": " + sb.toString()); -+ } -+ } -+ -+ is = conn.getInputStream(); -+ -+ AbstractBurlapInput in = _factory.getBurlapInput(is); -+ -+ return in.readReply(method.getReturnType()); -+ } catch (BurlapProtocolException e) { -+ throw new BurlapRuntimeException(e); -+ } finally { -+ try { -+ if (is != null) -+ is.close(); -+ } catch (IOException e) { -+ } -+ -+ if (httpConn != null) -+ httpConn.disconnect(); -+ } -+ } -+ -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _url + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyFactory.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyFactory.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,384 +1,384 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --import com.caucho.burlap.io.AbstractBurlapInput; --import com.caucho.burlap.io.BurlapInput; --import com.caucho.burlap.io.BurlapOutput; --import com.caucho.burlap.io.BurlapRemoteObject; --import com.caucho.burlap.io.BurlapRemoteResolver; --import com.caucho.services.client.ServiceProxyFactory; -- --import javax.naming.Context; --import javax.naming.Name; --import javax.naming.NamingException; --import javax.naming.RefAddr; --import javax.naming.Reference; --import javax.naming.spi.ObjectFactory; --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; --import java.lang.reflect.Proxy; --import java.net.HttpURLConnection; --import java.net.MalformedURLException; --import java.net.URL; --import java.net.URLConnection; --import java.util.Hashtable; -- --/** -- * Factory for creating Burlap client stubs. The returned stub will -- * call the remote object for all methods. -- * -- *
-- * String url = "http://localhost:8080/ejb/hello";
-- * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-- * 
-- * -- * After creation, the stub can be like a regular Java class. Because -- * it makes remote calls, it can throw more exceptions than a Java class. -- * In particular, it may throw protocol exceptions. -- * -- * The factory can also be configured as a JNDI resource. The factory -- * expects to parameters: "type" and "url", corresponding to the two -- * arguments to create -- * -- * In Resin 3.0, the above example would be configured as: -- *
-- * <reference>
-- *   <name>hessian/hello</name>
-- *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
-- *   <init url="http://localhost:8080/ejb/hello"/>
-- *         type="test.HelloHome"/>
-- * </reference>
-- * 
-- * -- * To get the above resource, use JNDI as follows: -- *
-- * Context ic = new InitialContext();
-- * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/burlap/hello");
-- *
-- * System.out.println("Hello: " + hello.helloWorld());
-- * 
-- * -- *

Authentication

-- * -- *

The proxy can use HTTP basic authentication if the user and the -- * password are set. -- */ --public class BurlapProxyFactory implements ServiceProxyFactory, ObjectFactory { -- private BurlapRemoteResolver _resolver; -- -- private String _user; -- private String _password; -- private String _basicAuth; -- -- private long _readTimeout; -- private boolean _isOverloadEnabled = false; -- -- /** -- * Creates the new proxy factory. -- */ -- public BurlapProxyFactory() -- { -- _resolver = new BurlapProxyResolver(this); -- } -- -- /** -- * Sets the user. -- */ -- public void setUser(String user) -- { -- _user = user; -- _basicAuth = null; -- } -- -- /** -- * Sets the password. -- */ -- public void setPassword(String password) -- { -- _password = password; -- _basicAuth = null; -- } -- -- /** -- * Returns true if overloaded methods are allowed (using mangling) -- */ -- public boolean isOverloadEnabled() -- { -- return _isOverloadEnabled; -- } -- -- /** -- * set true if overloaded methods are allowed (using mangling) -- */ -- public void setOverloadEnabled(boolean isOverloadEnabled) -- { -- _isOverloadEnabled = isOverloadEnabled; -- } -- -- /** -- * Returns the remote resolver. -- */ -- public BurlapRemoteResolver getRemoteResolver() -- { -- return _resolver; -- } -- -- /** -- * Creates the URL connection. -- */ -- protected URLConnection openConnection(URL url) -- throws IOException -- { -- URLConnection conn = url.openConnection(); -- -- conn.setDoOutput(true); -- -- if (_basicAuth != null) -- conn.setRequestProperty("Authorization", _basicAuth); -- else if (_user != null && _password != null) { -- _basicAuth = "Basic " + base64(_user + ":" + _password); -- conn.setRequestProperty("Authorization", _basicAuth); -- } -- -- return conn; -- } -- -- /** -- * Creates a new proxy with the specified URL. The API class uses -- * the java.api.class value from _hessian_ -- * -- * @param url the URL where the client object is located. -- * -- * @return a proxy to the object with the specified interface. -- */ -- public Object create(String url) -- throws MalformedURLException, ClassNotFoundException -- { -- BurlapMetaInfoAPI metaInfo; -- -- metaInfo = (BurlapMetaInfoAPI) create(BurlapMetaInfoAPI.class, url); -- -- String apiClassName = -- (String) metaInfo._burlap_getAttribute("java.api.class"); -- -- if (apiClassName == null) -- throw new BurlapRuntimeException(url + " has an unknown api."); -- -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- -- Class apiClass = Class.forName(apiClassName, false, loader); -- -- return create(apiClass, url); -- } -- -- /** -- * Creates a new proxy with the specified URL. The returned object -- * is a proxy with the interface specified by api. -- * -- *

--   * String url = "http://localhost:8080/ejb/hello");
--   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
--   * 
-- * -- * @param api the interface the proxy class needs to implement -- * @param url the URL where the client object is located. -- * -- * @return a proxy to the object with the specified interface. -- */ -- public Object create(Class api, String urlName) -- throws MalformedURLException -- { -- if (api == null) -- throw new NullPointerException(); -- -- URL url = new URL(urlName); -- -- try { -- // clear old keepalive connections -- HttpURLConnection conn = (HttpURLConnection) url.openConnection(); -- -- conn.setConnectTimeout(10); -- conn.setReadTimeout(10); -- -- conn.setRequestProperty("Connection", "close"); -- -- InputStream is = conn.getInputStream(); -- -- is.close(); -- -- conn.disconnect(); -- } catch (IOException e) { -- } -- -- BurlapProxy handler = new BurlapProxy(this, url); -- -- return Proxy.newProxyInstance(api.getClassLoader(), -- new Class[] { api, -- BurlapRemoteObject.class }, -- handler); -- } -- -- public AbstractBurlapInput getBurlapInput(InputStream is) -- { -- AbstractBurlapInput in = new BurlapInput(is); -- in.setRemoteResolver(getRemoteResolver()); -- -- return in; -- } -- -- public BurlapOutput getBurlapOutput(OutputStream os) -- { -- BurlapOutput out = new BurlapOutput(os); -- -- return out; -- } -- -- /** -- * JNDI object factory so the proxy can be used as a resource. -- */ -- public Object getObjectInstance(Object obj, Name name, -- Context nameCtx, -- Hashtable environment) -- throws Exception -- { -- Reference ref = (Reference) obj; -- -- String api = null; -- String url = null; -- String user = null; -- String password = null; -- -- for (int i = 0; i < ref.size(); i++) { -- RefAddr addr = ref.get(i); -- -- String type = addr.getType(); -- String value = (String) addr.getContent(); -- -- if (type.equals("type")) -- api = value; -- else if (type.equals("url")) -- url = value; -- else if (type.equals("user")) -- setUser(value); -- else if (type.equals("password")) -- setPassword(value); -- } -- -- if (url == null) -- throw new NamingException("`url' must be configured for BurlapProxyFactory."); -- // XXX: could use meta protocol to grab this -- if (api == null) -- throw new NamingException("`type' must be configured for BurlapProxyFactory."); -- -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- Class apiClass = Class.forName(api, false, loader); -- -- return create(apiClass, url); -- } -- -- /** -- * Creates the Base64 value. -- */ -- private String base64(String value) -- { -- StringBuffer cb = new StringBuffer(); -- -- int i = 0; -- for (i = 0; i + 2 < value.length(); i += 3) { -- long chunk = (int) value.charAt(i); -- chunk = (chunk << 8) + (int) value.charAt(i + 1); -- chunk = (chunk << 8) + (int) value.charAt(i + 2); -- -- cb.append(encode(chunk >> 18)); -- cb.append(encode(chunk >> 12)); -- cb.append(encode(chunk >> 6)); -- cb.append(encode(chunk)); -- } -- -- if (i + 1 < value.length()) { -- long chunk = (int) value.charAt(i); -- chunk = (chunk << 8) + (int) value.charAt(i + 1); -- chunk <<= 8; -- -- cb.append(encode(chunk >> 18)); -- cb.append(encode(chunk >> 12)); -- cb.append(encode(chunk >> 6)); -- cb.append('='); -- } -- else if (i < value.length()) { -- long chunk = (int) value.charAt(i); -- chunk <<= 16; -- -- cb.append(encode(chunk >> 18)); -- cb.append(encode(chunk >> 12)); -- cb.append('='); -- cb.append('='); -- } -- -- return cb.toString(); -- } -- -- public static char encode(long d) -- { -- d &= 0x3f; -- if (d < 26) -- return (char) (d + 'A'); -- else if (d < 52) -- return (char) (d + 'a' - 26); -- else if (d < 62) -- return (char) (d + '0' - 52); -- else if (d == 62) -- return '+'; -- else -- return '/'; -- } --} -- -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+import com.caucho.burlap.io.AbstractBurlapInput; -+import com.caucho.burlap.io.BurlapInput; -+import com.caucho.burlap.io.BurlapOutput; -+import com.caucho.burlap.io.BurlapRemoteObject; -+import com.caucho.burlap.io.BurlapRemoteResolver; -+import com.caucho.services.client.ServiceProxyFactory; -+ -+import javax.naming.Context; -+import javax.naming.Name; -+import javax.naming.NamingException; -+import javax.naming.RefAddr; -+import javax.naming.Reference; -+import javax.naming.spi.ObjectFactory; -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.lang.reflect.Proxy; -+import java.net.HttpURLConnection; -+import java.net.MalformedURLException; -+import java.net.URL; -+import java.net.URLConnection; -+import java.util.Hashtable; -+ -+/** -+ * Factory for creating Burlap client stubs. The returned stub will -+ * call the remote object for all methods. -+ * -+ *
-+ * String url = "http://localhost:8080/ejb/hello";
-+ * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+ * 
-+ * -+ * After creation, the stub can be like a regular Java class. Because -+ * it makes remote calls, it can throw more exceptions than a Java class. -+ * In particular, it may throw protocol exceptions. -+ * -+ * The factory can also be configured as a JNDI resource. The factory -+ * expects to parameters: "type" and "url", corresponding to the two -+ * arguments to create -+ * -+ * In Resin 3.0, the above example would be configured as: -+ *
-+ * <reference>
-+ *   <name>hessian/hello</name>
-+ *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
-+ *   <init url="http://localhost:8080/ejb/hello"/>
-+ *         type="test.HelloHome"/>
-+ * </reference>
-+ * 
-+ * -+ * To get the above resource, use JNDI as follows: -+ *
-+ * Context ic = new InitialContext();
-+ * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/burlap/hello");
-+ *
-+ * System.out.println("Hello: " + hello.helloWorld());
-+ * 
-+ * -+ *

Authentication

-+ * -+ *

The proxy can use HTTP basic authentication if the user and the -+ * password are set. -+ */ -+public class BurlapProxyFactory implements ServiceProxyFactory, ObjectFactory { -+ private BurlapRemoteResolver _resolver; -+ -+ private String _user; -+ private String _password; -+ private String _basicAuth; -+ -+ private long _readTimeout; -+ private boolean _isOverloadEnabled = false; -+ -+ /** -+ * Creates the new proxy factory. -+ */ -+ public BurlapProxyFactory() -+ { -+ _resolver = new BurlapProxyResolver(this); -+ } -+ -+ /** -+ * Sets the user. -+ */ -+ public void setUser(String user) -+ { -+ _user = user; -+ _basicAuth = null; -+ } -+ -+ /** -+ * Sets the password. -+ */ -+ public void setPassword(String password) -+ { -+ _password = password; -+ _basicAuth = null; -+ } -+ -+ /** -+ * Returns true if overloaded methods are allowed (using mangling) -+ */ -+ public boolean isOverloadEnabled() -+ { -+ return _isOverloadEnabled; -+ } -+ -+ /** -+ * set true if overloaded methods are allowed (using mangling) -+ */ -+ public void setOverloadEnabled(boolean isOverloadEnabled) -+ { -+ _isOverloadEnabled = isOverloadEnabled; -+ } -+ -+ /** -+ * Returns the remote resolver. -+ */ -+ public BurlapRemoteResolver getRemoteResolver() -+ { -+ return _resolver; -+ } -+ -+ /** -+ * Creates the URL connection. -+ */ -+ protected URLConnection openConnection(URL url) -+ throws IOException -+ { -+ URLConnection conn = url.openConnection(); -+ -+ conn.setDoOutput(true); -+ -+ if (_basicAuth != null) -+ conn.setRequestProperty("Authorization", _basicAuth); -+ else if (_user != null && _password != null) { -+ _basicAuth = "Basic " + base64(_user + ":" + _password); -+ conn.setRequestProperty("Authorization", _basicAuth); -+ } -+ -+ return conn; -+ } -+ -+ /** -+ * Creates a new proxy with the specified URL. The API class uses -+ * the java.api.class value from _hessian_ -+ * -+ * @param url the URL where the client object is located. -+ * -+ * @return a proxy to the object with the specified interface. -+ */ -+ public Object create(String url) -+ throws MalformedURLException, ClassNotFoundException -+ { -+ BurlapMetaInfoAPI metaInfo; -+ -+ metaInfo = (BurlapMetaInfoAPI) create(BurlapMetaInfoAPI.class, url); -+ -+ String apiClassName = -+ (String) metaInfo._burlap_getAttribute("java.api.class"); -+ -+ if (apiClassName == null) -+ throw new BurlapRuntimeException(url + " has an unknown api."); -+ -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ -+ Class apiClass = Class.forName(apiClassName, false, loader); -+ -+ return create(apiClass, url); -+ } -+ -+ /** -+ * Creates a new proxy with the specified URL. The returned object -+ * is a proxy with the interface specified by api. -+ * -+ *

-+   * String url = "http://localhost:8080/ejb/hello");
-+   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+   * 
-+ * -+ * @param api the interface the proxy class needs to implement -+ * @param url the URL where the client object is located. -+ * -+ * @return a proxy to the object with the specified interface. -+ */ -+ public Object create(Class api, String urlName) -+ throws MalformedURLException -+ { -+ if (api == null) -+ throw new NullPointerException(); -+ -+ URL url = new URL(urlName); -+ -+ try { -+ // clear old keepalive connections -+ HttpURLConnection conn = (HttpURLConnection) url.openConnection(); -+ -+ conn.setConnectTimeout(10); -+ conn.setReadTimeout(10); -+ -+ conn.setRequestProperty("Connection", "close"); -+ -+ InputStream is = conn.getInputStream(); -+ -+ is.close(); -+ -+ conn.disconnect(); -+ } catch (IOException e) { -+ } -+ -+ BurlapProxy handler = new BurlapProxy(this, url); -+ -+ return Proxy.newProxyInstance(api.getClassLoader(), -+ new Class[] { api, -+ BurlapRemoteObject.class }, -+ handler); -+ } -+ -+ public AbstractBurlapInput getBurlapInput(InputStream is) -+ { -+ AbstractBurlapInput in = new BurlapInput(is); -+ in.setRemoteResolver(getRemoteResolver()); -+ -+ return in; -+ } -+ -+ public BurlapOutput getBurlapOutput(OutputStream os) -+ { -+ BurlapOutput out = new BurlapOutput(os); -+ -+ return out; -+ } -+ -+ /** -+ * JNDI object factory so the proxy can be used as a resource. -+ */ -+ public Object getObjectInstance(Object obj, Name name, -+ Context nameCtx, -+ Hashtable environment) -+ throws Exception -+ { -+ Reference ref = (Reference) obj; -+ -+ String api = null; -+ String url = null; -+ String user = null; -+ String password = null; -+ -+ for (int i = 0; i < ref.size(); i++) { -+ RefAddr addr = ref.get(i); -+ -+ String type = addr.getType(); -+ String value = (String) addr.getContent(); -+ -+ if (type.equals("type")) -+ api = value; -+ else if (type.equals("url")) -+ url = value; -+ else if (type.equals("user")) -+ setUser(value); -+ else if (type.equals("password")) -+ setPassword(value); -+ } -+ -+ if (url == null) -+ throw new NamingException("`url' must be configured for BurlapProxyFactory."); -+ // XXX: could use meta protocol to grab this -+ if (api == null) -+ throw new NamingException("`type' must be configured for BurlapProxyFactory."); -+ -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ Class apiClass = Class.forName(api, false, loader); -+ -+ return create(apiClass, url); -+ } -+ -+ /** -+ * Creates the Base64 value. -+ */ -+ private String base64(String value) -+ { -+ StringBuffer cb = new StringBuffer(); -+ -+ int i = 0; -+ for (i = 0; i + 2 < value.length(); i += 3) { -+ long chunk = (int) value.charAt(i); -+ chunk = (chunk << 8) + (int) value.charAt(i + 1); -+ chunk = (chunk << 8) + (int) value.charAt(i + 2); -+ -+ cb.append(encode(chunk >> 18)); -+ cb.append(encode(chunk >> 12)); -+ cb.append(encode(chunk >> 6)); -+ cb.append(encode(chunk)); -+ } -+ -+ if (i + 1 < value.length()) { -+ long chunk = (int) value.charAt(i); -+ chunk = (chunk << 8) + (int) value.charAt(i + 1); -+ chunk <<= 8; -+ -+ cb.append(encode(chunk >> 18)); -+ cb.append(encode(chunk >> 12)); -+ cb.append(encode(chunk >> 6)); -+ cb.append('='); -+ } -+ else if (i < value.length()) { -+ long chunk = (int) value.charAt(i); -+ chunk <<= 16; -+ -+ cb.append(encode(chunk >> 18)); -+ cb.append(encode(chunk >> 12)); -+ cb.append('='); -+ cb.append('='); -+ } -+ -+ return cb.toString(); -+ } -+ -+ public static char encode(long d) -+ { -+ d &= 0x3f; -+ if (d < 26) -+ return (char) (d + 'A'); -+ else if (d < 52) -+ return (char) (d + 'a' - 26); -+ else if (d < 62) -+ return (char) (d + '0' - 52); -+ else if (d == 62) -+ return '+'; -+ else -+ return '/'; -+ } -+} -+ -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyResolver.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyResolver.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapProxyResolver.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapProxyResolver.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,85 +1,85 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --import com.caucho.burlap.io.BurlapRemoteResolver; -- --import java.io.IOException; -- --/** -- * Looks up remote objects in the proxy. -- */ --public class BurlapProxyResolver implements BurlapRemoteResolver { -- private BurlapProxyFactory factory; -- -- /** -- * Creates an uninitialized Burlap remote resolver. -- */ -- public BurlapProxyResolver(BurlapProxyFactory factory) -- { -- this.factory = factory; -- } -- -- /** -- * Looks up a proxy object. -- */ -- public Object lookup(String type, String url) -- throws IOException -- { -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- -- try { -- Class api = Class.forName(type, false, loader); -- -- return factory.create(api, url); -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+import com.caucho.burlap.io.BurlapRemoteResolver; -+ -+import java.io.IOException; -+ -+/** -+ * Looks up remote objects in the proxy. -+ */ -+public class BurlapProxyResolver implements BurlapRemoteResolver { -+ private BurlapProxyFactory factory; -+ -+ /** -+ * Creates an uninitialized Burlap remote resolver. -+ */ -+ public BurlapProxyResolver(BurlapProxyFactory factory) -+ { -+ this.factory = factory; -+ } -+ -+ /** -+ * Looks up a proxy object. -+ */ -+ public Object lookup(String type, String url) -+ throws IOException -+ { -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ -+ try { -+ Class api = Class.forName(type, false, loader); -+ -+ return factory.create(api, url); -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapRemote.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRemote.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapRemote.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRemote.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,130 +1,130 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --/** -- * Encapsulates a remote address when no stub is available, e.g. for -- * Java MicroEdition. -- */ --public class BurlapRemote { -- private String type; -- private String url; -- -- /** -- * Creates a new Burlap remote object. -- * -- * @param type the remote stub interface -- * @param url the remote url -- */ -- public BurlapRemote(String type, String url) -- { -- this.type = type; -- this.url = url; -- } -- -- /** -- * Creates an uninitialized Burlap remote. -- */ -- public BurlapRemote() -- { -- } -- -- /** -- * Returns the remote api class name. -- */ -- public String getType() -- { -- return type; -- } -- -- /** -- * Returns the remote URL. -- */ -- public String getURL() -- { -- return url; -- } -- -- /** -- * Sets the remote URL. -- */ -- public void setURL(String url) -- { -- this.url = url; -- } -- -- /** -- * Defines the hashcode. -- */ -- public int hashCode() -- { -- return url.hashCode(); -- } -- -- /** -- * Defines equality -- */ -- public boolean equals(Object obj) -- { -- if (! (obj instanceof BurlapRemote)) -- return false; -- -- BurlapRemote remote = (BurlapRemote) obj; -- -- return url.equals(remote.url); -- } -- -- /** -- * Readable version of the remote. -- */ -- public String toString() -- { -- return "[Remote " + url + "]"; -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+/** -+ * Encapsulates a remote address when no stub is available, e.g. for -+ * Java MicroEdition. -+ */ -+public class BurlapRemote { -+ private String type; -+ private String url; -+ -+ /** -+ * Creates a new Burlap remote object. -+ * -+ * @param type the remote stub interface -+ * @param url the remote url -+ */ -+ public BurlapRemote(String type, String url) -+ { -+ this.type = type; -+ this.url = url; -+ } -+ -+ /** -+ * Creates an uninitialized Burlap remote. -+ */ -+ public BurlapRemote() -+ { -+ } -+ -+ /** -+ * Returns the remote api class name. -+ */ -+ public String getType() -+ { -+ return type; -+ } -+ -+ /** -+ * Returns the remote URL. -+ */ -+ public String getURL() -+ { -+ return url; -+ } -+ -+ /** -+ * Sets the remote URL. -+ */ -+ public void setURL(String url) -+ { -+ this.url = url; -+ } -+ -+ /** -+ * Defines the hashcode. -+ */ -+ public int hashCode() -+ { -+ return url.hashCode(); -+ } -+ -+ /** -+ * Defines equality -+ */ -+ public boolean equals(Object obj) -+ { -+ if (! (obj instanceof BurlapRemote)) -+ return false; -+ -+ BurlapRemote remote = (BurlapRemote) obj; -+ -+ return url.equals(remote.url); -+ } -+ -+ /** -+ * Readable version of the remote. -+ */ -+ public String toString() -+ { -+ return "[Remote " + url + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapRuntimeException.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRuntimeException.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapRuntimeException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapRuntimeException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,107 +1,107 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --/** -- * Wrapper for protocol exceptions thrown in the proxy. -- */ --public class BurlapRuntimeException extends RuntimeException { -- private Throwable rootCause; -- -- /** -- * Zero-arg constructor. -- */ -- public BurlapRuntimeException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public BurlapRuntimeException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public BurlapRuntimeException(String message, Throwable rootCause) -- { -- super(message); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Create the exception. -- */ -- public BurlapRuntimeException(Throwable rootCause) -- { -- super(String.valueOf(rootCause)); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getRootCause() -- { -- return this.rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getCause() -- { -- return this.rootCause; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+/** -+ * Wrapper for protocol exceptions thrown in the proxy. -+ */ -+public class BurlapRuntimeException extends RuntimeException { -+ private Throwable rootCause; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public BurlapRuntimeException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapRuntimeException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapRuntimeException(String message, Throwable rootCause) -+ { -+ super(message); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapRuntimeException(Throwable rootCause) -+ { -+ super(String.valueOf(rootCause)); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getRootCause() -+ { -+ return this.rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getCause() -+ { -+ return this.rootCause; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/BurlapServiceException.java hessian-4.0.65-fix/com/caucho/burlap/client/BurlapServiceException.java ---- hessian-4.0.65-src/com/caucho/burlap/client/BurlapServiceException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/BurlapServiceException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,91 +1,91 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroBurlapInput. -- */ --public class BurlapServiceException extends Exception { -- private String code; -- private Object detail; -- -- /** -- * Zero-arg constructor. -- */ -- public BurlapServiceException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public BurlapServiceException(String message, String code, Object detail) -- { -- super(message); -- this.code = code; -- this.detail = detail; -- } -- -- /** -- * Returns the code. -- */ -- public String getCode() -- { -- return code; -- } -- -- /** -- * Returns the detail. -- */ -- public Object getDetail() -- { -- return detail; -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroBurlapInput. -+ */ -+public class BurlapServiceException extends Exception { -+ private String code; -+ private Object detail; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public BurlapServiceException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapServiceException(String message, String code, Object detail) -+ { -+ super(message); -+ this.code = code; -+ this.detail = detail; -+ } -+ -+ /** -+ * Returns the code. -+ */ -+ public String getCode() -+ { -+ return code; -+ } -+ -+ /** -+ * Returns the detail. -+ */ -+ public Object getDetail() -+ { -+ return detail; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapInput.java hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapInput.java ---- hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,1031 +1,1031 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --import java.io.ByteArrayOutputStream; --import java.io.IOException; --import java.io.InputStream; --import java.util.Calendar; --import java.util.Date; --import java.util.Hashtable; --import java.util.TimeZone; --import java.util.Vector; -- --/** -- * Input stream for Burlap requests, compatible with microedition -- * Java. It only uses classes and types available to J2ME. In -- * particular, it does not have any support for the <double> type. -- * -- *

MicroBurlapInput does not depend on any classes other than -- * in J2ME, so it can be extracted independently into a smaller package. -- * -- *

MicroBurlapInput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * InputStream is = ...; // from http connection
-- * MicroBurlapInput in = new MicroBurlapInput(is);
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --public class MicroBurlapInput { -- private static int base64Decode[]; -- -- private InputStream is; -- protected int peek; -- protected boolean peekTag; -- protected Date date; -- protected Calendar utcCalendar; -- private Calendar localCalendar; -- protected Vector refs; -- protected String method; -- protected StringBuffer sbuf = new StringBuffer(); -- protected StringBuffer entity = new StringBuffer(); -- -- /** -- * Creates a new Burlap input stream, initialized with an -- * underlying input stream. -- * -- * @param is the underlying input stream. -- */ -- public MicroBurlapInput(InputStream is) -- { -- init(is); -- } -- -- /** -- * Creates an uninitialized Burlap input stream. -- */ -- public MicroBurlapInput() -- { -- } -- -- /** -- * Returns a call's method. -- */ -- public String getMethod() -- { -- return method; -- } -- -- /** -- * Initialize the Burlap input stream with a new underlying stream. -- * Applications can use init(InputStream) to reuse -- * MicroBurlapInput to save garbage collection. -- */ -- public void init(InputStream is) -- { -- this.is = is; -- this.refs = null; -- } -- -- /** -- * Starts reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * <burlap:call>
--   * <method>method</method>
--   * 
-- */ -- public void startCall() -- throws IOException -- { -- expectStartTag("burlap:call"); -- expectStartTag("method"); -- method = parseString(); -- expectEndTag("method"); -- this.refs = null; -- } -- -- /** -- * Completes reading the call. -- * -- *
--   * </burlap:call>
--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- expectEndTag("burlap:call"); -- } -- -- /** -- * Reads a reply as an object. -- * If the reply has a fault, throws the exception. -- */ -- public Object readReply(Class expectedClass) -- throws Exception -- { -- if (startReply()) { -- Object value = readObject(expectedClass); -- completeReply(); -- return value; -- } -- else { -- Hashtable fault = readFault(); -- -- Object detail = fault.get("detail"); -- if (detail instanceof Exception) -- throw (Exception) detail; -- -- else { -- String code = (String) fault.get("code"); -- String message = (String) fault.get("message"); -- -- throw new BurlapServiceException(message, code, detail); -- } -- } -- } -- -- /** -- * Starts reading the reply. -- * -- *

A successful completion will have a single value. An unsuccessful -- * one will have a fault: -- * -- *

--   * <burlap:reply>
--   * 
-- * -- * @return true if success, false for fault. -- */ -- public boolean startReply() -- throws IOException -- { -- this.refs = null; -- -- expectStartTag("burlap:reply"); -- -- if (! parseTag()) -- throw new BurlapProtocolException("expected "); -- -- String tag = sbuf.toString(); -- if (tag.equals("fault")) { -- peekTag = true; -- return false; -- } -- else { -- peekTag = true; -- return true; -- } -- } -- -- /** -- * Completes reading the reply. -- * -- *
--   * </burlap:reply>
--   * 
-- */ -- public void completeReply() -- throws IOException -- { -- expectEndTag("burlap:reply"); -- } -- -- /** -- * Reads a boolean value from the input stream. -- */ -- public boolean readBoolean() -- throws IOException -- { -- expectStartTag("boolean"); -- -- int value = parseInt(); -- -- expectEndTag("boolean"); -- -- return value != 0; -- } -- -- /** -- * Reads an integer value from the input stream. -- */ -- public int readInt() -- throws IOException -- { -- expectStartTag("int"); -- -- int value = parseInt(); -- -- expectEndTag("int"); -- -- return value; -- } -- -- /** -- * Reads a long value from the input stream. -- */ -- public long readLong() -- throws IOException -- { -- expectStartTag("long"); -- -- long value = parseLong(); -- -- expectEndTag("long"); -- -- return value; -- } -- -- /** -- * Reads a date value from the input stream. -- */ -- public long readUTCDate() -- throws IOException -- { -- expectStartTag("date"); -- -- if (utcCalendar == null) -- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -- -- long value = parseDate(utcCalendar); -- -- expectEndTag("date"); -- -- return value; -- } -- -- /** -- * Reads a date value from the input stream. -- */ -- public long readLocalDate() -- throws IOException -- { -- expectStartTag("date"); -- -- if (localCalendar == null) -- localCalendar = Calendar.getInstance(); -- -- long value = parseDate(localCalendar); -- -- expectEndTag("date"); -- -- return value; -- } -- -- /** -- * Reads a remote value from the input stream. -- */ -- public BurlapRemote readRemote() -- throws IOException -- { -- expectStartTag("remote"); -- -- String type = readType(); -- String url = readString(); -- -- expectEndTag("remote"); -- -- return new BurlapRemote(type, url); -- } -- -- /** -- * Reads a string value from the input stream. -- * -- *

The two valid possibilities are either a <null> -- * or a <string>. The string value is encoded in utf-8, and -- * understands the basic XML escapes: "&123;", "<", ">", -- * "'", """. -- * -- *

--   * <null></null>
--   * <string>a utf-8 encoded string</string>
--   * 
-- */ -- public String readString() -- throws IOException -- { -- if (! parseTag()) -- throw new BurlapProtocolException("expected "); -- -- String tag = sbuf.toString(); -- if (tag.equals("null")) { -- expectEndTag("null"); -- return null; -- } -- else if (tag.equals("string")) { -- sbuf.setLength(0); -- parseString(sbuf); -- String value = sbuf.toString(); -- expectEndTag("string"); -- return value; -- } -- else -- throw expectBeginTag("string", tag); -- } -- -- /** -- * Reads a byte array from the input stream. -- * -- *

The two valid possibilities are either a <null> -- * or a <base64>. -- */ -- public byte []readBytes() -- throws IOException -- { -- if (! parseTag()) -- throw new BurlapProtocolException("expected "); -- -- String tag = sbuf.toString(); -- if (tag.equals("null")) { -- expectEndTag("null"); -- return null; -- } -- else if (tag.equals("base64")) { -- sbuf.setLength(0); -- byte []value = parseBytes(); -- expectEndTag("base64"); -- return value; -- } -- else -- throw expectBeginTag("base64", tag); -- } -- -- /** -- * Reads an arbitrary object the input stream. -- */ -- public Object readObject(Class expectedClass) -- throws IOException -- { -- if (! parseTag()) -- throw new BurlapProtocolException("expected "); -- -- String tag = sbuf.toString(); -- if (tag.equals("null")) { -- expectEndTag("null"); -- return null; -- } -- else if (tag.equals("boolean")) { -- int value = parseInt(); -- expectEndTag("boolean"); -- return new Boolean(value != 0); -- } -- else if (tag.equals("int")) { -- int value = parseInt(); -- expectEndTag("int"); -- return new Integer(value); -- } -- else if (tag.equals("long")) { -- long value = parseLong(); -- expectEndTag("long"); -- return new Long(value); -- } -- else if (tag.equals("string")) { -- sbuf.setLength(0); -- parseString(sbuf); -- String value = sbuf.toString(); -- expectEndTag("string"); -- return value; -- } -- else if (tag.equals("xml")) { -- sbuf.setLength(0); -- parseString(sbuf); -- String value = sbuf.toString(); -- expectEndTag("xml"); -- return value; -- } -- else if (tag.equals("date")) { -- if (utcCalendar == null) -- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -- -- long value = parseDate(utcCalendar); -- expectEndTag("date"); -- return new Date(value); -- } -- else if (tag.equals("map")) { -- String type = readType(); -- -- return readMap(expectedClass, type); -- } -- else if (tag.equals("list")) { -- String type = readType(); -- -- int length = readLength(); -- -- return readList(expectedClass, type, length); -- } -- else if (tag.equals("ref")) { -- int value = parseInt(); -- expectEndTag("ref"); -- -- return refs.elementAt(value); -- } -- else if (tag.equals("remote")) { -- String type = readType(); -- String url = readString(); -- -- expectEndTag("remote"); -- -- return resolveRemote(type, url); -- } -- else -- return readExtensionObject(expectedClass, tag); -- } -- -- /** -- * Reads a type value from the input stream. -- * -- *

--   * <type>a utf-8 encoded string</type>
--   * 
-- */ -- public String readType() -- throws IOException -- { -- if (! parseTag()) -- throw new BurlapProtocolException("expected "); -- -- String tag = sbuf.toString(); -- if (! tag.equals("type")) -- throw new BurlapProtocolException("expected "); -- -- sbuf.setLength(0); -- parseString(sbuf); -- String value = sbuf.toString(); -- expectEndTag("type"); -- -- return value; -- } -- -- /** -- * Reads a length value from the input stream. If the length isn't -- * specified, returns -1. -- * -- *
--   * <length>integer</length>
--   * 
-- */ -- public int readLength() -- throws IOException -- { -- expectStartTag("length"); -- -- int ch = skipWhitespace(); -- -- peek = ch; -- -- if (ch == '<') { -- expectEndTag("length"); -- return -1; -- } -- -- int value = parseInt(); -- -- expectEndTag("length"); -- -- return value; -- } -- -- /** -- * Resolves a remote object. -- */ -- public Object resolveRemote(String type, String url) -- throws IOException -- { -- return new BurlapRemote(type, url); -- } -- -- /** -- * Reads a fault. -- */ -- public Hashtable readFault() -- throws IOException -- { -- expectStartTag("fault"); -- -- Hashtable map = new Hashtable(); -- -- while (parseTag()) { -- peekTag = true; -- Object key = readObject(null); -- Object value = readObject(null); -- -- if (key != null && value != null) -- map.put(key, value); -- } -- -- if (! sbuf.toString().equals("fault")) -- throw new BurlapProtocolException("expected "); -- -- return map; -- } -- -- /** -- * Reads an object from the input stream. -- * -- * @param expectedClass the calling routine's expected class -- * @param type the type from the stream -- */ -- public Object readMap(Class expectedClass, String type) -- throws IOException -- { -- Hashtable map = new Hashtable(); -- if (refs == null) -- refs = new Vector(); -- refs.addElement(map); -- -- while (parseTag()) { -- peekTag = true; -- Object key = readObject(null); -- Object value = readObject(null); -- -- map.put(key, value); -- } -- if (! sbuf.toString().equals("map")) -- throw new BurlapProtocolException("expected "); -- -- return map; -- } -- -- /** -- * Reads object unknown to MicroBurlapInput. -- */ -- protected Object readExtensionObject(Class expectedClass, String tag) -- throws IOException -- { -- throw new BurlapProtocolException("unknown object tag <" + tag + ">"); -- } -- -- /** -- * Reads a list object from the input stream. -- * -- * @param expectedClass the calling routine's expected class -- * @param type the type from the stream -- * @param length the expected length, -1 for unspecified length -- */ -- public Object readList(Class expectedClass, String type, int length) -- throws IOException -- { -- Vector list = new Vector(); -- if (refs == null) -- refs = new Vector(); -- refs.addElement(list); -- -- while (parseTag()) { -- peekTag = true; -- Object value = readObject(null); -- -- list.addElement(value); -- } -- -- if (! sbuf.toString().equals("list")) -- throw new BurlapProtocolException("expected "); -- -- return list; -- } -- -- /** -- * Parses an integer value from the stream. -- */ -- protected int parseInt() -- throws IOException -- { -- int sign = 1; -- int value = 0; -- -- int ch = skipWhitespace(); -- if (ch == '+') -- ch = read(); -- else if (ch == '-') { -- sign = -1; -- ch = read(); -- } -- -- for (; ch >= '0' && ch <= '9'; ch = read()) -- value = 10 * value + ch - '0'; -- -- peek = ch; -- -- return sign * value; -- } -- -- /** -- * Parses a long value from the stream. -- */ -- protected long parseLong() -- throws IOException -- { -- long sign = 1; -- long value = 0; -- -- int ch = skipWhitespace(); -- if (ch == '+') -- ch = read(); -- else if (ch == '-') { -- sign = -1; -- ch = read(); -- } -- -- for (; ch >= '0' && ch <= '9'; ch = read()) { -- value = 10 * value + ch - '0'; -- } -- -- peek = ch; -- -- return sign * value; -- } -- -- /** -- * Parses a date value from the stream. -- */ -- protected long parseDate(Calendar calendar) -- throws IOException -- { -- int ch = skipWhitespace(); -- -- int year = 0; -- for (int i = 0; i < 4; i++) { -- if (ch >= '0' && ch <= '9') -- year = 10 * year + ch - '0'; -- else -- throw expectedChar("year", ch); -- -- ch = read(); -- } -- -- int month = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- month = 10 * month + ch - '0'; -- else -- throw expectedChar("month", ch); -- -- ch = read(); -- } -- -- int day = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- day = 10 * day + ch - '0'; -- else -- throw expectedChar("day", ch); -- -- ch = read(); -- } -- -- if (ch != 'T') -- throw expectedChar("`T'", ch); -- -- ch = read(); -- -- int hour = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- hour = 10 * hour + ch - '0'; -- else -- throw expectedChar("hour", ch); -- -- ch = read(); -- } -- -- int minute = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- minute = 10 * minute + ch - '0'; -- else -- throw expectedChar("minute", ch); -- -- ch = read(); -- } -- -- int second = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- second = 10 * second + ch - '0'; -- else -- throw expectedChar("second", ch); -- -- ch = read(); -- } -- -- for (; ch > 0 && ch != '<'; ch = read()) { -- } -- -- peek = ch; -- -- calendar.set(Calendar.YEAR, year); -- calendar.set(Calendar.MONTH, month - 1); -- calendar.set(Calendar.DAY_OF_MONTH, day); -- calendar.set(Calendar.HOUR_OF_DAY, hour); -- calendar.set(Calendar.MINUTE, minute); -- calendar.set(Calendar.SECOND, second); -- calendar.set(Calendar.MILLISECOND, 0); -- -- return calendar.getTime().getTime(); -- } -- -- /** -- * Parses a string value from the stream. -- * string buffer is used for the result. -- */ -- protected String parseString() -- throws IOException -- { -- StringBuffer sbuf = new StringBuffer(); -- -- return parseString(sbuf).toString(); -- } -- -- /** -- * Parses a string value from the stream. The burlap object's -- * string buffer is used for the result. -- */ -- protected StringBuffer parseString(StringBuffer sbuf) -- throws IOException -- { -- int ch = read(); -- -- for (; ch >= 0 && ch != '<'; ch = read()) { -- if (ch == '&') { -- ch = read(); -- -- if (ch == '#') { -- ch = read(); -- -- if (ch >= '0' && ch <= '9') { -- int v = 0; -- for (; ch >= '0' && ch <= '9'; ch = read()) { -- v = 10 * v + ch - '0'; -- } -- -- sbuf.append((char) v); -- } -- } -- else { -- StringBuffer entityBuffer = new StringBuffer(); -- -- for (; ch >= 'a' && ch <= 'z'; ch = read()) -- entityBuffer.append((char) ch); -- -- String entity = entityBuffer.toString(); -- if (entity.equals("amp")) -- sbuf.append('&'); -- else if (entity.equals("apos")) -- sbuf.append('\''); -- else if (entity.equals("quot")) -- sbuf.append('"'); -- else if (entity.equals("lt")) -- sbuf.append('<'); -- else if (entity.equals("gt")) -- sbuf.append('>'); -- else -- throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); -- } -- -- if (ch != ';') -- throw expectedChar("';'", ch); -- } -- else if (ch < 0x80) -- sbuf.append((char) ch); -- else if ((ch & 0xe0) == 0xc0) { -- int ch1 = read(); -- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -- -- sbuf.append((char) v); -- } -- else if ((ch & 0xf0) == 0xe0) { -- int ch1 = read(); -- int ch2 = read(); -- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -- -- sbuf.append((char) v); -- } -- else -- throw new BurlapProtocolException("bad utf-8 encoding"); -- } -- -- peek = ch; -- -- return sbuf; -- } -- -- /** -- * Parses a byte array. -- */ -- protected byte []parseBytes() -- throws IOException -- { -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- parseBytes(bos); -- -- return bos.toByteArray(); -- } -- -- /** -- * Parses a byte array. -- */ -- protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) -- throws IOException -- { -- int ch; -- for (ch = read(); ch >= 0 && ch != '<'; ch = read()) { -- int b1 = ch; -- int b2 = read(); -- int b3 = read(); -- int b4 = read(); -- -- if (b4 != '=') { -- int chunk = ((base64Decode[b1] << 18) + -- (base64Decode[b2] << 12) + -- (base64Decode[b3] << 6) + -- (base64Decode[b4])); -- -- bos.write(chunk >> 16); -- bos.write(chunk >> 8); -- bos.write(chunk); -- } -- else if (b3 != '=') { -- int chunk = ((base64Decode[b1] << 12) + -- (base64Decode[b2] << 6) + -- (base64Decode[b3])); -- -- bos.write(chunk >> 8); -- bos.write(chunk); -- } -- else { -- int chunk = ((base64Decode[b1] << 6) + -- (base64Decode[b2])); -- -- bos.write(chunk); -- } -- } -- -- if (ch == '<') -- peek = ch; -- -- return bos; -- } -- -- protected void expectStartTag(String tag) -- throws IOException -- { -- if (! parseTag()) -- throw new BurlapProtocolException("expected <" + tag + ">"); -- -- if (! sbuf.toString().equals(tag)) -- throw new BurlapProtocolException("expected <" + tag + "> at <" + sbuf + ">"); -- } -- -- protected void expectEndTag(String tag) -- throws IOException -- { -- if (parseTag()) -- throw new BurlapProtocolException("expected "); -- -- if (! sbuf.toString().equals(tag)) -- throw new BurlapProtocolException("expected at "); -- } -- -- /** -- * Parses a tag. Returns true if it's a start tag. -- */ -- protected boolean parseTag() -- throws IOException -- { -- if (peekTag) { -- peekTag = false; -- return true; -- } -- -- int ch = skipWhitespace(); -- boolean isStartTag = true; -- -- if (ch != '<') -- throw expectedChar("'<'", ch); -- -- ch = read(); -- if (ch == '/') { -- isStartTag = false; -- ch = is.read(); -- } -- -- if (! isTagChar(ch)) -- throw expectedChar("tag", ch); -- -- sbuf.setLength(0); -- for (; isTagChar(ch); ch = read()) -- sbuf.append((char) ch); -- -- if (ch != '>') -- throw expectedChar("'>'", ch); -- -- return isStartTag; -- } -- -- protected IOException expectedChar(String expect, int actualChar) -- { -- return new BurlapProtocolException("expected " + expect + " at " + -- (char) actualChar + "'"); -- } -- -- protected IOException expectBeginTag(String expect, String tag) -- { -- return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); -- } -- -- private boolean isTagChar(int ch) -- { -- return (ch >= 'a' && ch <= 'z' || -- ch >= 'A' && ch <= 'Z' || -- ch >= '0' && ch <= '9' || -- ch == ':' || ch == '-'); -- } -- -- protected int skipWhitespace() -- throws IOException -- { -- int ch = read(); -- -- for (; -- ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -- ch = read()) { -- } -- -- return ch; -- } -- -- protected boolean isWhitespace(int ch) -- throws IOException -- { -- return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -- } -- -- protected int read() -- throws IOException -- { -- if (peek > 0) { -- int value = peek; -- peek = 0; -- return value; -- } -- -- return is.read(); -- } -- -- static { -- base64Decode = new int[256]; -- for (int i = 'A'; i <= 'Z'; i++) -- base64Decode[i] = i - 'A'; -- for (int i = 'a'; i <= 'z'; i++) -- base64Decode[i] = i - 'a' + 26; -- for (int i = '0'; i <= '9'; i++) -- base64Decode[i] = i - '0' + 52; -- base64Decode['+'] = 62; -- base64Decode['/'] = 63; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+import java.io.ByteArrayOutputStream; -+import java.io.IOException; -+import java.io.InputStream; -+import java.util.Calendar; -+import java.util.Date; -+import java.util.Hashtable; -+import java.util.TimeZone; -+import java.util.Vector; -+ -+/** -+ * Input stream for Burlap requests, compatible with microedition -+ * Java. It only uses classes and types available to J2ME. In -+ * particular, it does not have any support for the <double> type. -+ * -+ *

MicroBurlapInput does not depend on any classes other than -+ * in J2ME, so it can be extracted independently into a smaller package. -+ * -+ *

MicroBurlapInput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * InputStream is = ...; // from http connection
-+ * MicroBurlapInput in = new MicroBurlapInput(is);
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+public class MicroBurlapInput { -+ private static int base64Decode[]; -+ -+ private InputStream is; -+ protected int peek; -+ protected boolean peekTag; -+ protected Date date; -+ protected Calendar utcCalendar; -+ private Calendar localCalendar; -+ protected Vector refs; -+ protected String method; -+ protected StringBuffer sbuf = new StringBuffer(); -+ protected StringBuffer entity = new StringBuffer(); -+ -+ /** -+ * Creates a new Burlap input stream, initialized with an -+ * underlying input stream. -+ * -+ * @param is the underlying input stream. -+ */ -+ public MicroBurlapInput(InputStream is) -+ { -+ init(is); -+ } -+ -+ /** -+ * Creates an uninitialized Burlap input stream. -+ */ -+ public MicroBurlapInput() -+ { -+ } -+ -+ /** -+ * Returns a call's method. -+ */ -+ public String getMethod() -+ { -+ return method; -+ } -+ -+ /** -+ * Initialize the Burlap input stream with a new underlying stream. -+ * Applications can use init(InputStream) to reuse -+ * MicroBurlapInput to save garbage collection. -+ */ -+ public void init(InputStream is) -+ { -+ this.is = is; -+ this.refs = null; -+ } -+ -+ /** -+ * Starts reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * <burlap:call>
-+   * <method>method</method>
-+   * 
-+ */ -+ public void startCall() -+ throws IOException -+ { -+ expectStartTag("burlap:call"); -+ expectStartTag("method"); -+ method = parseString(); -+ expectEndTag("method"); -+ this.refs = null; -+ } -+ -+ /** -+ * Completes reading the call. -+ * -+ *
-+   * </burlap:call>
-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ expectEndTag("burlap:call"); -+ } -+ -+ /** -+ * Reads a reply as an object. -+ * If the reply has a fault, throws the exception. -+ */ -+ public Object readReply(Class expectedClass) -+ throws Exception -+ { -+ if (startReply()) { -+ Object value = readObject(expectedClass); -+ completeReply(); -+ return value; -+ } -+ else { -+ Hashtable fault = readFault(); -+ -+ Object detail = fault.get("detail"); -+ if (detail instanceof Exception) -+ throw (Exception) detail; -+ -+ else { -+ String code = (String) fault.get("code"); -+ String message = (String) fault.get("message"); -+ -+ throw new BurlapServiceException(message, code, detail); -+ } -+ } -+ } -+ -+ /** -+ * Starts reading the reply. -+ * -+ *

A successful completion will have a single value. An unsuccessful -+ * one will have a fault: -+ * -+ *

-+   * <burlap:reply>
-+   * 
-+ * -+ * @return true if success, false for fault. -+ */ -+ public boolean startReply() -+ throws IOException -+ { -+ this.refs = null; -+ -+ expectStartTag("burlap:reply"); -+ -+ if (! parseTag()) -+ throw new BurlapProtocolException("expected "); -+ -+ String tag = sbuf.toString(); -+ if (tag.equals("fault")) { -+ peekTag = true; -+ return false; -+ } -+ else { -+ peekTag = true; -+ return true; -+ } -+ } -+ -+ /** -+ * Completes reading the reply. -+ * -+ *
-+   * </burlap:reply>
-+   * 
-+ */ -+ public void completeReply() -+ throws IOException -+ { -+ expectEndTag("burlap:reply"); -+ } -+ -+ /** -+ * Reads a boolean value from the input stream. -+ */ -+ public boolean readBoolean() -+ throws IOException -+ { -+ expectStartTag("boolean"); -+ -+ int value = parseInt(); -+ -+ expectEndTag("boolean"); -+ -+ return value != 0; -+ } -+ -+ /** -+ * Reads an integer value from the input stream. -+ */ -+ public int readInt() -+ throws IOException -+ { -+ expectStartTag("int"); -+ -+ int value = parseInt(); -+ -+ expectEndTag("int"); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a long value from the input stream. -+ */ -+ public long readLong() -+ throws IOException -+ { -+ expectStartTag("long"); -+ -+ long value = parseLong(); -+ -+ expectEndTag("long"); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a date value from the input stream. -+ */ -+ public long readUTCDate() -+ throws IOException -+ { -+ expectStartTag("date"); -+ -+ if (utcCalendar == null) -+ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -+ -+ long value = parseDate(utcCalendar); -+ -+ expectEndTag("date"); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a date value from the input stream. -+ */ -+ public long readLocalDate() -+ throws IOException -+ { -+ expectStartTag("date"); -+ -+ if (localCalendar == null) -+ localCalendar = Calendar.getInstance(); -+ -+ long value = parseDate(localCalendar); -+ -+ expectEndTag("date"); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a remote value from the input stream. -+ */ -+ public BurlapRemote readRemote() -+ throws IOException -+ { -+ expectStartTag("remote"); -+ -+ String type = readType(); -+ String url = readString(); -+ -+ expectEndTag("remote"); -+ -+ return new BurlapRemote(type, url); -+ } -+ -+ /** -+ * Reads a string value from the input stream. -+ * -+ *

The two valid possibilities are either a <null> -+ * or a <string>. The string value is encoded in utf-8, and -+ * understands the basic XML escapes: "&123;", "<", ">", -+ * "'", """. -+ * -+ *

-+   * <null></null>
-+   * <string>a utf-8 encoded string</string>
-+   * 
-+ */ -+ public String readString() -+ throws IOException -+ { -+ if (! parseTag()) -+ throw new BurlapProtocolException("expected "); -+ -+ String tag = sbuf.toString(); -+ if (tag.equals("null")) { -+ expectEndTag("null"); -+ return null; -+ } -+ else if (tag.equals("string")) { -+ sbuf.setLength(0); -+ parseString(sbuf); -+ String value = sbuf.toString(); -+ expectEndTag("string"); -+ return value; -+ } -+ else -+ throw expectBeginTag("string", tag); -+ } -+ -+ /** -+ * Reads a byte array from the input stream. -+ * -+ *

The two valid possibilities are either a <null> -+ * or a <base64>. -+ */ -+ public byte []readBytes() -+ throws IOException -+ { -+ if (! parseTag()) -+ throw new BurlapProtocolException("expected "); -+ -+ String tag = sbuf.toString(); -+ if (tag.equals("null")) { -+ expectEndTag("null"); -+ return null; -+ } -+ else if (tag.equals("base64")) { -+ sbuf.setLength(0); -+ byte []value = parseBytes(); -+ expectEndTag("base64"); -+ return value; -+ } -+ else -+ throw expectBeginTag("base64", tag); -+ } -+ -+ /** -+ * Reads an arbitrary object the input stream. -+ */ -+ public Object readObject(Class expectedClass) -+ throws IOException -+ { -+ if (! parseTag()) -+ throw new BurlapProtocolException("expected "); -+ -+ String tag = sbuf.toString(); -+ if (tag.equals("null")) { -+ expectEndTag("null"); -+ return null; -+ } -+ else if (tag.equals("boolean")) { -+ int value = parseInt(); -+ expectEndTag("boolean"); -+ return new Boolean(value != 0); -+ } -+ else if (tag.equals("int")) { -+ int value = parseInt(); -+ expectEndTag("int"); -+ return new Integer(value); -+ } -+ else if (tag.equals("long")) { -+ long value = parseLong(); -+ expectEndTag("long"); -+ return new Long(value); -+ } -+ else if (tag.equals("string")) { -+ sbuf.setLength(0); -+ parseString(sbuf); -+ String value = sbuf.toString(); -+ expectEndTag("string"); -+ return value; -+ } -+ else if (tag.equals("xml")) { -+ sbuf.setLength(0); -+ parseString(sbuf); -+ String value = sbuf.toString(); -+ expectEndTag("xml"); -+ return value; -+ } -+ else if (tag.equals("date")) { -+ if (utcCalendar == null) -+ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -+ -+ long value = parseDate(utcCalendar); -+ expectEndTag("date"); -+ return new Date(value); -+ } -+ else if (tag.equals("map")) { -+ String type = readType(); -+ -+ return readMap(expectedClass, type); -+ } -+ else if (tag.equals("list")) { -+ String type = readType(); -+ -+ int length = readLength(); -+ -+ return readList(expectedClass, type, length); -+ } -+ else if (tag.equals("ref")) { -+ int value = parseInt(); -+ expectEndTag("ref"); -+ -+ return refs.elementAt(value); -+ } -+ else if (tag.equals("remote")) { -+ String type = readType(); -+ String url = readString(); -+ -+ expectEndTag("remote"); -+ -+ return resolveRemote(type, url); -+ } -+ else -+ return readExtensionObject(expectedClass, tag); -+ } -+ -+ /** -+ * Reads a type value from the input stream. -+ * -+ *

-+   * <type>a utf-8 encoded string</type>
-+   * 
-+ */ -+ public String readType() -+ throws IOException -+ { -+ if (! parseTag()) -+ throw new BurlapProtocolException("expected "); -+ -+ String tag = sbuf.toString(); -+ if (! tag.equals("type")) -+ throw new BurlapProtocolException("expected "); -+ -+ sbuf.setLength(0); -+ parseString(sbuf); -+ String value = sbuf.toString(); -+ expectEndTag("type"); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a length value from the input stream. If the length isn't -+ * specified, returns -1. -+ * -+ *
-+   * <length>integer</length>
-+   * 
-+ */ -+ public int readLength() -+ throws IOException -+ { -+ expectStartTag("length"); -+ -+ int ch = skipWhitespace(); -+ -+ peek = ch; -+ -+ if (ch == '<') { -+ expectEndTag("length"); -+ return -1; -+ } -+ -+ int value = parseInt(); -+ -+ expectEndTag("length"); -+ -+ return value; -+ } -+ -+ /** -+ * Resolves a remote object. -+ */ -+ public Object resolveRemote(String type, String url) -+ throws IOException -+ { -+ return new BurlapRemote(type, url); -+ } -+ -+ /** -+ * Reads a fault. -+ */ -+ public Hashtable readFault() -+ throws IOException -+ { -+ expectStartTag("fault"); -+ -+ Hashtable map = new Hashtable(); -+ -+ while (parseTag()) { -+ peekTag = true; -+ Object key = readObject(null); -+ Object value = readObject(null); -+ -+ if (key != null && value != null) -+ map.put(key, value); -+ } -+ -+ if (! sbuf.toString().equals("fault")) -+ throw new BurlapProtocolException("expected "); -+ -+ return map; -+ } -+ -+ /** -+ * Reads an object from the input stream. -+ * -+ * @param expectedClass the calling routine's expected class -+ * @param type the type from the stream -+ */ -+ public Object readMap(Class expectedClass, String type) -+ throws IOException -+ { -+ Hashtable map = new Hashtable(); -+ if (refs == null) -+ refs = new Vector(); -+ refs.addElement(map); -+ -+ while (parseTag()) { -+ peekTag = true; -+ Object key = readObject(null); -+ Object value = readObject(null); -+ -+ map.put(key, value); -+ } -+ if (! sbuf.toString().equals("map")) -+ throw new BurlapProtocolException("expected "); -+ -+ return map; -+ } -+ -+ /** -+ * Reads object unknown to MicroBurlapInput. -+ */ -+ protected Object readExtensionObject(Class expectedClass, String tag) -+ throws IOException -+ { -+ throw new BurlapProtocolException("unknown object tag <" + tag + ">"); -+ } -+ -+ /** -+ * Reads a list object from the input stream. -+ * -+ * @param expectedClass the calling routine's expected class -+ * @param type the type from the stream -+ * @param length the expected length, -1 for unspecified length -+ */ -+ public Object readList(Class expectedClass, String type, int length) -+ throws IOException -+ { -+ Vector list = new Vector(); -+ if (refs == null) -+ refs = new Vector(); -+ refs.addElement(list); -+ -+ while (parseTag()) { -+ peekTag = true; -+ Object value = readObject(null); -+ -+ list.addElement(value); -+ } -+ -+ if (! sbuf.toString().equals("list")) -+ throw new BurlapProtocolException("expected "); -+ -+ return list; -+ } -+ -+ /** -+ * Parses an integer value from the stream. -+ */ -+ protected int parseInt() -+ throws IOException -+ { -+ int sign = 1; -+ int value = 0; -+ -+ int ch = skipWhitespace(); -+ if (ch == '+') -+ ch = read(); -+ else if (ch == '-') { -+ sign = -1; -+ ch = read(); -+ } -+ -+ for (; ch >= '0' && ch <= '9'; ch = read()) -+ value = 10 * value + ch - '0'; -+ -+ peek = ch; -+ -+ return sign * value; -+ } -+ -+ /** -+ * Parses a long value from the stream. -+ */ -+ protected long parseLong() -+ throws IOException -+ { -+ long sign = 1; -+ long value = 0; -+ -+ int ch = skipWhitespace(); -+ if (ch == '+') -+ ch = read(); -+ else if (ch == '-') { -+ sign = -1; -+ ch = read(); -+ } -+ -+ for (; ch >= '0' && ch <= '9'; ch = read()) { -+ value = 10 * value + ch - '0'; -+ } -+ -+ peek = ch; -+ -+ return sign * value; -+ } -+ -+ /** -+ * Parses a date value from the stream. -+ */ -+ protected long parseDate(Calendar calendar) -+ throws IOException -+ { -+ int ch = skipWhitespace(); -+ -+ int year = 0; -+ for (int i = 0; i < 4; i++) { -+ if (ch >= '0' && ch <= '9') -+ year = 10 * year + ch - '0'; -+ else -+ throw expectedChar("year", ch); -+ -+ ch = read(); -+ } -+ -+ int month = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ month = 10 * month + ch - '0'; -+ else -+ throw expectedChar("month", ch); -+ -+ ch = read(); -+ } -+ -+ int day = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ day = 10 * day + ch - '0'; -+ else -+ throw expectedChar("day", ch); -+ -+ ch = read(); -+ } -+ -+ if (ch != 'T') -+ throw expectedChar("`T'", ch); -+ -+ ch = read(); -+ -+ int hour = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ hour = 10 * hour + ch - '0'; -+ else -+ throw expectedChar("hour", ch); -+ -+ ch = read(); -+ } -+ -+ int minute = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ minute = 10 * minute + ch - '0'; -+ else -+ throw expectedChar("minute", ch); -+ -+ ch = read(); -+ } -+ -+ int second = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ second = 10 * second + ch - '0'; -+ else -+ throw expectedChar("second", ch); -+ -+ ch = read(); -+ } -+ -+ for (; ch > 0 && ch != '<'; ch = read()) { -+ } -+ -+ peek = ch; -+ -+ calendar.set(Calendar.YEAR, year); -+ calendar.set(Calendar.MONTH, month - 1); -+ calendar.set(Calendar.DAY_OF_MONTH, day); -+ calendar.set(Calendar.HOUR_OF_DAY, hour); -+ calendar.set(Calendar.MINUTE, minute); -+ calendar.set(Calendar.SECOND, second); -+ calendar.set(Calendar.MILLISECOND, 0); -+ -+ return calendar.getTime().getTime(); -+ } -+ -+ /** -+ * Parses a string value from the stream. -+ * string buffer is used for the result. -+ */ -+ protected String parseString() -+ throws IOException -+ { -+ StringBuffer sbuf = new StringBuffer(); -+ -+ return parseString(sbuf).toString(); -+ } -+ -+ /** -+ * Parses a string value from the stream. The burlap object's -+ * string buffer is used for the result. -+ */ -+ protected StringBuffer parseString(StringBuffer sbuf) -+ throws IOException -+ { -+ int ch = read(); -+ -+ for (; ch >= 0 && ch != '<'; ch = read()) { -+ if (ch == '&') { -+ ch = read(); -+ -+ if (ch == '#') { -+ ch = read(); -+ -+ if (ch >= '0' && ch <= '9') { -+ int v = 0; -+ for (; ch >= '0' && ch <= '9'; ch = read()) { -+ v = 10 * v + ch - '0'; -+ } -+ -+ sbuf.append((char) v); -+ } -+ } -+ else { -+ StringBuffer entityBuffer = new StringBuffer(); -+ -+ for (; ch >= 'a' && ch <= 'z'; ch = read()) -+ entityBuffer.append((char) ch); -+ -+ String entity = entityBuffer.toString(); -+ if (entity.equals("amp")) -+ sbuf.append('&'); -+ else if (entity.equals("apos")) -+ sbuf.append('\''); -+ else if (entity.equals("quot")) -+ sbuf.append('"'); -+ else if (entity.equals("lt")) -+ sbuf.append('<'); -+ else if (entity.equals("gt")) -+ sbuf.append('>'); -+ else -+ throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); -+ } -+ -+ if (ch != ';') -+ throw expectedChar("';'", ch); -+ } -+ else if (ch < 0x80) -+ sbuf.append((char) ch); -+ else if ((ch & 0xe0) == 0xc0) { -+ int ch1 = read(); -+ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -+ -+ sbuf.append((char) v); -+ } -+ else if ((ch & 0xf0) == 0xe0) { -+ int ch1 = read(); -+ int ch2 = read(); -+ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -+ -+ sbuf.append((char) v); -+ } -+ else -+ throw new BurlapProtocolException("bad utf-8 encoding"); -+ } -+ -+ peek = ch; -+ -+ return sbuf; -+ } -+ -+ /** -+ * Parses a byte array. -+ */ -+ protected byte []parseBytes() -+ throws IOException -+ { -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ parseBytes(bos); -+ -+ return bos.toByteArray(); -+ } -+ -+ /** -+ * Parses a byte array. -+ */ -+ protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) -+ throws IOException -+ { -+ int ch; -+ for (ch = read(); ch >= 0 && ch != '<'; ch = read()) { -+ int b1 = ch; -+ int b2 = read(); -+ int b3 = read(); -+ int b4 = read(); -+ -+ if (b4 != '=') { -+ int chunk = ((base64Decode[b1] << 18) + -+ (base64Decode[b2] << 12) + -+ (base64Decode[b3] << 6) + -+ (base64Decode[b4])); -+ -+ bos.write(chunk >> 16); -+ bos.write(chunk >> 8); -+ bos.write(chunk); -+ } -+ else if (b3 != '=') { -+ int chunk = ((base64Decode[b1] << 12) + -+ (base64Decode[b2] << 6) + -+ (base64Decode[b3])); -+ -+ bos.write(chunk >> 8); -+ bos.write(chunk); -+ } -+ else { -+ int chunk = ((base64Decode[b1] << 6) + -+ (base64Decode[b2])); -+ -+ bos.write(chunk); -+ } -+ } -+ -+ if (ch == '<') -+ peek = ch; -+ -+ return bos; -+ } -+ -+ protected void expectStartTag(String tag) -+ throws IOException -+ { -+ if (! parseTag()) -+ throw new BurlapProtocolException("expected <" + tag + ">"); -+ -+ if (! sbuf.toString().equals(tag)) -+ throw new BurlapProtocolException("expected <" + tag + "> at <" + sbuf + ">"); -+ } -+ -+ protected void expectEndTag(String tag) -+ throws IOException -+ { -+ if (parseTag()) -+ throw new BurlapProtocolException("expected "); -+ -+ if (! sbuf.toString().equals(tag)) -+ throw new BurlapProtocolException("expected at "); -+ } -+ -+ /** -+ * Parses a tag. Returns true if it's a start tag. -+ */ -+ protected boolean parseTag() -+ throws IOException -+ { -+ if (peekTag) { -+ peekTag = false; -+ return true; -+ } -+ -+ int ch = skipWhitespace(); -+ boolean isStartTag = true; -+ -+ if (ch != '<') -+ throw expectedChar("'<'", ch); -+ -+ ch = read(); -+ if (ch == '/') { -+ isStartTag = false; -+ ch = is.read(); -+ } -+ -+ if (! isTagChar(ch)) -+ throw expectedChar("tag", ch); -+ -+ sbuf.setLength(0); -+ for (; isTagChar(ch); ch = read()) -+ sbuf.append((char) ch); -+ -+ if (ch != '>') -+ throw expectedChar("'>'", ch); -+ -+ return isStartTag; -+ } -+ -+ protected IOException expectedChar(String expect, int actualChar) -+ { -+ return new BurlapProtocolException("expected " + expect + " at " + -+ (char) actualChar + "'"); -+ } -+ -+ protected IOException expectBeginTag(String expect, String tag) -+ { -+ return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); -+ } -+ -+ private boolean isTagChar(int ch) -+ { -+ return (ch >= 'a' && ch <= 'z' || -+ ch >= 'A' && ch <= 'Z' || -+ ch >= '0' && ch <= '9' || -+ ch == ':' || ch == '-'); -+ } -+ -+ protected int skipWhitespace() -+ throws IOException -+ { -+ int ch = read(); -+ -+ for (; -+ ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -+ ch = read()) { -+ } -+ -+ return ch; -+ } -+ -+ protected boolean isWhitespace(int ch) -+ throws IOException -+ { -+ return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -+ } -+ -+ protected int read() -+ throws IOException -+ { -+ if (peek > 0) { -+ int value = peek; -+ peek = 0; -+ return value; -+ } -+ -+ return is.read(); -+ } -+ -+ static { -+ base64Decode = new int[256]; -+ for (int i = 'A'; i <= 'Z'; i++) -+ base64Decode[i] = i - 'A'; -+ for (int i = 'a'; i <= 'z'; i++) -+ base64Decode[i] = i - 'a' + 26; -+ for (int i = '0'; i <= '9'; i++) -+ base64Decode[i] = i - '0' + 52; -+ base64Decode['+'] = 62; -+ base64Decode['/'] = 63; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapOutput.java hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapOutput.java ---- hessian-4.0.65-src/com/caucho/burlap/client/MicroBurlapOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/MicroBurlapOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,694 +1,694 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.client; -- --import java.io.IOException; --import java.io.OutputStream; --import java.util.Calendar; --import java.util.Date; --import java.util.Enumeration; --import java.util.Hashtable; --import java.util.TimeZone; --import java.util.Vector; -- --/** -- * Output stream for Burlap requests, compatible with microedition -- * Java. It only uses classes and types available to J2ME. In -- * particular, it does not have any support for the <double> type. -- * -- *

MicroBurlapOutput does not depend on any classes other than -- * in J2ME, so it can be extracted independently into a smaller package. -- * -- *

MicroBurlapOutput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * OutputStream os = ...; // from http connection
-- * MicroBurlapOutput out = new MicroBurlapOutput(os);
-- * String value;
-- *
-- * out.startCall("hello");  // start hello call
-- * out.writeString("arg1"); // write a string argument
-- * out.completeCall();      // complete the call
-- * 
-- */ --public class MicroBurlapOutput { -- private OutputStream os; -- private Date date; -- private Calendar utcCalendar; -- private Calendar localCalendar; -- -- /** -- * Creates a new Burlap output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public MicroBurlapOutput(OutputStream os) -- { -- init(os); -- } -- -- /** -- * Creates an uninitialized Burlap output stream. -- */ -- public MicroBurlapOutput() -- { -- } -- -- public void init(OutputStream os) -- { -- this.os = os; -- } -- -- /** -- * Writes a complete method call. -- */ -- public void call(String method, Object []args) -- throws IOException -- { -- startCall(method); -- -- if (args != null) { -- for (int i = 0; i < args.length; i++) -- writeObject(args[i]); -- } -- -- completeCall(); -- } -- -- /** -- * Writes the method call: -- * -- *
--   * <burlap:request>
--   *   <method>add</method>
--   * 
-- * -- * @param method the method name to call. -- */ -- public void startCall(String method) -- throws IOException -- { -- print(""); -- print(method); -- print(""); -- } -- -- /** -- * Writes the method call: -- * -- *
--   * </burlap:request>
--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- print("
"); -- } -- -- /** -- * Writes a boolean value to the stream. The boolean will be written -- * with the following syntax: -- * -- *
--   * <boolean>1</boolean>
--   * 
-- * -- * @param value the boolean value to write. -- */ -- public void writeBoolean(boolean value) -- throws IOException -- { -- print(""); -- printInt(value ? 1 : 0); -- print(""); -- } -- -- /** -- * Writes an integer value to the stream. The integer will be written -- * with the following syntax: -- * -- *
--   * <int>123</int>
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeInt(int value) -- throws IOException -- { -- print(""); -- printInt(value); -- print(""); -- } -- -- /** -- * Writes a long value to the stream. The long will be written -- * with the following syntax: -- * -- *
--   * <long>123</long>
--   * 
-- * -- * @param value the long value to write. -- */ -- public void writeLong(long value) -- throws IOException -- { -- print(""); -- printLong(value); -- print(""); -- } -- -- /** -- * Writes a null value to the stream. -- * The null will be written with the following syntax -- * -- *
--   * <null></null>
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeNull() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * <string>12.3e10</string>
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * <null></null>
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(String value) -- throws IOException -- { -- if (value == null) { -- print(""); -- } -- else { -- print(""); -- printString(value); -- print(""); -- } -- } -- -- /** -- * Writes a byte array to the stream using base64 encoding. -- * The array will be written with the following syntax: -- * -- *
--   * <base64>dJmO==</base64>
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * <null></null>
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- print(""); -- } -- else { -- print(""); -- printBytes(buffer, offset, length); -- print(""); -- } -- } -- -- /** -- * Writes a date to the stream using ISO8609. -- * -- *
--   * <date>19980508T095131Z</date>
--   * 
-- * -- * @param value the date in milliseconds from the epoch in UTC -- */ -- public void writeUTCDate(long time) -- throws IOException -- { -- print(""); -- if (utcCalendar == null) { -- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -- date = new Date(); -- } -- -- date.setTime(time); -- utcCalendar.setTime(date); -- -- printDate(utcCalendar); -- print(""); -- } -- -- /** -- * Writes a date to the stream using ISO8609. -- * -- *
--   * <date>19980508T095131Z</date>
--   * 
-- * -- * @param value the date in milliseconds from the epoch in local timezone -- */ -- public void writeLocalDate(long time) -- throws IOException -- { -- print(""); -- if (localCalendar == null) { -- localCalendar = Calendar.getInstance(); -- date = new Date(); -- } -- -- date.setTime(time); -- localCalendar.setTime(date); -- -- printDate(localCalendar); -- print(""); -- } -- -- /** -- * Writes a reference. -- * -- *
--   * <ref>123</ref>
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeRef(int value) -- throws IOException -- { -- print(""); -- printInt(value); -- print(""); -- } -- -- /** -- * Writes a generic object. writeObject understands the following types: -- * -- *
    -- *
  • null -- *
  • java.lang.String -- *
  • java.lang.Boolean -- *
  • java.lang.Integer -- *
  • java.lang.Long -- *
  • java.util.Date -- *
  • byte[] -- *
  • java.util.Vector -- *
  • java.util.Hashtable -- *
-- * -- * Unknown objects will call writeCustomObject. -- */ -- public void writeObject(Object object) -- throws IOException -- { -- if (object == null) -- writeNull(); -- else if (object instanceof String) -- writeString((String) object); -- else if (object instanceof Boolean) -- writeBoolean(((Boolean) object).booleanValue()); -- else if (object instanceof Integer) -- writeInt(((Integer) object).intValue()); -- else if (object instanceof Long) -- writeLong(((Long) object).longValue()); -- else if (object instanceof Date) -- writeUTCDate(((Date) object).getTime()); -- else if (object instanceof byte[]) { -- byte []data = (byte []) object; -- writeBytes(data, 0, data.length); -- } -- else if (object instanceof Vector) { -- Vector vector = (Vector) object; -- -- int size = vector.size(); -- writeListBegin(size, null); -- for (int i = 0; i < size; i++) -- writeObject(vector.elementAt(i)); -- -- writeListEnd(); -- } -- else if (object instanceof Hashtable) { -- Hashtable hashtable = (Hashtable) object; -- -- writeMapBegin(null); -- Enumeration e = hashtable.keys(); -- while (e.hasMoreElements()) { -- Object key = e.nextElement(); -- Object value = hashtable.get(key); -- -- writeObject(key); -- writeObject(value); -- } -- writeMapEnd(); -- } -- else -- writeCustomObject(object); -- } -- -- /** -- * Applications which override this can do custom serialization. -- * -- * @param object the object to write. -- */ -- public void writeCustomObject(Object object) -- throws IOException -- { -- throw new IOException("unexpected object: " + object); -- } -- -- /** -- * Writes the list header to the stream. List writers will call -- * writeListBegin followed by the list contents and then -- * call writeListEnd. -- * -- *
--   * <list>
--   *   <type>java.util.ArrayList</type>
--   *   <length>3</length>
--   *   <int>1</int>
--   *   <int>2</int>
--   *   <int>3</int>
--   * </list>
--   * 
-- */ -- public void writeListBegin(int length, String type) -- throws IOException -- { -- print(""); -- if (type != null) -- print(type); -- print(""); -- printInt(length); -- print(""); -- } -- -- /** -- * Writes the tail of the list to the stream. -- */ -- public void writeListEnd() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Writes the map header to the stream. Map writers will call -- * writeMapBegin followed by the map contents and then -- * call writeMapEnd. -- * -- *
--   * <map>
--   *   <type>java.util.Hashtable</type>
--   *   <string>a</string;<int>1</int>
--   *   <string>b</string;<int>2</int>
--   *   <string>c</string;<int>3</int>
--   * </map>
--   * 
-- */ -- public void writeMapBegin(String type) -- throws IOException -- { -- print(""); -- if (type != null) -- print(type); -- print(""); -- } -- -- /** -- * Writes the tail of the map to the stream. -- */ -- public void writeMapEnd() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Writes a remote object reference to the stream. The type is the -- * type of the remote interface. -- * -- *
--   * <remote>
--   *   <type>test.account.Account</type>
--   *   <string>http://caucho.com/foo;ejbid=bar</string>
--   * </remote>
--   * 
-- */ -- public void writeRemote(String type, String url) -- throws IOException -- { -- print(""); -- if (type != null) -- print(type); -- print(""); -- print(url); -- print(""); -- } -- -- /** -- * Prints an integer to the stream. -- * -- * @param v the integer to print. -- */ -- public void printInt(int v) -- throws IOException -- { -- print(String.valueOf(v)); -- } -- -- /** -- * Prints a long to the stream. -- * -- * @param v the long to print. -- */ -- public void printLong(long v) -- throws IOException -- { -- print(String.valueOf(v)); -- } -- -- /** -- * Prints a string to the stream, properly encoded. -- * -- * @param v the string to print. -- */ -- public void printString(String v) -- throws IOException -- { -- int len = v.length(); -- -- for (int i = 0; i < len; i++) { -- char ch = v.charAt(i); -- -- switch (ch) { -- case '<': -- print("<"); -- break; -- -- case '&': -- print("&"); -- break; -- -- case '\r': -- print(" "); -- break; -- -- default: -- if (ch < 0x80) -- os.write(ch); -- else if (ch < 0x800) { -- os.write(0xc0 + ((ch >> 6) & 0x1f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- else { -- os.write(0xe0 + ((ch >> 12) & 0xf)); -- os.write(0x80 + ((ch >> 6) & 0x3f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- break; -- } -- } -- } -- -- /** -- * Prints a byte array to the stream, properly encoded in base64. -- * -- * @param data the bytes to print. -- */ -- public void printBytes(byte []data, int offset, int length) -- throws IOException -- { -- int i; -- -- for (; length >= 3; length -= 3) { -- int chunk = (((data[offset] & 0xff) << 16) + -- ((data[offset + 1] & 0xff) << 8) + -- (data[offset + 2] & 0xff)); -- -- os.write(base64encode(chunk >> 18)); -- os.write(base64encode(chunk >> 12)); -- os.write(base64encode(chunk >> 6)); -- os.write(base64encode(chunk)); -- -- offset += 3; -- } -- -- if (length == 2) { -- int chunk = ((data[offset] & 0xff) << 8) + (data[offset + 1] & 0xff); -- -- os.write(base64encode(chunk >> 12)); -- os.write(base64encode(chunk >> 6)); -- os.write(base64encode(chunk)); -- os.write('='); -- } else if (length == 1) { -- int chunk = data[offset] & 0xff; -- os.write(base64encode(chunk >> 6)); -- os.write(base64encode(chunk)); -- os.write('='); -- os.write('='); -- } -- } -- -- /** -- * Converts the digit to its base64 encoding. -- */ -- public static char base64encode(int d) -- { -- d &= 0x3f; -- if (d < 26) -- return (char) (d + 'A'); -- else if (d < 52) -- return (char) (d + 'a' - 26); -- else if (d < 62) -- return (char) (d + '0' - 52); -- else if (d == 62) -- return '+'; -- else -- return '/'; -- } -- -- /** -- * Prints a date. -- * -- * @param date the date to print. -- */ -- public void printDate(Calendar calendar) -- throws IOException -- { -- int year = calendar.get(Calendar.YEAR); -- -- os.write((char) ('0' + (year / 1000 % 10))); -- os.write((char) ('0' + (year / 100 % 10))); -- os.write((char) ('0' + (year / 10 % 10))); -- os.write((char) ('0' + (year % 10))); -- -- int month = calendar.get(Calendar.MONTH) + 1; -- os.write((char) ('0' + (month / 10 % 10))); -- os.write((char) ('0' + (month % 10))); -- -- int day = calendar.get(Calendar.DAY_OF_MONTH); -- os.write((char) ('0' + (day / 10 % 10))); -- os.write((char) ('0' + (day % 10))); -- -- os.write('T'); -- -- int hour = calendar.get(Calendar.HOUR_OF_DAY); -- os.write((char) ('0' + (hour / 10 % 10))); -- os.write((char) ('0' + (hour % 10))); -- -- int minute = calendar.get(Calendar.MINUTE); -- os.write((char) ('0' + (minute / 10 % 10))); -- os.write((char) ('0' + (minute % 10))); -- -- int second = calendar.get(Calendar.SECOND); -- os.write((char) ('0' + (second / 10 % 10))); -- os.write((char) ('0' + (second % 10))); -- -- os.write('Z'); -- } -- -- /** -- * Prints a string as ascii to the stream. Used for tags, etc. -- * that are known to the ascii. -- * -- * @param s the ascii string to print. -- */ -- public void print(String s) -- throws IOException -- { -- int len = s.length(); -- for (int i = 0; i < len; i++) { -- int ch = s.charAt(i); -- -- os.write(ch); -- } -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.client; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+import java.util.Calendar; -+import java.util.Date; -+import java.util.Enumeration; -+import java.util.Hashtable; -+import java.util.TimeZone; -+import java.util.Vector; -+ -+/** -+ * Output stream for Burlap requests, compatible with microedition -+ * Java. It only uses classes and types available to J2ME. In -+ * particular, it does not have any support for the <double> type. -+ * -+ *

MicroBurlapOutput does not depend on any classes other than -+ * in J2ME, so it can be extracted independently into a smaller package. -+ * -+ *

MicroBurlapOutput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * OutputStream os = ...; // from http connection
-+ * MicroBurlapOutput out = new MicroBurlapOutput(os);
-+ * String value;
-+ *
-+ * out.startCall("hello");  // start hello call
-+ * out.writeString("arg1"); // write a string argument
-+ * out.completeCall();      // complete the call
-+ * 
-+ */ -+public class MicroBurlapOutput { -+ private OutputStream os; -+ private Date date; -+ private Calendar utcCalendar; -+ private Calendar localCalendar; -+ -+ /** -+ * Creates a new Burlap output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public MicroBurlapOutput(OutputStream os) -+ { -+ init(os); -+ } -+ -+ /** -+ * Creates an uninitialized Burlap output stream. -+ */ -+ public MicroBurlapOutput() -+ { -+ } -+ -+ public void init(OutputStream os) -+ { -+ this.os = os; -+ } -+ -+ /** -+ * Writes a complete method call. -+ */ -+ public void call(String method, Object []args) -+ throws IOException -+ { -+ startCall(method); -+ -+ if (args != null) { -+ for (int i = 0; i < args.length; i++) -+ writeObject(args[i]); -+ } -+ -+ completeCall(); -+ } -+ -+ /** -+ * Writes the method call: -+ * -+ *
-+   * <burlap:request>
-+   *   <method>add</method>
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void startCall(String method) -+ throws IOException -+ { -+ print(""); -+ print(method); -+ print(""); -+ } -+ -+ /** -+ * Writes the method call: -+ * -+ *
-+   * </burlap:request>
-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ print("
"); -+ } -+ -+ /** -+ * Writes a boolean value to the stream. The boolean will be written -+ * with the following syntax: -+ * -+ *
-+   * <boolean>1</boolean>
-+   * 
-+ * -+ * @param value the boolean value to write. -+ */ -+ public void writeBoolean(boolean value) -+ throws IOException -+ { -+ print(""); -+ printInt(value ? 1 : 0); -+ print(""); -+ } -+ -+ /** -+ * Writes an integer value to the stream. The integer will be written -+ * with the following syntax: -+ * -+ *
-+   * <int>123</int>
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeInt(int value) -+ throws IOException -+ { -+ print(""); -+ printInt(value); -+ print(""); -+ } -+ -+ /** -+ * Writes a long value to the stream. The long will be written -+ * with the following syntax: -+ * -+ *
-+   * <long>123</long>
-+   * 
-+ * -+ * @param value the long value to write. -+ */ -+ public void writeLong(long value) -+ throws IOException -+ { -+ print(""); -+ printLong(value); -+ print(""); -+ } -+ -+ /** -+ * Writes a null value to the stream. -+ * The null will be written with the following syntax -+ * -+ *
-+   * <null></null>
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeNull() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * <string>12.3e10</string>
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * <null></null>
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(String value) -+ throws IOException -+ { -+ if (value == null) { -+ print(""); -+ } -+ else { -+ print(""); -+ printString(value); -+ print(""); -+ } -+ } -+ -+ /** -+ * Writes a byte array to the stream using base64 encoding. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * <base64>dJmO==</base64>
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * <null></null>
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ print(""); -+ } -+ else { -+ print(""); -+ printBytes(buffer, offset, length); -+ print(""); -+ } -+ } -+ -+ /** -+ * Writes a date to the stream using ISO8609. -+ * -+ *
-+   * <date>19980508T095131Z</date>
-+   * 
-+ * -+ * @param value the date in milliseconds from the epoch in UTC -+ */ -+ public void writeUTCDate(long time) -+ throws IOException -+ { -+ print(""); -+ if (utcCalendar == null) { -+ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -+ date = new Date(); -+ } -+ -+ date.setTime(time); -+ utcCalendar.setTime(date); -+ -+ printDate(utcCalendar); -+ print(""); -+ } -+ -+ /** -+ * Writes a date to the stream using ISO8609. -+ * -+ *
-+   * <date>19980508T095131Z</date>
-+   * 
-+ * -+ * @param value the date in milliseconds from the epoch in local timezone -+ */ -+ public void writeLocalDate(long time) -+ throws IOException -+ { -+ print(""); -+ if (localCalendar == null) { -+ localCalendar = Calendar.getInstance(); -+ date = new Date(); -+ } -+ -+ date.setTime(time); -+ localCalendar.setTime(date); -+ -+ printDate(localCalendar); -+ print(""); -+ } -+ -+ /** -+ * Writes a reference. -+ * -+ *
-+   * <ref>123</ref>
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeRef(int value) -+ throws IOException -+ { -+ print(""); -+ printInt(value); -+ print(""); -+ } -+ -+ /** -+ * Writes a generic object. writeObject understands the following types: -+ * -+ *
    -+ *
  • null -+ *
  • java.lang.String -+ *
  • java.lang.Boolean -+ *
  • java.lang.Integer -+ *
  • java.lang.Long -+ *
  • java.util.Date -+ *
  • byte[] -+ *
  • java.util.Vector -+ *
  • java.util.Hashtable -+ *
-+ * -+ * Unknown objects will call writeCustomObject. -+ */ -+ public void writeObject(Object object) -+ throws IOException -+ { -+ if (object == null) -+ writeNull(); -+ else if (object instanceof String) -+ writeString((String) object); -+ else if (object instanceof Boolean) -+ writeBoolean(((Boolean) object).booleanValue()); -+ else if (object instanceof Integer) -+ writeInt(((Integer) object).intValue()); -+ else if (object instanceof Long) -+ writeLong(((Long) object).longValue()); -+ else if (object instanceof Date) -+ writeUTCDate(((Date) object).getTime()); -+ else if (object instanceof byte[]) { -+ byte []data = (byte []) object; -+ writeBytes(data, 0, data.length); -+ } -+ else if (object instanceof Vector) { -+ Vector vector = (Vector) object; -+ -+ int size = vector.size(); -+ writeListBegin(size, null); -+ for (int i = 0; i < size; i++) -+ writeObject(vector.elementAt(i)); -+ -+ writeListEnd(); -+ } -+ else if (object instanceof Hashtable) { -+ Hashtable hashtable = (Hashtable) object; -+ -+ writeMapBegin(null); -+ Enumeration e = hashtable.keys(); -+ while (e.hasMoreElements()) { -+ Object key = e.nextElement(); -+ Object value = hashtable.get(key); -+ -+ writeObject(key); -+ writeObject(value); -+ } -+ writeMapEnd(); -+ } -+ else -+ writeCustomObject(object); -+ } -+ -+ /** -+ * Applications which override this can do custom serialization. -+ * -+ * @param object the object to write. -+ */ -+ public void writeCustomObject(Object object) -+ throws IOException -+ { -+ throw new IOException("unexpected object: " + object); -+ } -+ -+ /** -+ * Writes the list header to the stream. List writers will call -+ * writeListBegin followed by the list contents and then -+ * call writeListEnd. -+ * -+ *
-+   * <list>
-+   *   <type>java.util.ArrayList</type>
-+   *   <length>3</length>
-+   *   <int>1</int>
-+   *   <int>2</int>
-+   *   <int>3</int>
-+   * </list>
-+   * 
-+ */ -+ public void writeListBegin(int length, String type) -+ throws IOException -+ { -+ print(""); -+ if (type != null) -+ print(type); -+ print(""); -+ printInt(length); -+ print(""); -+ } -+ -+ /** -+ * Writes the tail of the list to the stream. -+ */ -+ public void writeListEnd() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Writes the map header to the stream. Map writers will call -+ * writeMapBegin followed by the map contents and then -+ * call writeMapEnd. -+ * -+ *
-+   * <map>
-+   *   <type>java.util.Hashtable</type>
-+   *   <string>a</string;<int>1</int>
-+   *   <string>b</string;<int>2</int>
-+   *   <string>c</string;<int>3</int>
-+   * </map>
-+   * 
-+ */ -+ public void writeMapBegin(String type) -+ throws IOException -+ { -+ print(""); -+ if (type != null) -+ print(type); -+ print(""); -+ } -+ -+ /** -+ * Writes the tail of the map to the stream. -+ */ -+ public void writeMapEnd() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Writes a remote object reference to the stream. The type is the -+ * type of the remote interface. -+ * -+ *
-+   * <remote>
-+   *   <type>test.account.Account</type>
-+   *   <string>http://caucho.com/foo;ejbid=bar</string>
-+   * </remote>
-+   * 
-+ */ -+ public void writeRemote(String type, String url) -+ throws IOException -+ { -+ print(""); -+ if (type != null) -+ print(type); -+ print(""); -+ print(url); -+ print(""); -+ } -+ -+ /** -+ * Prints an integer to the stream. -+ * -+ * @param v the integer to print. -+ */ -+ public void printInt(int v) -+ throws IOException -+ { -+ print(String.valueOf(v)); -+ } -+ -+ /** -+ * Prints a long to the stream. -+ * -+ * @param v the long to print. -+ */ -+ public void printLong(long v) -+ throws IOException -+ { -+ print(String.valueOf(v)); -+ } -+ -+ /** -+ * Prints a string to the stream, properly encoded. -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v) -+ throws IOException -+ { -+ int len = v.length(); -+ -+ for (int i = 0; i < len; i++) { -+ char ch = v.charAt(i); -+ -+ switch (ch) { -+ case '<': -+ print("<"); -+ break; -+ -+ case '&': -+ print("&"); -+ break; -+ -+ case '\r': -+ print(" "); -+ break; -+ -+ default: -+ if (ch < 0x80) -+ os.write(ch); -+ else if (ch < 0x800) { -+ os.write(0xc0 + ((ch >> 6) & 0x1f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ else { -+ os.write(0xe0 + ((ch >> 12) & 0xf)); -+ os.write(0x80 + ((ch >> 6) & 0x3f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ break; -+ } -+ } -+ } -+ -+ /** -+ * Prints a byte array to the stream, properly encoded in base64. -+ * -+ * @param data the bytes to print. -+ */ -+ public void printBytes(byte []data, int offset, int length) -+ throws IOException -+ { -+ int i; -+ -+ for (; length >= 3; length -= 3) { -+ int chunk = (((data[offset] & 0xff) << 16) + -+ ((data[offset + 1] & 0xff) << 8) + -+ (data[offset + 2] & 0xff)); -+ -+ os.write(base64encode(chunk >> 18)); -+ os.write(base64encode(chunk >> 12)); -+ os.write(base64encode(chunk >> 6)); -+ os.write(base64encode(chunk)); -+ -+ offset += 3; -+ } -+ -+ if (length == 2) { -+ int chunk = ((data[offset] & 0xff) << 8) + (data[offset + 1] & 0xff); -+ -+ os.write(base64encode(chunk >> 12)); -+ os.write(base64encode(chunk >> 6)); -+ os.write(base64encode(chunk)); -+ os.write('='); -+ } else if (length == 1) { -+ int chunk = data[offset] & 0xff; -+ os.write(base64encode(chunk >> 6)); -+ os.write(base64encode(chunk)); -+ os.write('='); -+ os.write('='); -+ } -+ } -+ -+ /** -+ * Converts the digit to its base64 encoding. -+ */ -+ public static char base64encode(int d) -+ { -+ d &= 0x3f; -+ if (d < 26) -+ return (char) (d + 'A'); -+ else if (d < 52) -+ return (char) (d + 'a' - 26); -+ else if (d < 62) -+ return (char) (d + '0' - 52); -+ else if (d == 62) -+ return '+'; -+ else -+ return '/'; -+ } -+ -+ /** -+ * Prints a date. -+ * -+ * @param date the date to print. -+ */ -+ public void printDate(Calendar calendar) -+ throws IOException -+ { -+ int year = calendar.get(Calendar.YEAR); -+ -+ os.write((char) ('0' + (year / 1000 % 10))); -+ os.write((char) ('0' + (year / 100 % 10))); -+ os.write((char) ('0' + (year / 10 % 10))); -+ os.write((char) ('0' + (year % 10))); -+ -+ int month = calendar.get(Calendar.MONTH) + 1; -+ os.write((char) ('0' + (month / 10 % 10))); -+ os.write((char) ('0' + (month % 10))); -+ -+ int day = calendar.get(Calendar.DAY_OF_MONTH); -+ os.write((char) ('0' + (day / 10 % 10))); -+ os.write((char) ('0' + (day % 10))); -+ -+ os.write('T'); -+ -+ int hour = calendar.get(Calendar.HOUR_OF_DAY); -+ os.write((char) ('0' + (hour / 10 % 10))); -+ os.write((char) ('0' + (hour % 10))); -+ -+ int minute = calendar.get(Calendar.MINUTE); -+ os.write((char) ('0' + (minute / 10 % 10))); -+ os.write((char) ('0' + (minute % 10))); -+ -+ int second = calendar.get(Calendar.SECOND); -+ os.write((char) ('0' + (second / 10 % 10))); -+ os.write((char) ('0' + (second % 10))); -+ -+ os.write('Z'); -+ } -+ -+ /** -+ * Prints a string as ascii to the stream. Used for tags, etc. -+ * that are known to the ascii. -+ * -+ * @param s the ascii string to print. -+ */ -+ public void print(String s) -+ throws IOException -+ { -+ int len = s.length(); -+ for (int i = 0; i < len; i++) { -+ int ch = s.charAt(i); -+ -+ os.write(ch); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/client/package.html hessian-4.0.65-fix/com/caucho/burlap/client/package.html ---- hessian-4.0.65-src/com/caucho/burlap/client/package.html 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/client/package.html 2023-08-15 18:39:22.000000000 +0800 -@@ -1,59 +1,59 @@ -- -- --Portable client code for using Burlap services. Since this package is --independent of all Resin code, its classes can be copied to a --non-Resin client jar. -- --

RPC Proxy Clients - BurlapProxyFactory

-- --Most application clients will use BurlapProxyFactory to --create stub objects. The stub objects can be called with normal --Java calls. Because the objects are remote, the client application needs --to be able to deal with IOException caused by an unavailable server or --a protocol error. -- --
--import com.caucho.burlap.client.BurlapProxyFactory;
--
--...
--
--URL url = new URL("http://localhost:8080/ejb/hello");
--HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
--
--System.out.println("hello: " + hello.hello());
--
-- --

Serialization

-- --Since the Burlap protocol serializes Java objects to XML, the --BurlapSerializerOutput and BurlapSerializerInput --can be used for serialization. -- --

Serialization

--
--OutputStream os = new FileOutputStream("test.xml");
--BurlapOutput out = new BurlapSerializerOutput(os);
--
--out.writeObject(obj);
--os.close();
--
-- --

Deserialization

--
--InputStream is = new FileInputStream("test.xml");
--BurlapInput in = new BurlapSerializerInput(in);
--
--Object obj = in.readObject();
--
--is.close();
--
-- --

MicroBurlapInput and MicroBurlapOutput

-- --These two classes only require classes from Java MicroEdition. So they --can be extracted separately into a burlap-micro.jar. Because of this --restriction and their small size, these two classes --are ideal for limited size devices like mobile phones and PDAs. -- -- -+ -+ -+Portable client code for using Burlap services. Since this package is -+independent of all Resin code, its classes can be copied to a -+non-Resin client jar. -+ -+

RPC Proxy Clients - BurlapProxyFactory

-+ -+Most application clients will use BurlapProxyFactory to -+create stub objects. The stub objects can be called with normal -+Java calls. Because the objects are remote, the client application needs -+to be able to deal with IOException caused by an unavailable server or -+a protocol error. -+ -+
-+import com.caucho.burlap.client.BurlapProxyFactory;
-+
-+...
-+
-+URL url = new URL("http://localhost:8080/ejb/hello");
-+HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+
-+System.out.println("hello: " + hello.hello());
-+
-+ -+

Serialization

-+ -+Since the Burlap protocol serializes Java objects to XML, the -+BurlapSerializerOutput and BurlapSerializerInput -+can be used for serialization. -+ -+

Serialization

-+
-+OutputStream os = new FileOutputStream("test.xml");
-+BurlapOutput out = new BurlapSerializerOutput(os);
-+
-+out.writeObject(obj);
-+os.close();
-+
-+ -+

Deserialization

-+
-+InputStream is = new FileInputStream("test.xml");
-+BurlapInput in = new BurlapSerializerInput(in);
-+
-+Object obj = in.readObject();
-+
-+is.close();
-+
-+ -+

MicroBurlapInput and MicroBurlapOutput

-+ -+These two classes only require classes from Java MicroEdition. So they -+can be extracted separately into a burlap-micro.jar. Because of this -+restriction and their small size, these two classes -+are ideal for limited size devices like mobile phones and PDAs. -+ -+ - -\ No newline at end of file -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapInput.java hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapInput.java ---- hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,69 +1,69 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import com.caucho.hessian.io.AbstractHessianInput; -- --/** -- * Abstract base class for Burlap requests. Burlap users should only -- * need to use the methods in this class. -- * -- *

Note, this class is just an extension of AbstractHessianInput. -- * -- *

-- * AbstractBurlapInput in = ...; // get input
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --abstract public class AbstractBurlapInput extends AbstractHessianInput { --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+/** -+ * Abstract base class for Burlap requests. Burlap users should only -+ * need to use the methods in this class. -+ * -+ *

Note, this class is just an extension of AbstractHessianInput. -+ * -+ *

-+ * AbstractBurlapInput in = ...; // get input
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+abstract public class AbstractBurlapInput extends AbstractHessianInput { -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapOutput.java hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapOutput.java ---- hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,77 +1,77 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import com.caucho.hessian.io.AbstractHessianOutput; --import java.io.IOException; -- --/** -- * Abstract output stream for Burlap requests. -- * -- *
-- * OutputStream os = ...; // from http connection
-- * AbstractOutput out = new BurlapSerializerOutput(os);
-- * String value;
-- *
-- * out.startCall("hello");  // start hello call
-- * out.writeString("arg1"); // write a string argument
-- * out.completeCall();      // complete the call
-- * 
-- */ --abstract public class AbstractBurlapOutput extends AbstractHessianOutput { -- @Override -- public void startCall(String method, int length) -- throws IOException -- { -- startCall(method); -- } -- -- abstract void startCall(String method) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import com.caucho.hessian.io.AbstractHessianOutput; -+import java.io.IOException; -+ -+/** -+ * Abstract output stream for Burlap requests. -+ * -+ *
-+ * OutputStream os = ...; // from http connection
-+ * AbstractOutput out = new BurlapSerializerOutput(os);
-+ * String value;
-+ *
-+ * out.startCall("hello");  // start hello call
-+ * out.writeString("arg1"); // write a string argument
-+ * out.completeCall();      // complete the call
-+ * 
-+ */ -+abstract public class AbstractBurlapOutput extends AbstractHessianOutput { -+ @Override -+ public void startCall(String method, int length) -+ throws IOException -+ { -+ startCall(method); -+ } -+ -+ abstract void startCall(String method) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapResolver.java hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapResolver.java ---- hessian-4.0.65-src/com/caucho/burlap/io/AbstractBurlapResolver.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/AbstractBurlapResolver.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,65 +1,65 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import java.io.IOException; -- --/** -- * Looks up remote objects. The default just returns a BurlapRemote object. -- */ --public class AbstractBurlapResolver implements BurlapRemoteResolver { -- /** -- * Looks up a proxy object. -- */ -- public Object lookup(String type, String url) -- throws IOException -- { -- return new BurlapRemote(type, url); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import java.io.IOException; -+ -+/** -+ * Looks up remote objects. The default just returns a BurlapRemote object. -+ */ -+public class AbstractBurlapResolver implements BurlapRemoteResolver { -+ /** -+ * Looks up a proxy object. -+ */ -+ public Object lookup(String type, String url) -+ throws IOException -+ { -+ return new BurlapRemote(type, url); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapInput.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapInput.java ---- hessian-4.0.65-src/com/caucho/burlap/io/BurlapInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,1817 +1,1817 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import com.caucho.hessian.io.Deserializer; --import com.caucho.hessian.io.HessianRemoteResolver; --import com.caucho.hessian.io.SerializerFactory; -- --import java.io.ByteArrayOutputStream; --import java.io.IOException; --import java.io.InputStream; --import java.io.Reader; --import java.lang.reflect.Field; --import java.util.ArrayList; --import java.util.Calendar; --import java.util.Date; --import java.util.HashMap; --import java.util.TimeZone; -- --/** -- * Input stream for Burlap requests. -- * -- *

BurlapInput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * InputStream is = ...; // from http connection
-- * BurlapInput in = new BurlapInput(is);
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --public class BurlapInput extends AbstractBurlapInput { -- private static int []base64Decode; -- -- public final static int TAG_EOF = -1; -- -- public final static int TAG_NULL = 0; -- public final static int TAG_BOOLEAN = 1; -- public final static int TAG_INT = 2; -- public final static int TAG_LONG = 3; -- public final static int TAG_DOUBLE = 4; -- public final static int TAG_DATE = 5; -- public final static int TAG_STRING = 6; -- public final static int TAG_XML = 7; -- public final static int TAG_BASE64 = 8; -- public final static int TAG_MAP = 9; -- public final static int TAG_LIST = 10; -- public final static int TAG_TYPE = 11; -- public final static int TAG_LENGTH = 12; -- -- public final static int TAG_REF = 13; -- public final static int TAG_REMOTE = 14; -- -- public final static int TAG_CALL = 15; -- public final static int TAG_REPLY = 16; -- public final static int TAG_FAULT = 17; -- public final static int TAG_METHOD = 18; -- public final static int TAG_HEADER = 19; -- -- public final static int TAG_NULL_END = TAG_NULL + 100; -- public final static int TAG_BOOLEAN_END = TAG_BOOLEAN + 100; -- public final static int TAG_INT_END = TAG_INT + 100; -- public final static int TAG_LONG_END = TAG_LONG + 100; -- public final static int TAG_DOUBLE_END = TAG_DOUBLE + 100; -- public final static int TAG_DATE_END = TAG_DATE + 100; -- public final static int TAG_STRING_END = TAG_STRING + 100; -- public final static int TAG_XML_END = TAG_XML + 100; -- public final static int TAG_BASE64_END = TAG_BASE64 + 100; -- public final static int TAG_MAP_END = TAG_MAP + 100; -- public final static int TAG_LIST_END = TAG_LIST + 100; -- public final static int TAG_TYPE_END = TAG_TYPE + 100; -- public final static int TAG_LENGTH_END = TAG_LENGTH + 100; -- -- public final static int TAG_REF_END = TAG_REF + 100; -- public final static int TAG_REMOTE_END = TAG_REMOTE + 100; -- -- public final static int TAG_CALL_END = TAG_CALL + 100; -- public final static int TAG_REPLY_END = TAG_REPLY + 100; -- public final static int TAG_FAULT_END = TAG_FAULT + 100; -- public final static int TAG_METHOD_END = TAG_METHOD + 100; -- public final static int TAG_HEADER_END = TAG_HEADER + 100; -- -- private static HashMap _tagMap; -- -- private static Field _detailMessageField; -- -- protected SerializerFactory _serializerFactory; -- -- protected ArrayList _refs; -- -- // the underlying input stream -- private InputStream _is; -- // a peek character -- protected int _peek = -1; -- -- // the method for a call -- private String _method; -- -- private int _peekTag; -- -- private Throwable _replyFault; -- -- protected StringBuffer _sbuf = new StringBuffer(); -- protected StringBuffer _entityBuffer = new StringBuffer(); -- -- protected Calendar _utcCalendar; -- protected Calendar _localCalendar; -- -- /** -- * Creates an uninitialized Burlap input stream. -- */ -- public BurlapInput() -- { -- } -- -- /** -- * Creates a new Burlap input stream, initialized with an -- * underlying input stream. -- * -- * @param is the underlying input stream. -- */ -- public BurlapInput(InputStream is) -- { -- init(is); -- } -- -- /** -- * Sets the serializer factory. -- */ -- public void setSerializerFactory(SerializerFactory factory) -- { -- _serializerFactory = factory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- public SerializerFactory getSerializerFactory() -- { -- return _serializerFactory; -- } -- -- /** -- * Initialize the burlap stream with the underlying input stream. -- */ -- public void init(InputStream is) -- { -- _is = is; -- _method = null; -- _peek = -1; -- _peekTag = -1; -- _refs = null; -- _replyFault = null; -- -- if (_serializerFactory == null) -- _serializerFactory = new SerializerFactory(); -- } -- -- /** -- * Returns the calls method -- */ -- public String getMethod() -- { -- return _method; -- } -- -- /** -- * Returns any reply fault. -- */ -- public Throwable getReplyFault() -- { -- return _replyFault; -- } -- -- /** -- * Starts reading the call -- * -- *
--   * <burlap:call>
--   * <method>method</method>
--   * 
-- */ -- public void startCall() -- throws IOException -- { -- readCall(); -- -- while ((readHeader() != null)) -- readObject(); -- -- readMethod(); -- } -- -- /** -- * Starts reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * <burlap:call>
--   * 
-- */ -- public int readCall() -- throws IOException -- { -- expectTag(TAG_CALL); -- -- int major = 1; -- int minor = 0; -- -- return (major << 16) + minor; -- } -- -- /** -- * Reads the method -- * -- *
--   * <method>method</method>
--   * 
-- */ -- public String readMethod() -- throws IOException -- { -- expectTag(TAG_METHOD); -- -- _method = parseString(); -- -- expectTag(TAG_METHOD_END); -- -- return _method; -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * </burlap:call>
--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- expectTag(TAG_CALL_END); -- } -- -- /** -- * Reads a reply as an object. -- * If the reply has a fault, throws the exception. -- */ -- public Object readReply(Class expectedClass) -- throws Throwable -- { -- expectTag(TAG_REPLY); -- -- int tag = parseTag(); -- -- if (tag == TAG_FAULT) -- throw prepareFault(); -- else { -- _peekTag = tag; -- Object value = readObject(expectedClass); -- -- expectTag(TAG_REPLY_END); -- -- return value; -- } -- } -- -- /** -- * Starts reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * <burlap:reply>
--   * <value>
--   * 
-- */ -- public void startReply() -- throws Throwable -- { -- expectTag(TAG_REPLY); -- -- int tag = parseTag(); -- if (tag == TAG_FAULT) -- throw prepareFault(); -- else -- _peekTag = tag; -- } -- -- /** -- * Prepares the fault. -- */ -- private Throwable prepareFault() -- throws IOException -- { -- HashMap fault = readFault(); -- -- Object detail = fault.get("detail"); -- String message = (String) fault.get("message"); -- -- if (detail instanceof Throwable) { -- _replyFault = (Throwable) detail; -- -- Field detailMessageField = getDetailMessageField(); -- -- if (message != null && detailMessageField != null) { -- try { -- detailMessageField.set(_replyFault, message); -- } catch (Throwable e) { -- } -- } -- -- return _replyFault; -- } -- -- else { -- String code = (String) fault.get("code"); -- -- _replyFault = new BurlapServiceException(message, code, detail); -- -- return _replyFault; -- } -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * </burlap:reply>
--   * 
-- */ -- public void completeReply() -- throws IOException -- { -- expectTag(TAG_REPLY_END); -- } -- -- /** -- * Reads a header, returning null if there are no headers. -- * -- *
--   * <header>value</header>
--   * 
-- */ -- public String readHeader() -- throws IOException -- { -- int tag = parseTag(); -- -- if (tag == TAG_HEADER) { -- _sbuf.setLength(0); -- String value = parseString(_sbuf).toString(); -- expectTag(TAG_HEADER_END); -- return value; -- } -- -- _peekTag = tag; -- -- return null; -- } -- -- /** -- * Reads a null -- * -- *
--   * <null></null>
--   * 
-- */ -- public void readNull() -- throws IOException -- { -- int tag = parseTag(); -- -- switch (tag) { -- case TAG_NULL: -- expectTag(TAG_NULL_END); -- return; -- -- default: -- throw expectedTag("null", tag); -- } -- } -- -- /** -- * Reads a boolean -- * -- *
--   * <boolean>0</boolean>
--   * <boolean>1</boolean>
--   * 
-- */ -- public boolean readBoolean() -- throws IOException -- { -- int tag = parseTag(); -- -- boolean value; -- -- switch (tag) { -- case TAG_NULL: -- value = false; -- expectTag(TAG_NULL_END); -- return value; -- -- case TAG_BOOLEAN: -- value = parseInt() != 0; -- expectTag(TAG_BOOLEAN_END); -- return value; -- -- case TAG_INT: -- value = parseInt() != 0; -- expectTag(TAG_INT_END); -- return value; -- -- case TAG_LONG: -- value = parseLong() != 0; -- expectTag(TAG_LONG_END); -- return value; -- -- case TAG_DOUBLE: -- value = parseDouble() != 0; -- expectTag(TAG_DOUBLE_END); -- return value; -- -- default: -- throw expectedTag("boolean", tag); -- } -- } -- -- /** -- * Reads a byte -- * -- *
--   * <int>value</int>
--   * 
-- */ -- public byte readByte() -- throws IOException -- { -- return (byte) readInt(); -- } -- -- /** -- * Reads a short -- * -- *
--   * <int>value</int>
--   * 
-- */ -- public short readShort() -- throws IOException -- { -- return (short) readInt(); -- } -- -- /** -- * Reads an integer -- * -- *
--   * <int>value</int>
--   * 
-- */ -- public int readInt() -- throws IOException -- { -- int tag = parseTag(); -- -- int value; -- -- switch (tag) { -- case TAG_NULL: -- value = 0; -- expectTag(TAG_NULL_END); -- return value; -- -- case TAG_BOOLEAN: -- value = parseInt(); -- expectTag(TAG_BOOLEAN_END); -- return value; -- -- case TAG_INT: -- value = parseInt(); -- expectTag(TAG_INT_END); -- return value; -- -- case TAG_LONG: -- value = (int) parseLong(); -- expectTag(TAG_LONG_END); -- return value; -- -- case TAG_DOUBLE: -- value = (int) parseDouble(); -- expectTag(TAG_DOUBLE_END); -- return value; -- -- default: -- throw expectedTag("int", tag); -- } -- } -- -- /** -- * Reads a long -- * -- *
--   * <long>value</long>
--   * 
-- */ -- public long readLong() -- throws IOException -- { -- int tag = parseTag(); -- -- long value; -- -- switch (tag) { -- case TAG_NULL: -- value = 0; -- expectTag(TAG_NULL_END); -- return value; -- -- case TAG_BOOLEAN: -- value = parseInt(); -- expectTag(TAG_BOOLEAN_END); -- return value; -- -- case TAG_INT: -- value = parseInt(); -- expectTag(TAG_INT_END); -- return value; -- -- case TAG_LONG: -- value = parseLong(); -- expectTag(TAG_LONG_END); -- return value; -- -- case TAG_DOUBLE: -- value = (long) parseDouble(); -- expectTag(TAG_DOUBLE_END); -- return value; -- -- default: -- throw expectedTag("long", tag); -- } -- } -- -- /** -- * Reads a float -- * -- *
--   * <double>value</double>
--   * 
-- */ -- public float readFloat() -- throws IOException -- { -- return (float) readDouble(); -- } -- -- /** -- * Reads a double -- * -- *
--   * <double>value</double>
--   * 
-- */ -- public double readDouble() -- throws IOException -- { -- int tag = parseTag(); -- -- double value; -- -- switch (tag) { -- case TAG_NULL: -- value = 0; -- expectTag(TAG_NULL_END); -- return value; -- -- case TAG_BOOLEAN: -- value = parseInt(); -- expectTag(TAG_BOOLEAN_END); -- return value; -- -- case TAG_INT: -- value = parseInt(); -- expectTag(TAG_INT_END); -- return value; -- -- case TAG_LONG: -- value = parseLong(); -- expectTag(TAG_LONG_END); -- return value; -- -- case TAG_DOUBLE: -- value = parseDouble(); -- expectTag(TAG_DOUBLE_END); -- return value; -- -- default: -- throw expectedTag("double", tag); -- } -- } -- -- /** -- * Reads a date. -- * -- *
--   * <date>ISO-8609 date</date>
--   * 
-- */ -- public long readUTCDate() -- throws IOException -- { -- int tag = parseTag(); -- -- if (tag != TAG_DATE) -- throw error("expected date"); -- -- if (_utcCalendar == null) -- _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -- -- long value = parseDate(_utcCalendar); -- -- expectTag(TAG_DATE_END); -- -- return value; -- } -- -- /** -- * Reads a date. -- * -- *
--   * <date>ISO-8609 date</date>
--   * 
-- */ -- public long readLocalDate() -- throws IOException -- { -- int tag = parseTag(); -- -- if (tag != TAG_DATE) -- throw error("expected date"); -- -- if (_localCalendar == null) -- _localCalendar = Calendar.getInstance(); -- -- long value = parseDate(_localCalendar); -- -- expectTag(TAG_DATE_END); -- -- return value; -- } -- -- /** -- * Reads a string -- * -- *
--   * <string>value</string>
--   * 
-- */ -- public String readString() -- throws IOException -- { -- int tag = parseTag(); -- -- String value; -- -- switch (tag) { -- case TAG_NULL: -- expectTag(TAG_NULL_END); -- return null; -- -- case TAG_STRING: -- _sbuf.setLength(0); -- value = parseString(_sbuf).toString(); -- expectTag(TAG_STRING_END); -- return value; -- -- case TAG_XML: -- _sbuf.setLength(0); -- value = parseString(_sbuf).toString(); -- expectTag(TAG_XML_END); -- return value; -- -- default: -- throw expectedTag("string", tag); -- } -- } -- -- /** -- * Reads an XML node. -- * -- *
--   * &xml;xml string</xml>
--   * 
-- */ -- public org.w3c.dom.Node readNode() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'S': -- case 's': -- case 'X': -- case 'x': -- throw error("can't cope"); -- -- default: -- throw expectedTag("string", tag); -- } -- } -- -- /** -- * Reads a byte array -- * -- *
--   * <base64>...</base64>
--   * 
-- */ -- public byte []readBytes() -- throws IOException -- { -- int tag = parseTag(); -- -- switch (tag) { -- case TAG_NULL: -- expectTag(TAG_NULL_END); -- return null; -- -- case TAG_BASE64: -- byte []data = parseBytes(); -- expectTag(TAG_BASE64_END); -- -- return data; -- -- default: -- throw expectedTag("bytes", tag); -- } -- } -- -- /** -- * Reads a length -- * -- *
--   * <length>value</length>
--   * 
-- */ -- public int readLength() -- throws IOException -- { -- int tag = parseTag(); -- -- if (tag != TAG_LENGTH) { -- _peekTag = tag; -- return -1; -- } -- -- int value = parseInt(); -- -- expectTag(TAG_LENGTH_END); -- -- return value; -- } -- -- /** -- * Reads a fault. -- */ -- private HashMap readFault() -- throws IOException -- { -- HashMap map = new HashMap(); -- -- int code = parseTag(); -- for (; code >= 0 && code != TAG_FAULT_END; code = parseTag()) { -- _peekTag = code; -- -- Object key = readObject(); -- Object value = readObject(); -- -- if (key != null && value != null) -- map.put(key, value); -- } -- -- if (code != TAG_FAULT_END) -- throw expectedTag("fault", code); -- -- return map; -- } -- -- /** -- * Reads an object from the input stream with an expected type. -- */ -- public Object readObject(Class cl) -- throws IOException -- { -- if (cl == null || cl.equals(Object.class)) -- return readObject(); -- -- int tag = parseTag(); -- -- switch (tag) { -- case TAG_NULL: -- expectTag(TAG_NULL_END); -- return null; -- -- case TAG_MAP: -- { -- String type = readType(); -- Deserializer reader; -- -- reader = _serializerFactory.getObjectDeserializer(type, cl); -- -- return reader.readMap(this); -- } -- -- case TAG_LIST: -- { -- String type = readType(); -- int length = readLength(); -- -- Deserializer reader; -- reader = _serializerFactory.getObjectDeserializer(type, cl); -- -- return reader.readList(this, length); -- } -- -- case TAG_REF: -- { -- int ref = parseInt(); -- -- expectTag(TAG_REF_END); -- -- return _refs.get(ref); -- } -- -- case TAG_REMOTE: -- { -- String type = readType(); -- String url = readString(); -- -- expectTag(TAG_REMOTE_END); -- -- Object remote = resolveRemote(type, url); -- -- return remote; -- } -- } -- -- _peekTag = tag; -- -- Object value = _serializerFactory.getDeserializer(cl).readObject(this); -- -- return value; -- } -- -- /** -- * Reads an arbitrary object from the input stream when the type -- * is unknown. -- */ -- public Object readObject() -- throws IOException -- { -- int tag = parseTag(); -- -- switch (tag) { -- case TAG_NULL: -- expectTag(TAG_NULL_END); -- return null; -- -- case TAG_BOOLEAN: -- { -- int value = parseInt(); -- expectTag(TAG_BOOLEAN_END); -- return new Boolean(value != 0); -- } -- -- case TAG_INT: -- { -- int value = parseInt(); -- expectTag(TAG_INT_END); -- return new Integer(value); -- } -- -- case TAG_LONG: -- { -- long value = parseLong(); -- expectTag(TAG_LONG_END); -- return new Long(value); -- } -- -- case TAG_DOUBLE: -- { -- double value = parseDouble(); -- expectTag(TAG_DOUBLE_END); -- return new Double(value); -- } -- -- case TAG_DATE: -- { -- long value = parseDate(); -- expectTag(TAG_DATE_END); -- return new Date(value); -- } -- -- case TAG_XML: -- { -- return parseXML(); -- } -- -- case TAG_STRING: -- { -- _sbuf.setLength(0); -- -- String value = parseString(_sbuf).toString(); -- -- expectTag(TAG_STRING_END); -- -- return value; -- } -- -- case TAG_BASE64: -- { -- byte []data = parseBytes(); -- -- expectTag(TAG_BASE64_END); -- -- return data; -- } -- -- case TAG_LIST: -- { -- String type = readType(); -- int length = readLength(); -- -- return _serializerFactory.readList(this, length, type); -- } -- -- case TAG_MAP: -- { -- String type = readType(); -- Deserializer deserializer; -- deserializer = _serializerFactory.getObjectDeserializer(type); -- -- return deserializer.readMap(this); -- } -- -- case TAG_REF: -- { -- int ref = parseInt(); -- -- expectTag(TAG_REF_END); -- -- return _refs.get(ref); -- } -- -- case TAG_REMOTE: -- { -- String type = readType(); -- String url = readString(); -- -- expectTag(TAG_REMOTE_END); -- -- return resolveRemote(type, url); -- } -- -- default: -- throw error("unknown code:" + tagName(tag)); -- } -- } -- -- /** -- * Reads a remote object. -- */ -- public Object readRemote() -- throws IOException -- { -- String type = readType(); -- String url = readString(); -- -- return resolveRemote(type, url); -- } -- -- /** -- * Reads a reference. -- */ -- public Object readRef() -- throws IOException -- { -- return _refs.get(parseInt()); -- } -- -- /** -- * Reads the start of a list. -- */ -- public int readListStart() -- throws IOException -- { -- return parseTag(); -- } -- -- /** -- * Reads the start of a map. -- */ -- public int readMapStart() -- throws IOException -- { -- return parseTag(); -- } -- -- /** -- * Returns true if this is the end of a list or a map. -- */ -- public boolean isEnd() -- throws IOException -- { -- int code = parseTag(); -- -- _peekTag = code; -- -- return (code < 0 || code >= 100); -- } -- -- /** -- * Reads the end byte. -- */ -- public void readEnd() -- throws IOException -- { -- int code = parseTag(); -- -- if (code < 100) -- throw error("unknown code:" + (char) code); -- } -- -- /** -- * Reads the end of the map -- */ -- public void readMapEnd() -- throws IOException -- { -- expectTag(TAG_MAP_END); -- } -- -- /** -- * Reads the end of the map -- */ -- public void readListEnd() -- throws IOException -- { -- expectTag(TAG_LIST_END); -- } -- -- /** -- * Adds a list/map reference. -- */ -- public int addRef(Object ref) -- { -- if (_refs == null) -- _refs = new ArrayList(); -- -- _refs.add(ref); -- -- return _refs.size() - 1; -- } -- -- /** -- * Adds a list/map reference. -- */ -- public void setRef(int i, Object ref) -- { -- _refs.set(i, ref); -- } -- -- /** -- * Resolves a remote object. -- */ -- public Object resolveRemote(String type, String url) -- throws IOException -- { -- HessianRemoteResolver resolver = getRemoteResolver(); -- -- if (resolver != null) -- return resolver.lookup(type, url); -- else -- return new BurlapRemote(type, url); -- } -- -- /** -- * Parses a type from the stream. -- * -- *
--   * <type>type</type>
--   * 
-- */ -- public String readType() -- throws IOException -- { -- int code = parseTag(); -- -- if (code != TAG_TYPE) { -- _peekTag = code; -- return ""; -- } -- -- _sbuf.setLength(0); -- int ch; -- while ((ch = readChar()) >= 0) -- _sbuf.append((char) ch); -- String type = _sbuf.toString(); -- -- expectTag(TAG_TYPE_END); -- -- return type; -- } -- -- /** -- * Parses a 32-bit integer value from the stream. -- */ -- private int parseInt() -- throws IOException -- { -- int sign = 1; -- -- int ch = read(); -- if (ch == '-') { -- sign = -1; -- ch = read(); -- } -- -- int value = 0; -- for (; ch >= '0' && ch <= '9'; ch = read()) -- value = 10 * value + ch - '0'; -- -- _peek = ch; -- -- return sign * value; -- } -- -- /** -- * Parses a 64-bit long value from the stream. -- */ -- private long parseLong() -- throws IOException -- { -- int sign = 1; -- -- int ch = read(); -- if (ch == '-') { -- sign = -1; -- ch = read(); -- } -- -- long value = 0; -- for (; ch >= '0' && ch <= '9'; ch = read()) -- value = 10 * value + ch - '0'; -- -- _peek = ch; -- -- return sign * value; -- } -- -- /** -- * Parses a 64-bit double value from the stream. -- * -- *
--   * b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- private double parseDouble() -- throws IOException -- { -- int ch = skipWhitespace(); -- -- _sbuf.setLength(0); -- -- for (; ! isWhitespace(ch) && ch != '<'; ch = read()) -- _sbuf.append((char) ch); -- -- _peek = ch; -- -- return new Double(_sbuf.toString()).doubleValue(); -- } -- -- /** -- * Parses a date value from the stream. -- */ -- protected long parseDate() -- throws IOException -- { -- if (_utcCalendar == null) -- _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -- -- return parseDate(_utcCalendar); -- } -- -- /** -- * Parses a date value from the stream. -- */ -- protected long parseDate(Calendar calendar) -- throws IOException -- { -- int ch = skipWhitespace(); -- -- int year = 0; -- for (int i = 0; i < 4; i++) { -- if (ch >= '0' && ch <= '9') -- year = 10 * year + ch - '0'; -- else -- throw expectedChar("year", ch); -- -- ch = read(); -- } -- -- int month = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- month = 10 * month + ch - '0'; -- else -- throw expectedChar("month", ch); -- -- ch = read(); -- } -- -- int day = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- day = 10 * day + ch - '0'; -- else -- throw expectedChar("day", ch); -- -- ch = read(); -- } -- -- if (ch != 'T') -- throw expectedChar("`T'", ch); -- -- ch = read(); -- -- int hour = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- hour = 10 * hour + ch - '0'; -- else -- throw expectedChar("hour", ch); -- -- ch = read(); -- } -- -- int minute = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- minute = 10 * minute + ch - '0'; -- else -- throw expectedChar("minute", ch); -- -- ch = read(); -- } -- -- int second = 0; -- for (int i = 0; i < 2; i++) { -- if (ch >= '0' && ch <= '9') -- second = 10 * second + ch - '0'; -- else -- throw expectedChar("second", ch); -- -- ch = read(); -- } -- -- int ms = 0; -- if (ch == '.') { -- ch = read(); -- -- while (ch >= '0' && ch <= '9') { -- ms = 10 * ms + ch - '0'; -- -- ch = read(); -- } -- } -- -- for (; ch > 0 && ch != '<'; ch = read()) { -- } -- -- _peek = ch; -- -- calendar.set(Calendar.YEAR, year); -- calendar.set(Calendar.MONTH, month - 1); -- calendar.set(Calendar.DAY_OF_MONTH, day); -- calendar.set(Calendar.HOUR_OF_DAY, hour); -- calendar.set(Calendar.MINUTE, minute); -- calendar.set(Calendar.SECOND, second); -- calendar.set(Calendar.MILLISECOND, ms); -- -- return calendar.getTime().getTime(); -- } -- -- protected String parseString() -- throws IOException -- { -- _sbuf.setLength(0); -- -- return parseString(_sbuf).toString(); -- } -- -- /** -- * Parses a string value from the stream. The burlap object's -- * string buffer is used for the result. -- */ -- protected StringBuffer parseString(StringBuffer sbuf) -- throws IOException -- { -- int ch; -- -- while ((ch = readChar()) >= 0) -- sbuf.append((char) ch); -- -- return sbuf; -- } -- -- org.w3c.dom.Node parseXML() -- throws IOException -- { -- throw error("help!"); -- } -- -- /** -- * Reads a character from the underlying stream. -- */ -- int readChar() -- throws IOException -- { -- int ch = read(); -- -- if (ch == '<' || ch < 0) { -- _peek = ch; -- return -1; -- } -- -- if (ch == '&') { -- ch = read(); -- -- if (ch == '#') { -- ch = read(); -- -- if (ch >= '0' && ch <= '9') { -- int v = 0; -- for (; ch >= '0' && ch <= '9'; ch = read()) { -- v = 10 * v + ch - '0'; -- } -- -- if (ch != ';') -- throw error("expected ';' at " + (char) ch); -- -- return (char) v; -- } -- else -- throw error("expected digit at " + (char) ch); -- } -- else { -- _entityBuffer.setLength(0); -- -- for (; ch >= 'a' && ch <= 'z'; ch = read()) -- _entityBuffer.append((char) ch); -- -- String entity = _entityBuffer.toString(); -- -- if (ch != ';') -- throw expectedChar("';'", ch); -- -- if (entity.equals("amp")) -- return '&'; -- else if (entity.equals("apos")) -- return '\''; -- else if (entity.equals("quot")) -- return '"'; -- else if (entity.equals("lt")) -- return '<'; -- else if (entity.equals("gt")) -- return '>'; -- else -- throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); -- } -- } -- else if (ch < 0x80) -- return (char) ch; -- else if ((ch & 0xe0) == 0xc0) { -- int ch1 = read(); -- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -- -- return (char) v; -- } -- else if ((ch & 0xf0) == 0xe0) { -- int ch1 = read(); -- int ch2 = read(); -- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -- -- return (char) v; -- } -- else -- throw new BurlapProtocolException("bad utf-8 encoding"); -- } -- -- /** -- * Parses a byte array. -- */ -- protected byte []parseBytes() -- throws IOException -- { -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- parseBytes(bos); -- -- return bos.toByteArray(); -- } -- -- /** -- * Parses a byte array. -- */ -- protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) -- throws IOException -- { -- int ch; -- for (ch = skipWhitespace(); ch >= 0 && ch != '<'; ch = skipWhitespace()) { -- int b1 = ch; -- int b2 = read(); -- int b3 = read(); -- int b4 = read(); -- -- if (b4 != '=') { -- int chunk = ((base64Decode[b1] << 18) + -- (base64Decode[b2] << 12) + -- (base64Decode[b3] << 6) + -- (base64Decode[b4])); -- -- bos.write(chunk >> 16); -- bos.write(chunk >> 8); -- bos.write(chunk); -- } -- else if (b3 != '=') { -- int chunk = ((base64Decode[b1] << 10) + -- (base64Decode[b2] << 4) + -- (base64Decode[b3] >> 2)); -- -- bos.write(chunk >> 8); -- bos.write(chunk); -- } -- else { -- int chunk = ((base64Decode[b1] << 2) + -- (base64Decode[b2] >> 4)); -- -- bos.write(chunk); -- } -- } -- -- if (ch == '<') -- _peek = ch; -- -- return bos; -- } -- -- public void expectTag(int expectTag) -- throws IOException -- { -- int tag = parseTag(); -- -- if (tag != expectTag) -- throw error("expected " + tagName(expectTag) + " at " + tagName(tag)); -- } -- -- /** -- * Parses a tag. Returns true if it's a start tag. -- */ -- protected int parseTag() -- throws IOException -- { -- if (_peekTag >= 0) { -- int tag = _peekTag; -- _peekTag = -1; -- return tag; -- } -- -- int ch = skipWhitespace(); -- int endTagDelta = 0; -- -- if (ch != '<') -- throw expectedChar("'<'", ch); -- -- ch = read(); -- if (ch == '/') { -- endTagDelta = 100; -- ch = _is.read(); -- } -- -- if (! isTagChar(ch)) -- throw expectedChar("tag", ch); -- -- _sbuf.setLength(0); -- for (; isTagChar(ch); ch = read()) -- _sbuf.append((char) ch); -- -- if (ch != '>') -- throw expectedChar("'>'", ch); -- -- Integer value = (Integer) _tagMap.get(_sbuf.toString()); -- if (value == null) -- throw error("Unknown tag <" + _sbuf + ">"); -- -- return value.intValue() + endTagDelta; -- } -- -- /** -- * Returns true if the character is a valid tag character. -- */ -- private boolean isTagChar(int ch) -- { -- return (ch >= 'a' && ch <= 'z' || -- ch >= 'A' && ch <= 'Z' || -- ch >= '0' && ch <= '9' || -- ch == ':' || ch == '-'); -- } -- -- protected int skipWhitespace() -- throws IOException -- { -- int ch = read(); -- -- for (; -- ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -- ch = read()) { -- } -- -- return ch; -- } -- -- protected boolean isWhitespace(int ch) -- throws IOException -- { -- return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -- } -- -- /** -- * Reads bytes from the underlying stream. -- */ -- int read(byte []buffer, int offset, int length) -- throws IOException -- { -- throw new UnsupportedOperationException(); -- } -- -- int read() -- throws IOException -- { -- if (_peek >= 0) { -- int value = _peek; -- _peek = -1; -- return value; -- } -- -- int ch = _is.read(); -- return ch; -- } -- -- public Reader getReader() -- { -- return null; -- } -- -- public InputStream readInputStream() -- { -- return null; -- } -- -- public InputStream getInputStream() -- { -- return null; -- } -- -- protected IOException expectBeginTag(String expect, String tag) -- { -- return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); -- } -- -- protected IOException expectedChar(String expect, int ch) -- { -- if (ch < 0) -- return error("expected " + expect + " at end of file"); -- else -- return error("expected " + expect + " at " + (char) ch); -- } -- -- protected IOException expectedTag(String expect, int tag) -- { -- return error("expected " + expect + " at " + tagName(tag)); -- } -- -- protected IOException error(String message) -- { -- return new BurlapProtocolException(message); -- } -- -- protected static String tagName(int tag) -- { -- switch (tag) { -- case TAG_NULL: -- return ""; -- case TAG_NULL_END: -- return ""; -- -- case TAG_BOOLEAN: -- return ""; -- case TAG_BOOLEAN_END: -- return ""; -- -- case TAG_INT: -- return ""; -- case TAG_INT_END: -- return ""; -- -- case TAG_LONG: -- return ""; -- case TAG_LONG_END: -- return ""; -- -- case TAG_DOUBLE: -- return ""; -- case TAG_DOUBLE_END: -- return ""; -- -- case TAG_STRING: -- return ""; -- case TAG_STRING_END: -- return ""; -- -- case TAG_XML: -- return ""; -- case TAG_XML_END: -- return ""; -- -- case TAG_BASE64: -- return ""; -- case TAG_BASE64_END: -- return ""; -- -- case TAG_MAP: -- return ""; -- case TAG_MAP_END: -- return ""; -- -- case TAG_LIST: -- return ""; -- case TAG_LIST_END: -- return ""; -- -- case TAG_TYPE: -- return ""; -- case TAG_TYPE_END: -- return ""; -- -- case TAG_LENGTH: -- return ""; -- case TAG_LENGTH_END: -- return ""; -- -- case TAG_REF: -- return ""; -- case TAG_REF_END: -- return ""; -- -- case TAG_REMOTE: -- return ""; -- case TAG_REMOTE_END: -- return ""; -- -- case TAG_CALL: -- return ""; -- case TAG_CALL_END: -- return ""; -- -- case TAG_REPLY: -- return ""; -- case TAG_REPLY_END: -- return ""; -- -- case TAG_HEADER: -- return "
"; -- case TAG_HEADER_END: -- return "
"; -- -- case TAG_FAULT: -- return ""; -- case TAG_FAULT_END: -- return ""; -- -- case -1: -- return "end of file"; -- -- default: -- return "unknown " + tag; -- } -- } -- -- -- static { -- _tagMap = new HashMap(); -- _tagMap.put("null", new Integer(TAG_NULL)); -- -- _tagMap.put("boolean", new Integer(TAG_BOOLEAN)); -- _tagMap.put("int", new Integer(TAG_INT)); -- _tagMap.put("long", new Integer(TAG_LONG)); -- _tagMap.put("double", new Integer(TAG_DOUBLE)); -- -- _tagMap.put("date", new Integer(TAG_DATE)); -- -- _tagMap.put("string", new Integer(TAG_STRING)); -- _tagMap.put("xml", new Integer(TAG_XML)); -- _tagMap.put("base64", new Integer(TAG_BASE64)); -- -- _tagMap.put("map", new Integer(TAG_MAP)); -- _tagMap.put("list", new Integer(TAG_LIST)); -- -- _tagMap.put("type", new Integer(TAG_TYPE)); -- _tagMap.put("length", new Integer(TAG_LENGTH)); -- -- _tagMap.put("ref", new Integer(TAG_REF)); -- _tagMap.put("remote", new Integer(TAG_REMOTE)); -- -- _tagMap.put("burlap:call", new Integer(TAG_CALL)); -- _tagMap.put("burlap:reply", new Integer(TAG_REPLY)); -- _tagMap.put("fault", new Integer(TAG_FAULT)); -- _tagMap.put("method", new Integer(TAG_METHOD)); -- _tagMap.put("header", new Integer(TAG_HEADER)); -- } -- -- static { -- base64Decode = new int[256]; -- for (int i = 'A'; i <= 'Z'; i++) -- base64Decode[i] = i - 'A'; -- for (int i = 'a'; i <= 'z'; i++) -- base64Decode[i] = i - 'a' + 26; -- for (int i = '0'; i <= '9'; i++) -- base64Decode[i] = i - '0' + 52; -- base64Decode['+'] = 62; -- base64Decode['/'] = 63; -- } -- -- private static Field getDetailMessageField() -- { -- if (_detailMessageField == null) { -- try { -- _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); -- _detailMessageField.setAccessible(true); -- } catch (Throwable e) { -- } -- } -- -- return _detailMessageField; -- -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import com.caucho.hessian.io.Deserializer; -+import com.caucho.hessian.io.HessianRemoteResolver; -+import com.caucho.hessian.io.SerializerFactory; -+ -+import java.io.ByteArrayOutputStream; -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.Reader; -+import java.lang.reflect.Field; -+import java.util.ArrayList; -+import java.util.Calendar; -+import java.util.Date; -+import java.util.HashMap; -+import java.util.TimeZone; -+ -+/** -+ * Input stream for Burlap requests. -+ * -+ *

BurlapInput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * InputStream is = ...; // from http connection
-+ * BurlapInput in = new BurlapInput(is);
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+public class BurlapInput extends AbstractBurlapInput { -+ private static int []base64Decode; -+ -+ public final static int TAG_EOF = -1; -+ -+ public final static int TAG_NULL = 0; -+ public final static int TAG_BOOLEAN = 1; -+ public final static int TAG_INT = 2; -+ public final static int TAG_LONG = 3; -+ public final static int TAG_DOUBLE = 4; -+ public final static int TAG_DATE = 5; -+ public final static int TAG_STRING = 6; -+ public final static int TAG_XML = 7; -+ public final static int TAG_BASE64 = 8; -+ public final static int TAG_MAP = 9; -+ public final static int TAG_LIST = 10; -+ public final static int TAG_TYPE = 11; -+ public final static int TAG_LENGTH = 12; -+ -+ public final static int TAG_REF = 13; -+ public final static int TAG_REMOTE = 14; -+ -+ public final static int TAG_CALL = 15; -+ public final static int TAG_REPLY = 16; -+ public final static int TAG_FAULT = 17; -+ public final static int TAG_METHOD = 18; -+ public final static int TAG_HEADER = 19; -+ -+ public final static int TAG_NULL_END = TAG_NULL + 100; -+ public final static int TAG_BOOLEAN_END = TAG_BOOLEAN + 100; -+ public final static int TAG_INT_END = TAG_INT + 100; -+ public final static int TAG_LONG_END = TAG_LONG + 100; -+ public final static int TAG_DOUBLE_END = TAG_DOUBLE + 100; -+ public final static int TAG_DATE_END = TAG_DATE + 100; -+ public final static int TAG_STRING_END = TAG_STRING + 100; -+ public final static int TAG_XML_END = TAG_XML + 100; -+ public final static int TAG_BASE64_END = TAG_BASE64 + 100; -+ public final static int TAG_MAP_END = TAG_MAP + 100; -+ public final static int TAG_LIST_END = TAG_LIST + 100; -+ public final static int TAG_TYPE_END = TAG_TYPE + 100; -+ public final static int TAG_LENGTH_END = TAG_LENGTH + 100; -+ -+ public final static int TAG_REF_END = TAG_REF + 100; -+ public final static int TAG_REMOTE_END = TAG_REMOTE + 100; -+ -+ public final static int TAG_CALL_END = TAG_CALL + 100; -+ public final static int TAG_REPLY_END = TAG_REPLY + 100; -+ public final static int TAG_FAULT_END = TAG_FAULT + 100; -+ public final static int TAG_METHOD_END = TAG_METHOD + 100; -+ public final static int TAG_HEADER_END = TAG_HEADER + 100; -+ -+ private static HashMap _tagMap; -+ -+ private static Field _detailMessageField; -+ -+ protected SerializerFactory _serializerFactory; -+ -+ protected ArrayList _refs; -+ -+ // the underlying input stream -+ private InputStream _is; -+ // a peek character -+ protected int _peek = -1; -+ -+ // the method for a call -+ private String _method; -+ -+ private int _peekTag; -+ -+ private Throwable _replyFault; -+ -+ protected StringBuffer _sbuf = new StringBuffer(); -+ protected StringBuffer _entityBuffer = new StringBuffer(); -+ -+ protected Calendar _utcCalendar; -+ protected Calendar _localCalendar; -+ -+ /** -+ * Creates an uninitialized Burlap input stream. -+ */ -+ public BurlapInput() -+ { -+ } -+ -+ /** -+ * Creates a new Burlap input stream, initialized with an -+ * underlying input stream. -+ * -+ * @param is the underlying input stream. -+ */ -+ public BurlapInput(InputStream is) -+ { -+ init(is); -+ } -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ public SerializerFactory getSerializerFactory() -+ { -+ return _serializerFactory; -+ } -+ -+ /** -+ * Initialize the burlap stream with the underlying input stream. -+ */ -+ public void init(InputStream is) -+ { -+ _is = is; -+ _method = null; -+ _peek = -1; -+ _peekTag = -1; -+ _refs = null; -+ _replyFault = null; -+ -+ if (_serializerFactory == null) -+ _serializerFactory = new SerializerFactory(); -+ } -+ -+ /** -+ * Returns the calls method -+ */ -+ public String getMethod() -+ { -+ return _method; -+ } -+ -+ /** -+ * Returns any reply fault. -+ */ -+ public Throwable getReplyFault() -+ { -+ return _replyFault; -+ } -+ -+ /** -+ * Starts reading the call -+ * -+ *
-+   * <burlap:call>
-+   * <method>method</method>
-+   * 
-+ */ -+ public void startCall() -+ throws IOException -+ { -+ readCall(); -+ -+ while ((readHeader() != null)) -+ readObject(); -+ -+ readMethod(); -+ } -+ -+ /** -+ * Starts reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * <burlap:call>
-+   * 
-+ */ -+ public int readCall() -+ throws IOException -+ { -+ expectTag(TAG_CALL); -+ -+ int major = 1; -+ int minor = 0; -+ -+ return (major << 16) + minor; -+ } -+ -+ /** -+ * Reads the method -+ * -+ *
-+   * <method>method</method>
-+   * 
-+ */ -+ public String readMethod() -+ throws IOException -+ { -+ expectTag(TAG_METHOD); -+ -+ _method = parseString(); -+ -+ expectTag(TAG_METHOD_END); -+ -+ return _method; -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * </burlap:call>
-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ expectTag(TAG_CALL_END); -+ } -+ -+ /** -+ * Reads a reply as an object. -+ * If the reply has a fault, throws the exception. -+ */ -+ public Object readReply(Class expectedClass) -+ throws Throwable -+ { -+ expectTag(TAG_REPLY); -+ -+ int tag = parseTag(); -+ -+ if (tag == TAG_FAULT) -+ throw prepareFault(); -+ else { -+ _peekTag = tag; -+ Object value = readObject(expectedClass); -+ -+ expectTag(TAG_REPLY_END); -+ -+ return value; -+ } -+ } -+ -+ /** -+ * Starts reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * <burlap:reply>
-+   * <value>
-+   * 
-+ */ -+ public void startReply() -+ throws Throwable -+ { -+ expectTag(TAG_REPLY); -+ -+ int tag = parseTag(); -+ if (tag == TAG_FAULT) -+ throw prepareFault(); -+ else -+ _peekTag = tag; -+ } -+ -+ /** -+ * Prepares the fault. -+ */ -+ private Throwable prepareFault() -+ throws IOException -+ { -+ HashMap fault = readFault(); -+ -+ Object detail = fault.get("detail"); -+ String message = (String) fault.get("message"); -+ -+ if (detail instanceof Throwable) { -+ _replyFault = (Throwable) detail; -+ -+ Field detailMessageField = getDetailMessageField(); -+ -+ if (message != null && detailMessageField != null) { -+ try { -+ detailMessageField.set(_replyFault, message); -+ } catch (Throwable e) { -+ } -+ } -+ -+ return _replyFault; -+ } -+ -+ else { -+ String code = (String) fault.get("code"); -+ -+ _replyFault = new BurlapServiceException(message, code, detail); -+ -+ return _replyFault; -+ } -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * </burlap:reply>
-+   * 
-+ */ -+ public void completeReply() -+ throws IOException -+ { -+ expectTag(TAG_REPLY_END); -+ } -+ -+ /** -+ * Reads a header, returning null if there are no headers. -+ * -+ *
-+   * <header>value</header>
-+   * 
-+ */ -+ public String readHeader() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ if (tag == TAG_HEADER) { -+ _sbuf.setLength(0); -+ String value = parseString(_sbuf).toString(); -+ expectTag(TAG_HEADER_END); -+ return value; -+ } -+ -+ _peekTag = tag; -+ -+ return null; -+ } -+ -+ /** -+ * Reads a null -+ * -+ *
-+   * <null></null>
-+   * 
-+ */ -+ public void readNull() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ switch (tag) { -+ case TAG_NULL: -+ expectTag(TAG_NULL_END); -+ return; -+ -+ default: -+ throw expectedTag("null", tag); -+ } -+ } -+ -+ /** -+ * Reads a boolean -+ * -+ *
-+   * <boolean>0</boolean>
-+   * <boolean>1</boolean>
-+   * 
-+ */ -+ public boolean readBoolean() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ boolean value; -+ -+ switch (tag) { -+ case TAG_NULL: -+ value = false; -+ expectTag(TAG_NULL_END); -+ return value; -+ -+ case TAG_BOOLEAN: -+ value = parseInt() != 0; -+ expectTag(TAG_BOOLEAN_END); -+ return value; -+ -+ case TAG_INT: -+ value = parseInt() != 0; -+ expectTag(TAG_INT_END); -+ return value; -+ -+ case TAG_LONG: -+ value = parseLong() != 0; -+ expectTag(TAG_LONG_END); -+ return value; -+ -+ case TAG_DOUBLE: -+ value = parseDouble() != 0; -+ expectTag(TAG_DOUBLE_END); -+ return value; -+ -+ default: -+ throw expectedTag("boolean", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte -+ * -+ *
-+   * <int>value</int>
-+   * 
-+ */ -+ public byte readByte() -+ throws IOException -+ { -+ return (byte) readInt(); -+ } -+ -+ /** -+ * Reads a short -+ * -+ *
-+   * <int>value</int>
-+   * 
-+ */ -+ public short readShort() -+ throws IOException -+ { -+ return (short) readInt(); -+ } -+ -+ /** -+ * Reads an integer -+ * -+ *
-+   * <int>value</int>
-+   * 
-+ */ -+ public int readInt() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ int value; -+ -+ switch (tag) { -+ case TAG_NULL: -+ value = 0; -+ expectTag(TAG_NULL_END); -+ return value; -+ -+ case TAG_BOOLEAN: -+ value = parseInt(); -+ expectTag(TAG_BOOLEAN_END); -+ return value; -+ -+ case TAG_INT: -+ value = parseInt(); -+ expectTag(TAG_INT_END); -+ return value; -+ -+ case TAG_LONG: -+ value = (int) parseLong(); -+ expectTag(TAG_LONG_END); -+ return value; -+ -+ case TAG_DOUBLE: -+ value = (int) parseDouble(); -+ expectTag(TAG_DOUBLE_END); -+ return value; -+ -+ default: -+ throw expectedTag("int", tag); -+ } -+ } -+ -+ /** -+ * Reads a long -+ * -+ *
-+   * <long>value</long>
-+   * 
-+ */ -+ public long readLong() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ long value; -+ -+ switch (tag) { -+ case TAG_NULL: -+ value = 0; -+ expectTag(TAG_NULL_END); -+ return value; -+ -+ case TAG_BOOLEAN: -+ value = parseInt(); -+ expectTag(TAG_BOOLEAN_END); -+ return value; -+ -+ case TAG_INT: -+ value = parseInt(); -+ expectTag(TAG_INT_END); -+ return value; -+ -+ case TAG_LONG: -+ value = parseLong(); -+ expectTag(TAG_LONG_END); -+ return value; -+ -+ case TAG_DOUBLE: -+ value = (long) parseDouble(); -+ expectTag(TAG_DOUBLE_END); -+ return value; -+ -+ default: -+ throw expectedTag("long", tag); -+ } -+ } -+ -+ /** -+ * Reads a float -+ * -+ *
-+   * <double>value</double>
-+   * 
-+ */ -+ public float readFloat() -+ throws IOException -+ { -+ return (float) readDouble(); -+ } -+ -+ /** -+ * Reads a double -+ * -+ *
-+   * <double>value</double>
-+   * 
-+ */ -+ public double readDouble() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ double value; -+ -+ switch (tag) { -+ case TAG_NULL: -+ value = 0; -+ expectTag(TAG_NULL_END); -+ return value; -+ -+ case TAG_BOOLEAN: -+ value = parseInt(); -+ expectTag(TAG_BOOLEAN_END); -+ return value; -+ -+ case TAG_INT: -+ value = parseInt(); -+ expectTag(TAG_INT_END); -+ return value; -+ -+ case TAG_LONG: -+ value = parseLong(); -+ expectTag(TAG_LONG_END); -+ return value; -+ -+ case TAG_DOUBLE: -+ value = parseDouble(); -+ expectTag(TAG_DOUBLE_END); -+ return value; -+ -+ default: -+ throw expectedTag("double", tag); -+ } -+ } -+ -+ /** -+ * Reads a date. -+ * -+ *
-+   * <date>ISO-8609 date</date>
-+   * 
-+ */ -+ public long readUTCDate() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ if (tag != TAG_DATE) -+ throw error("expected date"); -+ -+ if (_utcCalendar == null) -+ _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -+ -+ long value = parseDate(_utcCalendar); -+ -+ expectTag(TAG_DATE_END); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a date. -+ * -+ *
-+   * <date>ISO-8609 date</date>
-+   * 
-+ */ -+ public long readLocalDate() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ if (tag != TAG_DATE) -+ throw error("expected date"); -+ -+ if (_localCalendar == null) -+ _localCalendar = Calendar.getInstance(); -+ -+ long value = parseDate(_localCalendar); -+ -+ expectTag(TAG_DATE_END); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a string -+ * -+ *
-+   * <string>value</string>
-+   * 
-+ */ -+ public String readString() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ String value; -+ -+ switch (tag) { -+ case TAG_NULL: -+ expectTag(TAG_NULL_END); -+ return null; -+ -+ case TAG_STRING: -+ _sbuf.setLength(0); -+ value = parseString(_sbuf).toString(); -+ expectTag(TAG_STRING_END); -+ return value; -+ -+ case TAG_XML: -+ _sbuf.setLength(0); -+ value = parseString(_sbuf).toString(); -+ expectTag(TAG_XML_END); -+ return value; -+ -+ default: -+ throw expectedTag("string", tag); -+ } -+ } -+ -+ /** -+ * Reads an XML node. -+ * -+ *
-+   * &xml;xml string</xml>
-+   * 
-+ */ -+ public org.w3c.dom.Node readNode() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'S': -+ case 's': -+ case 'X': -+ case 'x': -+ throw error("can't cope"); -+ -+ default: -+ throw expectedTag("string", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte array -+ * -+ *
-+   * <base64>...</base64>
-+   * 
-+ */ -+ public byte []readBytes() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ switch (tag) { -+ case TAG_NULL: -+ expectTag(TAG_NULL_END); -+ return null; -+ -+ case TAG_BASE64: -+ byte []data = parseBytes(); -+ expectTag(TAG_BASE64_END); -+ -+ return data; -+ -+ default: -+ throw expectedTag("bytes", tag); -+ } -+ } -+ -+ /** -+ * Reads a length -+ * -+ *
-+   * <length>value</length>
-+   * 
-+ */ -+ public int readLength() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ if (tag != TAG_LENGTH) { -+ _peekTag = tag; -+ return -1; -+ } -+ -+ int value = parseInt(); -+ -+ expectTag(TAG_LENGTH_END); -+ -+ return value; -+ } -+ -+ /** -+ * Reads a fault. -+ */ -+ private HashMap readFault() -+ throws IOException -+ { -+ HashMap map = new HashMap(); -+ -+ int code = parseTag(); -+ for (; code >= 0 && code != TAG_FAULT_END; code = parseTag()) { -+ _peekTag = code; -+ -+ Object key = readObject(); -+ Object value = readObject(); -+ -+ if (key != null && value != null) -+ map.put(key, value); -+ } -+ -+ if (code != TAG_FAULT_END) -+ throw expectedTag("fault", code); -+ -+ return map; -+ } -+ -+ /** -+ * Reads an object from the input stream with an expected type. -+ */ -+ public Object readObject(Class cl) -+ throws IOException -+ { -+ if (cl == null || cl.equals(Object.class)) -+ return readObject(); -+ -+ int tag = parseTag(); -+ -+ switch (tag) { -+ case TAG_NULL: -+ expectTag(TAG_NULL_END); -+ return null; -+ -+ case TAG_MAP: -+ { -+ String type = readType(); -+ Deserializer reader; -+ -+ reader = _serializerFactory.getObjectDeserializer(type, cl); -+ -+ return reader.readMap(this); -+ } -+ -+ case TAG_LIST: -+ { -+ String type = readType(); -+ int length = readLength(); -+ -+ Deserializer reader; -+ reader = _serializerFactory.getObjectDeserializer(type, cl); -+ -+ return reader.readList(this, length); -+ } -+ -+ case TAG_REF: -+ { -+ int ref = parseInt(); -+ -+ expectTag(TAG_REF_END); -+ -+ return _refs.get(ref); -+ } -+ -+ case TAG_REMOTE: -+ { -+ String type = readType(); -+ String url = readString(); -+ -+ expectTag(TAG_REMOTE_END); -+ -+ Object remote = resolveRemote(type, url); -+ -+ return remote; -+ } -+ } -+ -+ _peekTag = tag; -+ -+ Object value = _serializerFactory.getDeserializer(cl).readObject(this); -+ -+ return value; -+ } -+ -+ /** -+ * Reads an arbitrary object from the input stream when the type -+ * is unknown. -+ */ -+ public Object readObject() -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ switch (tag) { -+ case TAG_NULL: -+ expectTag(TAG_NULL_END); -+ return null; -+ -+ case TAG_BOOLEAN: -+ { -+ int value = parseInt(); -+ expectTag(TAG_BOOLEAN_END); -+ return new Boolean(value != 0); -+ } -+ -+ case TAG_INT: -+ { -+ int value = parseInt(); -+ expectTag(TAG_INT_END); -+ return new Integer(value); -+ } -+ -+ case TAG_LONG: -+ { -+ long value = parseLong(); -+ expectTag(TAG_LONG_END); -+ return new Long(value); -+ } -+ -+ case TAG_DOUBLE: -+ { -+ double value = parseDouble(); -+ expectTag(TAG_DOUBLE_END); -+ return new Double(value); -+ } -+ -+ case TAG_DATE: -+ { -+ long value = parseDate(); -+ expectTag(TAG_DATE_END); -+ return new Date(value); -+ } -+ -+ case TAG_XML: -+ { -+ return parseXML(); -+ } -+ -+ case TAG_STRING: -+ { -+ _sbuf.setLength(0); -+ -+ String value = parseString(_sbuf).toString(); -+ -+ expectTag(TAG_STRING_END); -+ -+ return value; -+ } -+ -+ case TAG_BASE64: -+ { -+ byte []data = parseBytes(); -+ -+ expectTag(TAG_BASE64_END); -+ -+ return data; -+ } -+ -+ case TAG_LIST: -+ { -+ String type = readType(); -+ int length = readLength(); -+ -+ return _serializerFactory.readList(this, length, type); -+ } -+ -+ case TAG_MAP: -+ { -+ String type = readType(); -+ Deserializer deserializer; -+ deserializer = _serializerFactory.getObjectDeserializer(type); -+ -+ return deserializer.readMap(this); -+ } -+ -+ case TAG_REF: -+ { -+ int ref = parseInt(); -+ -+ expectTag(TAG_REF_END); -+ -+ return _refs.get(ref); -+ } -+ -+ case TAG_REMOTE: -+ { -+ String type = readType(); -+ String url = readString(); -+ -+ expectTag(TAG_REMOTE_END); -+ -+ return resolveRemote(type, url); -+ } -+ -+ default: -+ throw error("unknown code:" + tagName(tag)); -+ } -+ } -+ -+ /** -+ * Reads a remote object. -+ */ -+ public Object readRemote() -+ throws IOException -+ { -+ String type = readType(); -+ String url = readString(); -+ -+ return resolveRemote(type, url); -+ } -+ -+ /** -+ * Reads a reference. -+ */ -+ public Object readRef() -+ throws IOException -+ { -+ return _refs.get(parseInt()); -+ } -+ -+ /** -+ * Reads the start of a list. -+ */ -+ public int readListStart() -+ throws IOException -+ { -+ return parseTag(); -+ } -+ -+ /** -+ * Reads the start of a map. -+ */ -+ public int readMapStart() -+ throws IOException -+ { -+ return parseTag(); -+ } -+ -+ /** -+ * Returns true if this is the end of a list or a map. -+ */ -+ public boolean isEnd() -+ throws IOException -+ { -+ int code = parseTag(); -+ -+ _peekTag = code; -+ -+ return (code < 0 || code >= 100); -+ } -+ -+ /** -+ * Reads the end byte. -+ */ -+ public void readEnd() -+ throws IOException -+ { -+ int code = parseTag(); -+ -+ if (code < 100) -+ throw error("unknown code:" + (char) code); -+ } -+ -+ /** -+ * Reads the end of the map -+ */ -+ public void readMapEnd() -+ throws IOException -+ { -+ expectTag(TAG_MAP_END); -+ } -+ -+ /** -+ * Reads the end of the map -+ */ -+ public void readListEnd() -+ throws IOException -+ { -+ expectTag(TAG_LIST_END); -+ } -+ -+ /** -+ * Adds a list/map reference. -+ */ -+ public int addRef(Object ref) -+ { -+ if (_refs == null) -+ _refs = new ArrayList(); -+ -+ _refs.add(ref); -+ -+ return _refs.size() - 1; -+ } -+ -+ /** -+ * Adds a list/map reference. -+ */ -+ public void setRef(int i, Object ref) -+ { -+ _refs.set(i, ref); -+ } -+ -+ /** -+ * Resolves a remote object. -+ */ -+ public Object resolveRemote(String type, String url) -+ throws IOException -+ { -+ HessianRemoteResolver resolver = getRemoteResolver(); -+ -+ if (resolver != null) -+ return resolver.lookup(type, url); -+ else -+ return new BurlapRemote(type, url); -+ } -+ -+ /** -+ * Parses a type from the stream. -+ * -+ *
-+   * <type>type</type>
-+   * 
-+ */ -+ public String readType() -+ throws IOException -+ { -+ int code = parseTag(); -+ -+ if (code != TAG_TYPE) { -+ _peekTag = code; -+ return ""; -+ } -+ -+ _sbuf.setLength(0); -+ int ch; -+ while ((ch = readChar()) >= 0) -+ _sbuf.append((char) ch); -+ String type = _sbuf.toString(); -+ -+ expectTag(TAG_TYPE_END); -+ -+ return type; -+ } -+ -+ /** -+ * Parses a 32-bit integer value from the stream. -+ */ -+ private int parseInt() -+ throws IOException -+ { -+ int sign = 1; -+ -+ int ch = read(); -+ if (ch == '-') { -+ sign = -1; -+ ch = read(); -+ } -+ -+ int value = 0; -+ for (; ch >= '0' && ch <= '9'; ch = read()) -+ value = 10 * value + ch - '0'; -+ -+ _peek = ch; -+ -+ return sign * value; -+ } -+ -+ /** -+ * Parses a 64-bit long value from the stream. -+ */ -+ private long parseLong() -+ throws IOException -+ { -+ int sign = 1; -+ -+ int ch = read(); -+ if (ch == '-') { -+ sign = -1; -+ ch = read(); -+ } -+ -+ long value = 0; -+ for (; ch >= '0' && ch <= '9'; ch = read()) -+ value = 10 * value + ch - '0'; -+ -+ _peek = ch; -+ -+ return sign * value; -+ } -+ -+ /** -+ * Parses a 64-bit double value from the stream. -+ * -+ *
-+   * b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ private double parseDouble() -+ throws IOException -+ { -+ int ch = skipWhitespace(); -+ -+ _sbuf.setLength(0); -+ -+ for (; ! isWhitespace(ch) && ch != '<'; ch = read()) -+ _sbuf.append((char) ch); -+ -+ _peek = ch; -+ -+ return new Double(_sbuf.toString()).doubleValue(); -+ } -+ -+ /** -+ * Parses a date value from the stream. -+ */ -+ protected long parseDate() -+ throws IOException -+ { -+ if (_utcCalendar == null) -+ _utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -+ -+ return parseDate(_utcCalendar); -+ } -+ -+ /** -+ * Parses a date value from the stream. -+ */ -+ protected long parseDate(Calendar calendar) -+ throws IOException -+ { -+ int ch = skipWhitespace(); -+ -+ int year = 0; -+ for (int i = 0; i < 4; i++) { -+ if (ch >= '0' && ch <= '9') -+ year = 10 * year + ch - '0'; -+ else -+ throw expectedChar("year", ch); -+ -+ ch = read(); -+ } -+ -+ int month = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ month = 10 * month + ch - '0'; -+ else -+ throw expectedChar("month", ch); -+ -+ ch = read(); -+ } -+ -+ int day = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ day = 10 * day + ch - '0'; -+ else -+ throw expectedChar("day", ch); -+ -+ ch = read(); -+ } -+ -+ if (ch != 'T') -+ throw expectedChar("`T'", ch); -+ -+ ch = read(); -+ -+ int hour = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ hour = 10 * hour + ch - '0'; -+ else -+ throw expectedChar("hour", ch); -+ -+ ch = read(); -+ } -+ -+ int minute = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ minute = 10 * minute + ch - '0'; -+ else -+ throw expectedChar("minute", ch); -+ -+ ch = read(); -+ } -+ -+ int second = 0; -+ for (int i = 0; i < 2; i++) { -+ if (ch >= '0' && ch <= '9') -+ second = 10 * second + ch - '0'; -+ else -+ throw expectedChar("second", ch); -+ -+ ch = read(); -+ } -+ -+ int ms = 0; -+ if (ch == '.') { -+ ch = read(); -+ -+ while (ch >= '0' && ch <= '9') { -+ ms = 10 * ms + ch - '0'; -+ -+ ch = read(); -+ } -+ } -+ -+ for (; ch > 0 && ch != '<'; ch = read()) { -+ } -+ -+ _peek = ch; -+ -+ calendar.set(Calendar.YEAR, year); -+ calendar.set(Calendar.MONTH, month - 1); -+ calendar.set(Calendar.DAY_OF_MONTH, day); -+ calendar.set(Calendar.HOUR_OF_DAY, hour); -+ calendar.set(Calendar.MINUTE, minute); -+ calendar.set(Calendar.SECOND, second); -+ calendar.set(Calendar.MILLISECOND, ms); -+ -+ return calendar.getTime().getTime(); -+ } -+ -+ protected String parseString() -+ throws IOException -+ { -+ _sbuf.setLength(0); -+ -+ return parseString(_sbuf).toString(); -+ } -+ -+ /** -+ * Parses a string value from the stream. The burlap object's -+ * string buffer is used for the result. -+ */ -+ protected StringBuffer parseString(StringBuffer sbuf) -+ throws IOException -+ { -+ int ch; -+ -+ while ((ch = readChar()) >= 0) -+ sbuf.append((char) ch); -+ -+ return sbuf; -+ } -+ -+ org.w3c.dom.Node parseXML() -+ throws IOException -+ { -+ throw error("help!"); -+ } -+ -+ /** -+ * Reads a character from the underlying stream. -+ */ -+ int readChar() -+ throws IOException -+ { -+ int ch = read(); -+ -+ if (ch == '<' || ch < 0) { -+ _peek = ch; -+ return -1; -+ } -+ -+ if (ch == '&') { -+ ch = read(); -+ -+ if (ch == '#') { -+ ch = read(); -+ -+ if (ch >= '0' && ch <= '9') { -+ int v = 0; -+ for (; ch >= '0' && ch <= '9'; ch = read()) { -+ v = 10 * v + ch - '0'; -+ } -+ -+ if (ch != ';') -+ throw error("expected ';' at " + (char) ch); -+ -+ return (char) v; -+ } -+ else -+ throw error("expected digit at " + (char) ch); -+ } -+ else { -+ _entityBuffer.setLength(0); -+ -+ for (; ch >= 'a' && ch <= 'z'; ch = read()) -+ _entityBuffer.append((char) ch); -+ -+ String entity = _entityBuffer.toString(); -+ -+ if (ch != ';') -+ throw expectedChar("';'", ch); -+ -+ if (entity.equals("amp")) -+ return '&'; -+ else if (entity.equals("apos")) -+ return '\''; -+ else if (entity.equals("quot")) -+ return '"'; -+ else if (entity.equals("lt")) -+ return '<'; -+ else if (entity.equals("gt")) -+ return '>'; -+ else -+ throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'"); -+ } -+ } -+ else if (ch < 0x80) -+ return (char) ch; -+ else if ((ch & 0xe0) == 0xc0) { -+ int ch1 = read(); -+ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -+ -+ return (char) v; -+ } -+ else if ((ch & 0xf0) == 0xe0) { -+ int ch1 = read(); -+ int ch2 = read(); -+ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -+ -+ return (char) v; -+ } -+ else -+ throw new BurlapProtocolException("bad utf-8 encoding"); -+ } -+ -+ /** -+ * Parses a byte array. -+ */ -+ protected byte []parseBytes() -+ throws IOException -+ { -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ parseBytes(bos); -+ -+ return bos.toByteArray(); -+ } -+ -+ /** -+ * Parses a byte array. -+ */ -+ protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) -+ throws IOException -+ { -+ int ch; -+ for (ch = skipWhitespace(); ch >= 0 && ch != '<'; ch = skipWhitespace()) { -+ int b1 = ch; -+ int b2 = read(); -+ int b3 = read(); -+ int b4 = read(); -+ -+ if (b4 != '=') { -+ int chunk = ((base64Decode[b1] << 18) + -+ (base64Decode[b2] << 12) + -+ (base64Decode[b3] << 6) + -+ (base64Decode[b4])); -+ -+ bos.write(chunk >> 16); -+ bos.write(chunk >> 8); -+ bos.write(chunk); -+ } -+ else if (b3 != '=') { -+ int chunk = ((base64Decode[b1] << 10) + -+ (base64Decode[b2] << 4) + -+ (base64Decode[b3] >> 2)); -+ -+ bos.write(chunk >> 8); -+ bos.write(chunk); -+ } -+ else { -+ int chunk = ((base64Decode[b1] << 2) + -+ (base64Decode[b2] >> 4)); -+ -+ bos.write(chunk); -+ } -+ } -+ -+ if (ch == '<') -+ _peek = ch; -+ -+ return bos; -+ } -+ -+ public void expectTag(int expectTag) -+ throws IOException -+ { -+ int tag = parseTag(); -+ -+ if (tag != expectTag) -+ throw error("expected " + tagName(expectTag) + " at " + tagName(tag)); -+ } -+ -+ /** -+ * Parses a tag. Returns true if it's a start tag. -+ */ -+ protected int parseTag() -+ throws IOException -+ { -+ if (_peekTag >= 0) { -+ int tag = _peekTag; -+ _peekTag = -1; -+ return tag; -+ } -+ -+ int ch = skipWhitespace(); -+ int endTagDelta = 0; -+ -+ if (ch != '<') -+ throw expectedChar("'<'", ch); -+ -+ ch = read(); -+ if (ch == '/') { -+ endTagDelta = 100; -+ ch = _is.read(); -+ } -+ -+ if (! isTagChar(ch)) -+ throw expectedChar("tag", ch); -+ -+ _sbuf.setLength(0); -+ for (; isTagChar(ch); ch = read()) -+ _sbuf.append((char) ch); -+ -+ if (ch != '>') -+ throw expectedChar("'>'", ch); -+ -+ Integer value = (Integer) _tagMap.get(_sbuf.toString()); -+ if (value == null) -+ throw error("Unknown tag <" + _sbuf + ">"); -+ -+ return value.intValue() + endTagDelta; -+ } -+ -+ /** -+ * Returns true if the character is a valid tag character. -+ */ -+ private boolean isTagChar(int ch) -+ { -+ return (ch >= 'a' && ch <= 'z' || -+ ch >= 'A' && ch <= 'Z' || -+ ch >= '0' && ch <= '9' || -+ ch == ':' || ch == '-'); -+ } -+ -+ protected int skipWhitespace() -+ throws IOException -+ { -+ int ch = read(); -+ -+ for (; -+ ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -+ ch = read()) { -+ } -+ -+ return ch; -+ } -+ -+ protected boolean isWhitespace(int ch) -+ throws IOException -+ { -+ return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; -+ } -+ -+ /** -+ * Reads bytes from the underlying stream. -+ */ -+ int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(); -+ } -+ -+ int read() -+ throws IOException -+ { -+ if (_peek >= 0) { -+ int value = _peek; -+ _peek = -1; -+ return value; -+ } -+ -+ int ch = _is.read(); -+ return ch; -+ } -+ -+ public Reader getReader() -+ { -+ return null; -+ } -+ -+ public InputStream readInputStream() -+ { -+ return null; -+ } -+ -+ public InputStream getInputStream() -+ { -+ return null; -+ } -+ -+ protected IOException expectBeginTag(String expect, String tag) -+ { -+ return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">"); -+ } -+ -+ protected IOException expectedChar(String expect, int ch) -+ { -+ if (ch < 0) -+ return error("expected " + expect + " at end of file"); -+ else -+ return error("expected " + expect + " at " + (char) ch); -+ } -+ -+ protected IOException expectedTag(String expect, int tag) -+ { -+ return error("expected " + expect + " at " + tagName(tag)); -+ } -+ -+ protected IOException error(String message) -+ { -+ return new BurlapProtocolException(message); -+ } -+ -+ protected static String tagName(int tag) -+ { -+ switch (tag) { -+ case TAG_NULL: -+ return ""; -+ case TAG_NULL_END: -+ return ""; -+ -+ case TAG_BOOLEAN: -+ return ""; -+ case TAG_BOOLEAN_END: -+ return ""; -+ -+ case TAG_INT: -+ return ""; -+ case TAG_INT_END: -+ return ""; -+ -+ case TAG_LONG: -+ return ""; -+ case TAG_LONG_END: -+ return ""; -+ -+ case TAG_DOUBLE: -+ return ""; -+ case TAG_DOUBLE_END: -+ return ""; -+ -+ case TAG_STRING: -+ return ""; -+ case TAG_STRING_END: -+ return ""; -+ -+ case TAG_XML: -+ return ""; -+ case TAG_XML_END: -+ return ""; -+ -+ case TAG_BASE64: -+ return ""; -+ case TAG_BASE64_END: -+ return ""; -+ -+ case TAG_MAP: -+ return ""; -+ case TAG_MAP_END: -+ return ""; -+ -+ case TAG_LIST: -+ return ""; -+ case TAG_LIST_END: -+ return ""; -+ -+ case TAG_TYPE: -+ return ""; -+ case TAG_TYPE_END: -+ return ""; -+ -+ case TAG_LENGTH: -+ return ""; -+ case TAG_LENGTH_END: -+ return ""; -+ -+ case TAG_REF: -+ return ""; -+ case TAG_REF_END: -+ return ""; -+ -+ case TAG_REMOTE: -+ return ""; -+ case TAG_REMOTE_END: -+ return ""; -+ -+ case TAG_CALL: -+ return ""; -+ case TAG_CALL_END: -+ return ""; -+ -+ case TAG_REPLY: -+ return ""; -+ case TAG_REPLY_END: -+ return ""; -+ -+ case TAG_HEADER: -+ return "
"; -+ case TAG_HEADER_END: -+ return "
"; -+ -+ case TAG_FAULT: -+ return ""; -+ case TAG_FAULT_END: -+ return ""; -+ -+ case -1: -+ return "end of file"; -+ -+ default: -+ return "unknown " + tag; -+ } -+ } -+ -+ -+ static { -+ _tagMap = new HashMap(); -+ _tagMap.put("null", new Integer(TAG_NULL)); -+ -+ _tagMap.put("boolean", new Integer(TAG_BOOLEAN)); -+ _tagMap.put("int", new Integer(TAG_INT)); -+ _tagMap.put("long", new Integer(TAG_LONG)); -+ _tagMap.put("double", new Integer(TAG_DOUBLE)); -+ -+ _tagMap.put("date", new Integer(TAG_DATE)); -+ -+ _tagMap.put("string", new Integer(TAG_STRING)); -+ _tagMap.put("xml", new Integer(TAG_XML)); -+ _tagMap.put("base64", new Integer(TAG_BASE64)); -+ -+ _tagMap.put("map", new Integer(TAG_MAP)); -+ _tagMap.put("list", new Integer(TAG_LIST)); -+ -+ _tagMap.put("type", new Integer(TAG_TYPE)); -+ _tagMap.put("length", new Integer(TAG_LENGTH)); -+ -+ _tagMap.put("ref", new Integer(TAG_REF)); -+ _tagMap.put("remote", new Integer(TAG_REMOTE)); -+ -+ _tagMap.put("burlap:call", new Integer(TAG_CALL)); -+ _tagMap.put("burlap:reply", new Integer(TAG_REPLY)); -+ _tagMap.put("fault", new Integer(TAG_FAULT)); -+ _tagMap.put("method", new Integer(TAG_METHOD)); -+ _tagMap.put("header", new Integer(TAG_HEADER)); -+ } -+ -+ static { -+ base64Decode = new int[256]; -+ for (int i = 'A'; i <= 'Z'; i++) -+ base64Decode[i] = i - 'A'; -+ for (int i = 'a'; i <= 'z'; i++) -+ base64Decode[i] = i - 'a' + 26; -+ for (int i = '0'; i <= '9'; i++) -+ base64Decode[i] = i - '0' + 52; -+ base64Decode['+'] = 62; -+ base64Decode['/'] = 63; -+ } -+ -+ private static Field getDetailMessageField() -+ { -+ if (_detailMessageField == null) { -+ try { -+ _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); -+ _detailMessageField.setAccessible(true); -+ } catch (Throwable e) { -+ } -+ } -+ -+ return _detailMessageField; -+ -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapOutput.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapOutput.java ---- hessian-4.0.65-src/com/caucho/burlap/io/BurlapOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,978 +1,978 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import com.caucho.hessian.io.Serializer; --import com.caucho.hessian.io.SerializerFactory; -- --import java.io.IOException; --import java.io.OutputStream; --import java.util.Calendar; --import java.util.Date; --import java.util.IdentityHashMap; --import java.util.TimeZone; -- --/** -- * Output stream for Burlap requests, compatible with microedition -- * Java. It only uses classes and types available in JDK. -- * -- *

Since BurlapOutput does not depend on any classes other than -- * in the JDK, it can be extracted independently into a smaller package. -- * -- *

BurlapOutput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * OutputStream os = ...; // from http connection
-- * BurlapOutput out = new BurlapOutput(os);
-- * String value;
-- *
-- * out.startCall("hello");  // start hello call
-- * out.writeString("arg1"); // write a string argument
-- * out.completeCall();      // complete the call
-- * 
-- */ --public class BurlapOutput extends AbstractBurlapOutput { -- // the output stream -- protected OutputStream os; -- // map of references -- private IdentityHashMap _refs; -- -- private Date date; -- private Calendar utcCalendar; -- private Calendar localCalendar; -- /** -- * Creates a new Burlap output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public BurlapOutput(OutputStream os) -- { -- init(os); -- } -- -- /** -- * Creates an uninitialized Burlap output stream. -- */ -- public BurlapOutput() -- { -- } -- -- /** -- * Initializes the output -- */ -- public void init(OutputStream os) -- { -- this.os = os; -- -- _refs = null; -- -- if (_serializerFactory == null) -- _serializerFactory = new SerializerFactory(); -- } -- -- /** -- * Writes a complete method call. -- */ -- public void call(String method, Object []args) -- throws IOException -- { -- startCall(method); -- -- if (args != null) { -- for (int i = 0; i < args.length; i++) -- writeObject(args[i]); -- } -- -- completeCall(); -- } -- -- /** -- * Starts the method call. Clients would use startCall -- * instead of call if they wanted finer control over -- * writing the arguments, or needed to write headers. -- * -- *
--   * <burlap:call>
--   * <method>method-name</method>
--   * 
-- * -- * @param method the method name to call. -- */ -- public void startCall(String method) -- throws IOException -- { -- print(""); -- print(method); -- print(""); -- } -- -- /** -- * Starts the method call. Clients would use startCall -- * instead of call if they wanted finer control over -- * writing the arguments, or needed to write headers. -- * -- *
--   * <method>method-name</method>
--   * 
-- * -- * @param method the method name to call. -- */ -- public void startCall() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Writes the method for a call. -- * -- *
--   * <method>value</method>
--   * 
-- * -- * @param method the method name to call. -- */ -- public void writeMethod(String method) -- throws IOException -- { -- print(""); -- print(method); -- print(""); -- } -- -- -- /** -- * Completes. -- * -- *
--   * </burlap:call>
--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- print("
"); -- } -- -- /** -- * Starts the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * r
--   * 
-- */ -- public void startReply() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Completes reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * </burlap:reply>
--   * 
-- */ -- public void completeReply() -- throws IOException -- { -- print("
"); -- } -- -- /** -- * Writes a header name. The header value must immediately follow. -- * -- *
--   * <header>foo</header><int>value</int>
--   * 
-- */ -- public void writeHeader(String name) -- throws IOException -- { -- print("
"); -- printString(name); -- print("
"); -- } -- -- /** -- * Writes a fault. The fault will be written -- * as a descriptive string followed by an object: -- * -- *
--   * <fault>
--   * <string>code
--   * <string>the fault code
--   *
--   * <string>message
--   * <string>the fault mesage
--   *
--   * <string>detail
--   * <map>t\x00\xnnjavax.ejb.FinderException
--   *     ...
--   * </map>
--   * </fault>
--   * 
-- * -- * @param code the fault code, a three digit -- */ -- public void writeFault(String code, String message, Object detail) -- throws IOException -- { -- print(""); -- writeString("code"); -- writeString(code); -- -- writeString("message"); -- writeString(message); -- -- if (detail != null) { -- writeString("detail"); -- writeObject(detail); -- } -- print(""); -- } -- -- /** -- * Writes any object to the output stream. -- */ -- public void writeObject(Object object) -- throws IOException -- { -- if (object == null) { -- writeNull(); -- return; -- } -- -- Serializer serializer; -- -- serializer = _serializerFactory.getSerializer(object.getClass()); -- -- serializer.writeObject(object, this); -- } -- -- /** -- * Writes the list header to the stream. List writers will call -- * writeListBegin followed by the list contents and then -- * call writeListEnd. -- * -- *
--   * <list>
--   *   <type>java.util.ArrayList</type>
--   *   <length>3</length>
--   *   <int>1</int>
--   *   <int>2</int>
--   *   <int>3</int>
--   * </list>
--   * 
-- */ -- public boolean writeListBegin(int length, String type) -- throws IOException -- { -- print(""); -- -- if (type != null) -- print(type); -- -- print(""); -- print(length); -- print(""); -- -- return true; -- } -- -- /** -- * Writes the tail of the list to the stream. -- */ -- public void writeListEnd() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Writes the map header to the stream. Map writers will call -- * writeMapBegin followed by the map contents and then -- * call writeMapEnd. -- * -- *
--   * <map>
--   *   <type>type</type>
--   *   (<key> <value>)*
--   * </map>
--   * 
-- */ -- public void writeMapBegin(String type) -- throws IOException -- { -- print(""); -- if (type != null) -- print(type); -- -- print(""); -- } -- -- /** -- * Writes the tail of the map to the stream. -- */ -- public void writeMapEnd() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Writes a remote object reference to the stream. The type is the -- * type of the remote interface. -- * -- *
--   * <remote>
--   *   <type>test.account.Account</type>
--   *   <string>http://caucho.com/foo;ejbid=bar</string>
--   * </remote>
--   * 
-- */ -- public void writeRemote(String type, String url) -- throws IOException -- { -- print(""); -- print(type); -- print(""); -- print(url); -- print(""); -- } -- -- /** -- * Writes a boolean value to the stream. The boolean will be written -- * with the following syntax: -- * -- *
--   * <boolean>0</boolean>
--   * <boolean>1</boolean>
--   * 
-- * -- * @param value the boolean value to write. -- */ -- public void writeBoolean(boolean value) -- throws IOException -- { -- if (value) -- print("1"); -- else -- print("0"); -- } -- -- /** -- * Writes an integer value to the stream. The integer will be written -- * with the following syntax: -- * -- *
--   * <int>int value</int>
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeInt(int value) -- throws IOException -- { -- print(""); -- print(value); -- print(""); -- } -- -- /** -- * Writes a long value to the stream. The long will be written -- * with the following syntax: -- * -- *
--   * <long>int value</long>
--   * 
-- * -- * @param value the long value to write. -- */ -- public void writeLong(long value) -- throws IOException -- { -- print(""); -- print(value); -- print(""); -- } -- -- /** -- * Writes a double value to the stream. The double will be written -- * with the following syntax: -- * -- *
--   * <double>value</double>
--   * 
-- * -- * @param value the double value to write. -- */ -- public void writeDouble(double value) -- throws IOException -- { -- print(""); -- print(value); -- print(""); -- } -- -- /** -- * Writes a date to the stream. -- * -- *
--   * <date>iso8901</date>
--   * 
-- * -- * @param time the date in milliseconds from the epoch in UTC -- */ -- public void writeUTCDate(long time) -- throws IOException -- { -- print(""); -- if (utcCalendar == null) { -- utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -- date = new Date(); -- } -- -- date.setTime(time); -- utcCalendar.setTime(date); -- -- printDate(utcCalendar); -- print(""); -- } -- -- /** -- * Writes a null value to the stream. -- * The null will be written with the following syntax -- * -- *
--   * <null></null>
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeNull() -- throws IOException -- { -- print(""); -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * <string>string-value</string>
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * <null></null>
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(String value) -- throws IOException -- { -- if (value == null) { -- print(""); -- } -- else { -- print(""); -- printString(value); -- print(""); -- } -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(char []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- print(""); -- } -- else { -- print(""); -- printString(buffer, offset, length); -- print(""); -- } -- } -- -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * <base64>bytes</base64>
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * <null></null>
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer) -- throws IOException -- { -- if (buffer == null) -- print(""); -- else -- writeBytes(buffer, 0, buffer.length); -- } -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * <base64>bytes</base64>
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * <null></null>
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- print(""); -- } -- else { -- print(""); -- -- int i = 0; -- for (; i + 2 < length; i += 3) { -- if (i != 0 && (i & 0x3f) == 0) -- print('\n'); -- -- int v = (((buffer[offset + i] & 0xff) << 16) + -- ((buffer[offset + i + 1] & 0xff) << 8) + -- (buffer[offset + i + 2] & 0xff)); -- -- print(encode(v >> 18)); -- print(encode(v >> 12)); -- print(encode(v >> 6)); -- print(encode(v)); -- } -- -- if (i + 1 < length) { -- int v = (((buffer[offset + i] & 0xff) << 8) + -- (buffer[offset + i + 1] & 0xff)); -- -- print(encode(v >> 10)); -- print(encode(v >> 4)); -- print(encode(v << 2)); -- print('='); -- } -- else if (i < length) { -- int v = buffer[offset + i] & 0xff; -- -- print(encode(v >> 2)); -- print(encode(v << 4)); -- print('='); -- print('='); -- } -- -- print(""); -- } -- } -- -- /** -- * Writes a byte buffer to the stream. -- */ -- public void writeByteBufferStart() -- throws IOException -- { -- throw new UnsupportedOperationException(); -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- */ -- public void writeByteBufferPart(byte []buffer, int offset, int length) -- throws IOException -- { -- throw new UnsupportedOperationException(); -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- */ -- public void writeByteBufferEnd(byte []buffer, int offset, int length) -- throws IOException -- { -- throw new UnsupportedOperationException(); -- } -- -- /** -- * Encodes a digit -- */ -- private char encode(int d) -- { -- d &= 0x3f; -- if (d < 26) -- return (char) (d + 'A'); -- else if (d < 52) -- return (char) (d + 'a' - 26); -- else if (d < 62) -- return (char) (d + '0' - 52); -- else if (d == 62) -- return '+'; -- else -- return '/'; -- } -- -- /** -- * Writes a reference. -- * -- *
--   * <ref>int</ref>
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeRef(int value) -- throws IOException -- { -- print(""); -- print(value); -- print(""); -- } -- -- /** -- * If the object has already been written, just write its ref. -- * -- * @return true if we're writing a ref. -- */ -- public boolean addRef(Object object) -- throws IOException -- { -- if (_refs == null) -- _refs = new IdentityHashMap(); -- -- Integer ref = (Integer) _refs.get(object); -- -- if (ref != null) { -- int value = ref.intValue(); -- -- writeRef(value); -- return true; -- } -- else { -- _refs.put(object, new Integer(_refs.size())); -- -- return false; -- } -- } -- -- @Override -- public int getRef(Object obj) -- { -- if (_refs == null) -- return -1; -- -- Integer ref = (Integer) _refs.get(obj); -- -- if (ref != null) -- return ref; -- else -- return -1; -- } -- -- /** -- * Removes a reference. -- */ -- public boolean removeRef(Object obj) -- throws IOException -- { -- if (_refs != null) { -- _refs.remove(obj); -- -- return true; -- } -- else -- return false; -- } -- -- /** -- * Replaces a reference from one object to another. -- */ -- public boolean replaceRef(Object oldRef, Object newRef) -- throws IOException -- { -- Integer value = (Integer) _refs.remove(oldRef); -- -- if (value != null) { -- _refs.put(newRef, value); -- return true; -- } -- else -- return false; -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v) -- throws IOException -- { -- printString(v, 0, v.length()); -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v, int offset, int length) -- throws IOException -- { -- for (int i = 0; i < length; i++) { -- char ch = v.charAt(i + offset); -- -- if (ch == '<') { -- os.write('&'); -- os.write('#'); -- os.write('6'); -- os.write('0'); -- os.write(';'); -- } -- else if (ch == '&') { -- os.write('&'); -- os.write('#'); -- os.write('3'); -- os.write('8'); -- os.write(';'); -- } -- else if (ch < 0x80) -- os.write(ch); -- else if (ch < 0x800) { -- os.write(0xc0 + ((ch >> 6) & 0x1f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- else { -- os.write(0xe0 + ((ch >> 12) & 0xf)); -- os.write(0x80 + ((ch >> 6) & 0x3f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- } -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(char []v, int offset, int length) -- throws IOException -- { -- for (int i = 0; i < length; i++) { -- char ch = v[i + offset]; -- -- if (ch < 0x80) -- os.write(ch); -- else if (ch < 0x800) { -- os.write(0xc0 + ((ch >> 6) & 0x1f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- else { -- os.write(0xe0 + ((ch >> 12) & 0xf)); -- os.write(0x80 + ((ch >> 6) & 0x3f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- } -- } -- -- /** -- * Prints a date. -- * -- * @param date the date to print. -- */ -- public void printDate(Calendar calendar) -- throws IOException -- { -- int year = calendar.get(Calendar.YEAR); -- -- os.write((char) ('0' + (year / 1000 % 10))); -- os.write((char) ('0' + (year / 100 % 10))); -- os.write((char) ('0' + (year / 10 % 10))); -- os.write((char) ('0' + (year % 10))); -- -- int month = calendar.get(Calendar.MONTH) + 1; -- os.write((char) ('0' + (month / 10 % 10))); -- os.write((char) ('0' + (month % 10))); -- -- int day = calendar.get(Calendar.DAY_OF_MONTH); -- os.write((char) ('0' + (day / 10 % 10))); -- os.write((char) ('0' + (day % 10))); -- -- os.write('T'); -- -- int hour = calendar.get(Calendar.HOUR_OF_DAY); -- os.write((char) ('0' + (hour / 10 % 10))); -- os.write((char) ('0' + (hour % 10))); -- -- int minute = calendar.get(Calendar.MINUTE); -- os.write((char) ('0' + (minute / 10 % 10))); -- os.write((char) ('0' + (minute % 10))); -- -- int second = calendar.get(Calendar.SECOND); -- os.write((char) ('0' + (second / 10 % 10))); -- os.write((char) ('0' + (second % 10))); -- -- int ms = calendar.get(Calendar.MILLISECOND); -- os.write('.'); -- os.write((char) ('0' + (ms / 100 % 10))); -- os.write((char) ('0' + (ms / 10 % 10))); -- os.write((char) ('0' + (ms % 10))); -- -- os.write('Z'); -- } -- -- /** -- * Prints a char to the stream. -- * -- * @param v the char to print. -- */ -- protected void print(char v) -- throws IOException -- { -- os.write(v); -- } -- -- /** -- * Prints an integer to the stream. -- * -- * @param v the integer to print. -- */ -- protected void print(int v) -- throws IOException -- { -- print(String.valueOf(v)); -- } -- -- /** -- * Prints a long to the stream. -- * -- * @param v the long to print. -- */ -- protected void print(long v) -- throws IOException -- { -- print(String.valueOf(v)); -- } -- -- /** -- * Prints a double to the stream. -- * -- * @param v the double to print. -- */ -- protected void print(double v) -- throws IOException -- { -- print(String.valueOf(v)); -- } -- -- /** -- * Prints a string as ascii to the stream. Used for tags, etc. -- * that are known to the ascii. -- * -- * @param s the ascii string to print. -- */ -- protected void print(String s) -- throws IOException -- { -- int len = s.length(); -- for (int i = 0; i < len; i++) { -- int ch = s.charAt(i); -- -- os.write(ch); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import com.caucho.hessian.io.Serializer; -+import com.caucho.hessian.io.SerializerFactory; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+import java.util.Calendar; -+import java.util.Date; -+import java.util.IdentityHashMap; -+import java.util.TimeZone; -+ -+/** -+ * Output stream for Burlap requests, compatible with microedition -+ * Java. It only uses classes and types available in JDK. -+ * -+ *

Since BurlapOutput does not depend on any classes other than -+ * in the JDK, it can be extracted independently into a smaller package. -+ * -+ *

BurlapOutput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * OutputStream os = ...; // from http connection
-+ * BurlapOutput out = new BurlapOutput(os);
-+ * String value;
-+ *
-+ * out.startCall("hello");  // start hello call
-+ * out.writeString("arg1"); // write a string argument
-+ * out.completeCall();      // complete the call
-+ * 
-+ */ -+public class BurlapOutput extends AbstractBurlapOutput { -+ // the output stream -+ protected OutputStream os; -+ // map of references -+ private IdentityHashMap _refs; -+ -+ private Date date; -+ private Calendar utcCalendar; -+ private Calendar localCalendar; -+ /** -+ * Creates a new Burlap output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public BurlapOutput(OutputStream os) -+ { -+ init(os); -+ } -+ -+ /** -+ * Creates an uninitialized Burlap output stream. -+ */ -+ public BurlapOutput() -+ { -+ } -+ -+ /** -+ * Initializes the output -+ */ -+ public void init(OutputStream os) -+ { -+ this.os = os; -+ -+ _refs = null; -+ -+ if (_serializerFactory == null) -+ _serializerFactory = new SerializerFactory(); -+ } -+ -+ /** -+ * Writes a complete method call. -+ */ -+ public void call(String method, Object []args) -+ throws IOException -+ { -+ startCall(method); -+ -+ if (args != null) { -+ for (int i = 0; i < args.length; i++) -+ writeObject(args[i]); -+ } -+ -+ completeCall(); -+ } -+ -+ /** -+ * Starts the method call. Clients would use startCall -+ * instead of call if they wanted finer control over -+ * writing the arguments, or needed to write headers. -+ * -+ *
-+   * <burlap:call>
-+   * <method>method-name</method>
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void startCall(String method) -+ throws IOException -+ { -+ print(""); -+ print(method); -+ print(""); -+ } -+ -+ /** -+ * Starts the method call. Clients would use startCall -+ * instead of call if they wanted finer control over -+ * writing the arguments, or needed to write headers. -+ * -+ *
-+   * <method>method-name</method>
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void startCall() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Writes the method for a call. -+ * -+ *
-+   * <method>value</method>
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void writeMethod(String method) -+ throws IOException -+ { -+ print(""); -+ print(method); -+ print(""); -+ } -+ -+ -+ /** -+ * Completes. -+ * -+ *
-+   * </burlap:call>
-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ print("
"); -+ } -+ -+ /** -+ * Starts the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * r
-+   * 
-+ */ -+ public void startReply() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Completes reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * </burlap:reply>
-+   * 
-+ */ -+ public void completeReply() -+ throws IOException -+ { -+ print("
"); -+ } -+ -+ /** -+ * Writes a header name. The header value must immediately follow. -+ * -+ *
-+   * <header>foo</header><int>value</int>
-+   * 
-+ */ -+ public void writeHeader(String name) -+ throws IOException -+ { -+ print("
"); -+ printString(name); -+ print("
"); -+ } -+ -+ /** -+ * Writes a fault. The fault will be written -+ * as a descriptive string followed by an object: -+ * -+ *
-+   * <fault>
-+   * <string>code
-+   * <string>the fault code
-+   *
-+   * <string>message
-+   * <string>the fault mesage
-+   *
-+   * <string>detail
-+   * <map>t\x00\xnnjavax.ejb.FinderException
-+   *     ...
-+   * </map>
-+   * </fault>
-+   * 
-+ * -+ * @param code the fault code, a three digit -+ */ -+ public void writeFault(String code, String message, Object detail) -+ throws IOException -+ { -+ print(""); -+ writeString("code"); -+ writeString(code); -+ -+ writeString("message"); -+ writeString(message); -+ -+ if (detail != null) { -+ writeString("detail"); -+ writeObject(detail); -+ } -+ print(""); -+ } -+ -+ /** -+ * Writes any object to the output stream. -+ */ -+ public void writeObject(Object object) -+ throws IOException -+ { -+ if (object == null) { -+ writeNull(); -+ return; -+ } -+ -+ Serializer serializer; -+ -+ serializer = _serializerFactory.getSerializer(object.getClass()); -+ -+ serializer.writeObject(object, this); -+ } -+ -+ /** -+ * Writes the list header to the stream. List writers will call -+ * writeListBegin followed by the list contents and then -+ * call writeListEnd. -+ * -+ *
-+   * <list>
-+   *   <type>java.util.ArrayList</type>
-+   *   <length>3</length>
-+   *   <int>1</int>
-+   *   <int>2</int>
-+   *   <int>3</int>
-+   * </list>
-+   * 
-+ */ -+ public boolean writeListBegin(int length, String type) -+ throws IOException -+ { -+ print(""); -+ -+ if (type != null) -+ print(type); -+ -+ print(""); -+ print(length); -+ print(""); -+ -+ return true; -+ } -+ -+ /** -+ * Writes the tail of the list to the stream. -+ */ -+ public void writeListEnd() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Writes the map header to the stream. Map writers will call -+ * writeMapBegin followed by the map contents and then -+ * call writeMapEnd. -+ * -+ *
-+   * <map>
-+   *   <type>type</type>
-+   *   (<key> <value>)*
-+   * </map>
-+   * 
-+ */ -+ public void writeMapBegin(String type) -+ throws IOException -+ { -+ print(""); -+ if (type != null) -+ print(type); -+ -+ print(""); -+ } -+ -+ /** -+ * Writes the tail of the map to the stream. -+ */ -+ public void writeMapEnd() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Writes a remote object reference to the stream. The type is the -+ * type of the remote interface. -+ * -+ *
-+   * <remote>
-+   *   <type>test.account.Account</type>
-+   *   <string>http://caucho.com/foo;ejbid=bar</string>
-+   * </remote>
-+   * 
-+ */ -+ public void writeRemote(String type, String url) -+ throws IOException -+ { -+ print(""); -+ print(type); -+ print(""); -+ print(url); -+ print(""); -+ } -+ -+ /** -+ * Writes a boolean value to the stream. The boolean will be written -+ * with the following syntax: -+ * -+ *
-+   * <boolean>0</boolean>
-+   * <boolean>1</boolean>
-+   * 
-+ * -+ * @param value the boolean value to write. -+ */ -+ public void writeBoolean(boolean value) -+ throws IOException -+ { -+ if (value) -+ print("1"); -+ else -+ print("0"); -+ } -+ -+ /** -+ * Writes an integer value to the stream. The integer will be written -+ * with the following syntax: -+ * -+ *
-+   * <int>int value</int>
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeInt(int value) -+ throws IOException -+ { -+ print(""); -+ print(value); -+ print(""); -+ } -+ -+ /** -+ * Writes a long value to the stream. The long will be written -+ * with the following syntax: -+ * -+ *
-+   * <long>int value</long>
-+   * 
-+ * -+ * @param value the long value to write. -+ */ -+ public void writeLong(long value) -+ throws IOException -+ { -+ print(""); -+ print(value); -+ print(""); -+ } -+ -+ /** -+ * Writes a double value to the stream. The double will be written -+ * with the following syntax: -+ * -+ *
-+   * <double>value</double>
-+   * 
-+ * -+ * @param value the double value to write. -+ */ -+ public void writeDouble(double value) -+ throws IOException -+ { -+ print(""); -+ print(value); -+ print(""); -+ } -+ -+ /** -+ * Writes a date to the stream. -+ * -+ *
-+   * <date>iso8901</date>
-+   * 
-+ * -+ * @param time the date in milliseconds from the epoch in UTC -+ */ -+ public void writeUTCDate(long time) -+ throws IOException -+ { -+ print(""); -+ if (utcCalendar == null) { -+ utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); -+ date = new Date(); -+ } -+ -+ date.setTime(time); -+ utcCalendar.setTime(date); -+ -+ printDate(utcCalendar); -+ print(""); -+ } -+ -+ /** -+ * Writes a null value to the stream. -+ * The null will be written with the following syntax -+ * -+ *
-+   * <null></null>
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeNull() -+ throws IOException -+ { -+ print(""); -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * <string>string-value</string>
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * <null></null>
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(String value) -+ throws IOException -+ { -+ if (value == null) { -+ print(""); -+ } -+ else { -+ print(""); -+ printString(value); -+ print(""); -+ } -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(char []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ print(""); -+ } -+ else { -+ print(""); -+ printString(buffer, offset, length); -+ print(""); -+ } -+ } -+ -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * <base64>bytes</base64>
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * <null></null>
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer) -+ throws IOException -+ { -+ if (buffer == null) -+ print(""); -+ else -+ writeBytes(buffer, 0, buffer.length); -+ } -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * <base64>bytes</base64>
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * <null></null>
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ print(""); -+ } -+ else { -+ print(""); -+ -+ int i = 0; -+ for (; i + 2 < length; i += 3) { -+ if (i != 0 && (i & 0x3f) == 0) -+ print('\n'); -+ -+ int v = (((buffer[offset + i] & 0xff) << 16) + -+ ((buffer[offset + i + 1] & 0xff) << 8) + -+ (buffer[offset + i + 2] & 0xff)); -+ -+ print(encode(v >> 18)); -+ print(encode(v >> 12)); -+ print(encode(v >> 6)); -+ print(encode(v)); -+ } -+ -+ if (i + 1 < length) { -+ int v = (((buffer[offset + i] & 0xff) << 8) + -+ (buffer[offset + i + 1] & 0xff)); -+ -+ print(encode(v >> 10)); -+ print(encode(v >> 4)); -+ print(encode(v << 2)); -+ print('='); -+ } -+ else if (i < length) { -+ int v = buffer[offset + i] & 0xff; -+ -+ print(encode(v >> 2)); -+ print(encode(v << 4)); -+ print('='); -+ print('='); -+ } -+ -+ print(""); -+ } -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ */ -+ public void writeByteBufferStart() -+ throws IOException -+ { -+ throw new UnsupportedOperationException(); -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ */ -+ public void writeByteBufferPart(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(); -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ */ -+ public void writeByteBufferEnd(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(); -+ } -+ -+ /** -+ * Encodes a digit -+ */ -+ private char encode(int d) -+ { -+ d &= 0x3f; -+ if (d < 26) -+ return (char) (d + 'A'); -+ else if (d < 52) -+ return (char) (d + 'a' - 26); -+ else if (d < 62) -+ return (char) (d + '0' - 52); -+ else if (d == 62) -+ return '+'; -+ else -+ return '/'; -+ } -+ -+ /** -+ * Writes a reference. -+ * -+ *
-+   * <ref>int</ref>
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeRef(int value) -+ throws IOException -+ { -+ print(""); -+ print(value); -+ print(""); -+ } -+ -+ /** -+ * If the object has already been written, just write its ref. -+ * -+ * @return true if we're writing a ref. -+ */ -+ public boolean addRef(Object object) -+ throws IOException -+ { -+ if (_refs == null) -+ _refs = new IdentityHashMap(); -+ -+ Integer ref = (Integer) _refs.get(object); -+ -+ if (ref != null) { -+ int value = ref.intValue(); -+ -+ writeRef(value); -+ return true; -+ } -+ else { -+ _refs.put(object, new Integer(_refs.size())); -+ -+ return false; -+ } -+ } -+ -+ @Override -+ public int getRef(Object obj) -+ { -+ if (_refs == null) -+ return -1; -+ -+ Integer ref = (Integer) _refs.get(obj); -+ -+ if (ref != null) -+ return ref; -+ else -+ return -1; -+ } -+ -+ /** -+ * Removes a reference. -+ */ -+ public boolean removeRef(Object obj) -+ throws IOException -+ { -+ if (_refs != null) { -+ _refs.remove(obj); -+ -+ return true; -+ } -+ else -+ return false; -+ } -+ -+ /** -+ * Replaces a reference from one object to another. -+ */ -+ public boolean replaceRef(Object oldRef, Object newRef) -+ throws IOException -+ { -+ Integer value = (Integer) _refs.remove(oldRef); -+ -+ if (value != null) { -+ _refs.put(newRef, value); -+ return true; -+ } -+ else -+ return false; -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v) -+ throws IOException -+ { -+ printString(v, 0, v.length()); -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v, int offset, int length) -+ throws IOException -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = v.charAt(i + offset); -+ -+ if (ch == '<') { -+ os.write('&'); -+ os.write('#'); -+ os.write('6'); -+ os.write('0'); -+ os.write(';'); -+ } -+ else if (ch == '&') { -+ os.write('&'); -+ os.write('#'); -+ os.write('3'); -+ os.write('8'); -+ os.write(';'); -+ } -+ else if (ch < 0x80) -+ os.write(ch); -+ else if (ch < 0x800) { -+ os.write(0xc0 + ((ch >> 6) & 0x1f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ else { -+ os.write(0xe0 + ((ch >> 12) & 0xf)); -+ os.write(0x80 + ((ch >> 6) & 0x3f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ } -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(char []v, int offset, int length) -+ throws IOException -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = v[i + offset]; -+ -+ if (ch < 0x80) -+ os.write(ch); -+ else if (ch < 0x800) { -+ os.write(0xc0 + ((ch >> 6) & 0x1f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ else { -+ os.write(0xe0 + ((ch >> 12) & 0xf)); -+ os.write(0x80 + ((ch >> 6) & 0x3f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ } -+ } -+ -+ /** -+ * Prints a date. -+ * -+ * @param date the date to print. -+ */ -+ public void printDate(Calendar calendar) -+ throws IOException -+ { -+ int year = calendar.get(Calendar.YEAR); -+ -+ os.write((char) ('0' + (year / 1000 % 10))); -+ os.write((char) ('0' + (year / 100 % 10))); -+ os.write((char) ('0' + (year / 10 % 10))); -+ os.write((char) ('0' + (year % 10))); -+ -+ int month = calendar.get(Calendar.MONTH) + 1; -+ os.write((char) ('0' + (month / 10 % 10))); -+ os.write((char) ('0' + (month % 10))); -+ -+ int day = calendar.get(Calendar.DAY_OF_MONTH); -+ os.write((char) ('0' + (day / 10 % 10))); -+ os.write((char) ('0' + (day % 10))); -+ -+ os.write('T'); -+ -+ int hour = calendar.get(Calendar.HOUR_OF_DAY); -+ os.write((char) ('0' + (hour / 10 % 10))); -+ os.write((char) ('0' + (hour % 10))); -+ -+ int minute = calendar.get(Calendar.MINUTE); -+ os.write((char) ('0' + (minute / 10 % 10))); -+ os.write((char) ('0' + (minute % 10))); -+ -+ int second = calendar.get(Calendar.SECOND); -+ os.write((char) ('0' + (second / 10 % 10))); -+ os.write((char) ('0' + (second % 10))); -+ -+ int ms = calendar.get(Calendar.MILLISECOND); -+ os.write('.'); -+ os.write((char) ('0' + (ms / 100 % 10))); -+ os.write((char) ('0' + (ms / 10 % 10))); -+ os.write((char) ('0' + (ms % 10))); -+ -+ os.write('Z'); -+ } -+ -+ /** -+ * Prints a char to the stream. -+ * -+ * @param v the char to print. -+ */ -+ protected void print(char v) -+ throws IOException -+ { -+ os.write(v); -+ } -+ -+ /** -+ * Prints an integer to the stream. -+ * -+ * @param v the integer to print. -+ */ -+ protected void print(int v) -+ throws IOException -+ { -+ print(String.valueOf(v)); -+ } -+ -+ /** -+ * Prints a long to the stream. -+ * -+ * @param v the long to print. -+ */ -+ protected void print(long v) -+ throws IOException -+ { -+ print(String.valueOf(v)); -+ } -+ -+ /** -+ * Prints a double to the stream. -+ * -+ * @param v the double to print. -+ */ -+ protected void print(double v) -+ throws IOException -+ { -+ print(String.valueOf(v)); -+ } -+ -+ /** -+ * Prints a string as ascii to the stream. Used for tags, etc. -+ * that are known to the ascii. -+ * -+ * @param s the ascii string to print. -+ */ -+ protected void print(String s) -+ throws IOException -+ { -+ int len = s.length(); -+ for (int i = 0; i < len; i++) { -+ int ch = s.charAt(i); -+ -+ os.write(ch); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapProtocolException.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapProtocolException.java ---- hessian-4.0.65-src/com/caucho/burlap/io/BurlapProtocolException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapProtocolException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,88 +1,88 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import com.caucho.hessian.io.HessianProtocolException; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroBurlapInput. -- */ --public class BurlapProtocolException extends HessianProtocolException { -- /** -- * Zero-arg constructor. -- */ -- public BurlapProtocolException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public BurlapProtocolException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public BurlapProtocolException(String message, Throwable rootCause) -- { -- super(message, rootCause); -- } -- -- /** -- * Create the exception. -- */ -- public BurlapProtocolException(Throwable rootCause) -- { -- super(rootCause); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import com.caucho.hessian.io.HessianProtocolException; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroBurlapInput. -+ */ -+public class BurlapProtocolException extends HessianProtocolException { -+ /** -+ * Zero-arg constructor. -+ */ -+ public BurlapProtocolException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapProtocolException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapProtocolException(String message, Throwable rootCause) -+ { -+ super(message, rootCause); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapProtocolException(Throwable rootCause) -+ { -+ super(rootCause); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemote.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemote.java ---- hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemote.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemote.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,130 +1,130 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --/** -- * Encapsulates a remote address when no stub is available, e.g. for -- * Java MicroEdition. -- */ --public class BurlapRemote { -- private String type; -- private String url; -- -- /** -- * Creates a new Burlap remote object. -- * -- * @param type the remote stub interface -- * @param url the remote url -- */ -- public BurlapRemote(String type, String url) -- { -- this.type = type; -- this.url = url; -- } -- -- /** -- * Creates an uninitialized Burlap remote. -- */ -- public BurlapRemote() -- { -- } -- -- /** -- * Returns the remote api class name. -- */ -- public String getType() -- { -- return this.type; -- } -- -- /** -- * Returns the remote URL. -- */ -- public String getURL() -- { -- return this.url; -- } -- -- /** -- * Sets the remote URL. -- */ -- public void setURL(String url) -- { -- this.url = url; -- } -- -- /** -- * Defines the hashcode. -- */ -- public int hashCode() -- { -- return this.url.hashCode(); -- } -- -- /** -- * Defines equality -- */ -- public boolean equals(Object obj) -- { -- if (! (obj instanceof BurlapRemote)) -- return false; -- -- BurlapRemote remote = (BurlapRemote) obj; -- -- return this.url.equals(remote.url); -- } -- -- /** -- * Readable version of the remote. -- */ -- public String toString() -- { -- return "[BurlapRemote " + this.url + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+/** -+ * Encapsulates a remote address when no stub is available, e.g. for -+ * Java MicroEdition. -+ */ -+public class BurlapRemote { -+ private String type; -+ private String url; -+ -+ /** -+ * Creates a new Burlap remote object. -+ * -+ * @param type the remote stub interface -+ * @param url the remote url -+ */ -+ public BurlapRemote(String type, String url) -+ { -+ this.type = type; -+ this.url = url; -+ } -+ -+ /** -+ * Creates an uninitialized Burlap remote. -+ */ -+ public BurlapRemote() -+ { -+ } -+ -+ /** -+ * Returns the remote api class name. -+ */ -+ public String getType() -+ { -+ return this.type; -+ } -+ -+ /** -+ * Returns the remote URL. -+ */ -+ public String getURL() -+ { -+ return this.url; -+ } -+ -+ /** -+ * Sets the remote URL. -+ */ -+ public void setURL(String url) -+ { -+ this.url = url; -+ } -+ -+ /** -+ * Defines the hashcode. -+ */ -+ public int hashCode() -+ { -+ return this.url.hashCode(); -+ } -+ -+ /** -+ * Defines equality -+ */ -+ public boolean equals(Object obj) -+ { -+ if (! (obj instanceof BurlapRemote)) -+ return false; -+ -+ BurlapRemote remote = (BurlapRemote) obj; -+ -+ return this.url.equals(remote.url); -+ } -+ -+ /** -+ * Readable version of the remote. -+ */ -+ public String toString() -+ { -+ return "[BurlapRemote " + this.url + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteObject.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteObject.java ---- hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteObject.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteObject.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,57 +1,57 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --/** -- * Interface for any burlap remote object. -- */ --public interface BurlapRemoteObject { -- public String getBurlapType(); -- public String getBurlapURL(); --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+/** -+ * Interface for any burlap remote object. -+ */ -+public interface BurlapRemoteObject { -+ public String getBurlapType(); -+ public String getBurlapURL(); -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteResolver.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteResolver.java ---- hessian-4.0.65-src/com/caucho/burlap/io/BurlapRemoteResolver.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapRemoteResolver.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,63 +1,63 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import com.caucho.hessian.io.HessianRemoteResolver; -- --import java.io.IOException; --/** -- * Looks up remote objects. The default just returns a BurlapRemote object. -- */ --public interface BurlapRemoteResolver extends HessianRemoteResolver { -- /** -- * Looks up a proxy object. -- */ -- public Object lookup(String type, String url) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import com.caucho.hessian.io.HessianRemoteResolver; -+ -+import java.io.IOException; -+/** -+ * Looks up remote objects. The default just returns a BurlapRemote object. -+ */ -+public interface BurlapRemoteResolver extends HessianRemoteResolver { -+ /** -+ * Looks up a proxy object. -+ */ -+ public Object lookup(String type, String url) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/io/BurlapServiceException.java hessian-4.0.65-fix/com/caucho/burlap/io/BurlapServiceException.java ---- hessian-4.0.65-src/com/caucho/burlap/io/BurlapServiceException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/io/BurlapServiceException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,72 +1,72 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.io; -- --import com.caucho.hessian.io.HessianServiceException; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroBurlapInput. -- */ --public class BurlapServiceException extends HessianServiceException { -- /** -- * Zero-arg constructor. -- */ -- public BurlapServiceException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public BurlapServiceException(String message, String code, Object detail) -- { -- super(message, code, detail); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.io; -+ -+import com.caucho.hessian.io.HessianServiceException; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroBurlapInput. -+ */ -+public class BurlapServiceException extends HessianServiceException { -+ /** -+ * Zero-arg constructor. -+ */ -+ public BurlapServiceException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public BurlapServiceException(String message, String code, Object detail) -+ { -+ super(message, code, detail); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/server/BurlapServlet.java hessian-4.0.65-fix/com/caucho/burlap/server/BurlapServlet.java ---- hessian-4.0.65-src/com/caucho/burlap/server/BurlapServlet.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/server/BurlapServlet.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,205 +1,205 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.server; -- --import com.caucho.burlap.io.BurlapInput; --import com.caucho.burlap.io.BurlapOutput; --import com.caucho.services.server.Service; --import com.caucho.services.server.ServiceContext; -- --import javax.servlet.GenericServlet; --import javax.servlet.Servlet; --import javax.servlet.ServletConfig; --import javax.servlet.ServletException; --import javax.servlet.ServletRequest; --import javax.servlet.ServletResponse; --import javax.servlet.http.HttpServletRequest; --import javax.servlet.http.HttpServletResponse; --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; --import java.io.PrintWriter; -- --/** -- * Servlet for serving Burlap services. -- */ --public class BurlapServlet extends GenericServlet { -- private Class _apiClass; -- private Object _service; -- -- private BurlapSkeleton _skeleton; -- -- public String getServletInfo() -- { -- return "Burlap Servlet"; -- } -- -- /** -- * Sets the service class. -- */ -- public void setService(Object service) -- { -- _service = service; -- } -- -- /** -- * Sets the api-class. -- */ -- public void setAPIClass(Class apiClass) -- { -- _apiClass = apiClass; -- } -- -- /** -- * Initialize the service, including the service object. -- */ -- public void init(ServletConfig config) -- throws ServletException -- { -- super.init(config); -- -- try { -- if (_service == null) { -- String className = getInitParameter("service-class"); -- Class serviceClass = null; -- -- if (className != null) { -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- -- if (loader != null) -- serviceClass = Class.forName(className, false, loader); -- else -- serviceClass = Class.forName(className); -- } -- else { -- if (getClass().equals(BurlapServlet.class)) -- throw new ServletException("server must extend BurlapServlet"); -- -- serviceClass = getClass(); -- } -- -- _service = serviceClass.newInstance(); -- -- if (_service instanceof BurlapServlet) -- ((BurlapServlet) _service).setService(this); -- if (_service instanceof Service) -- ((Service) _service).init(getServletConfig()); -- else if (_service instanceof Servlet) -- ((Servlet) _service).init(getServletConfig()); -- } -- -- if (_apiClass == null) { -- String className = getInitParameter("api-class"); -- -- if (className != null) { -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- -- if (loader != null) -- _apiClass = Class.forName(className, false, loader); -- else -- _apiClass = Class.forName(className); -- } -- else -- _apiClass = _service.getClass(); -- } -- -- _skeleton = new BurlapSkeleton(_service, _apiClass); -- } catch (ServletException e) { -- throw e; -- } catch (Exception e) { -- throw new ServletException(e); -- } -- } -- -- /** -- * Execute a request. The path-info of the request selects the bean. -- * Once the bean's selected, it will be applied. -- */ -- public void service(ServletRequest request, ServletResponse response) -- throws IOException, ServletException -- { -- HttpServletRequest req = (HttpServletRequest) request; -- HttpServletResponse res = (HttpServletResponse) response; -- -- if (! req.getMethod().equals("POST")) { -- res.setStatus(500, "Burlap Requires POST"); -- PrintWriter out = res.getWriter(); -- -- res.setContentType("text/html"); -- out.println("

Burlap Requires POST

"); -- -- return; -- } -- -- String serviceId = req.getPathInfo(); -- String objectId = req.getParameter("id"); -- if (objectId == null) -- objectId = req.getParameter("ejbid"); -- -- ServiceContext.begin(req, res, serviceId, objectId); -- -- try { -- InputStream is = request.getInputStream(); -- OutputStream os = response.getOutputStream(); -- -- BurlapInput in = new BurlapInput(is); -- BurlapOutput out = new BurlapOutput(os); -- -- _skeleton.invoke(in, out); -- } catch (RuntimeException e) { -- throw e; -- } catch (ServletException e) { -- throw e; -- } catch (Throwable e) { -- throw new ServletException(e); -- } finally { -- ServiceContext.end(); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.server; -+ -+import com.caucho.burlap.io.BurlapInput; -+import com.caucho.burlap.io.BurlapOutput; -+import com.caucho.services.server.Service; -+import com.caucho.services.server.ServiceContext; -+ -+import javax.servlet.GenericServlet; -+import javax.servlet.Servlet; -+import javax.servlet.ServletConfig; -+import javax.servlet.ServletException; -+import javax.servlet.ServletRequest; -+import javax.servlet.ServletResponse; -+import javax.servlet.http.HttpServletRequest; -+import javax.servlet.http.HttpServletResponse; -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.PrintWriter; -+ -+/** -+ * Servlet for serving Burlap services. -+ */ -+public class BurlapServlet extends GenericServlet { -+ private Class _apiClass; -+ private Object _service; -+ -+ private BurlapSkeleton _skeleton; -+ -+ public String getServletInfo() -+ { -+ return "Burlap Servlet"; -+ } -+ -+ /** -+ * Sets the service class. -+ */ -+ public void setService(Object service) -+ { -+ _service = service; -+ } -+ -+ /** -+ * Sets the api-class. -+ */ -+ public void setAPIClass(Class apiClass) -+ { -+ _apiClass = apiClass; -+ } -+ -+ /** -+ * Initialize the service, including the service object. -+ */ -+ public void init(ServletConfig config) -+ throws ServletException -+ { -+ super.init(config); -+ -+ try { -+ if (_service == null) { -+ String className = getInitParameter("service-class"); -+ Class serviceClass = null; -+ -+ if (className != null) { -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ -+ if (loader != null) -+ serviceClass = Class.forName(className, false, loader); -+ else -+ serviceClass = Class.forName(className); -+ } -+ else { -+ if (getClass().equals(BurlapServlet.class)) -+ throw new ServletException("server must extend BurlapServlet"); -+ -+ serviceClass = getClass(); -+ } -+ -+ _service = serviceClass.newInstance(); -+ -+ if (_service instanceof BurlapServlet) -+ ((BurlapServlet) _service).setService(this); -+ if (_service instanceof Service) -+ ((Service) _service).init(getServletConfig()); -+ else if (_service instanceof Servlet) -+ ((Servlet) _service).init(getServletConfig()); -+ } -+ -+ if (_apiClass == null) { -+ String className = getInitParameter("api-class"); -+ -+ if (className != null) { -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ -+ if (loader != null) -+ _apiClass = Class.forName(className, false, loader); -+ else -+ _apiClass = Class.forName(className); -+ } -+ else -+ _apiClass = _service.getClass(); -+ } -+ -+ _skeleton = new BurlapSkeleton(_service, _apiClass); -+ } catch (ServletException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new ServletException(e); -+ } -+ } -+ -+ /** -+ * Execute a request. The path-info of the request selects the bean. -+ * Once the bean's selected, it will be applied. -+ */ -+ public void service(ServletRequest request, ServletResponse response) -+ throws IOException, ServletException -+ { -+ HttpServletRequest req = (HttpServletRequest) request; -+ HttpServletResponse res = (HttpServletResponse) response; -+ -+ if (! req.getMethod().equals("POST")) { -+ res.setStatus(500, "Burlap Requires POST"); -+ PrintWriter out = res.getWriter(); -+ -+ res.setContentType("text/html"); -+ out.println("

Burlap Requires POST

"); -+ -+ return; -+ } -+ -+ String serviceId = req.getPathInfo(); -+ String objectId = req.getParameter("id"); -+ if (objectId == null) -+ objectId = req.getParameter("ejbid"); -+ -+ ServiceContext.begin(req, res, serviceId, objectId); -+ -+ try { -+ InputStream is = request.getInputStream(); -+ OutputStream os = response.getOutputStream(); -+ -+ BurlapInput in = new BurlapInput(is); -+ BurlapOutput out = new BurlapOutput(os); -+ -+ _skeleton.invoke(in, out); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (ServletException e) { -+ throw e; -+ } catch (Throwable e) { -+ throw new ServletException(e); -+ } finally { -+ ServiceContext.end(); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/burlap/server/BurlapSkeleton.java hessian-4.0.65-fix/com/caucho/burlap/server/BurlapSkeleton.java ---- hessian-4.0.65-src/com/caucho/burlap/server/BurlapSkeleton.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/burlap/server/BurlapSkeleton.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,195 +1,195 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.burlap.server; -- --import com.caucho.burlap.io.BurlapInput; --import com.caucho.burlap.io.BurlapOutput; --import com.caucho.services.server.AbstractSkeleton; --import com.caucho.services.server.ServiceContext; -- --import java.lang.reflect.InvocationTargetException; --import java.lang.reflect.Method; --import java.util.logging.*; -- --/** -- * Proxy class for Burlap services. -- */ --public class BurlapSkeleton extends AbstractSkeleton { -- private static final Logger log -- = Logger.getLogger(BurlapSkeleton.class.getName()); -- -- private Object _service; -- -- /** -- * Create a new burlap skeleton. -- * -- * @param service the underlying service object. -- * @param apiClass the API interface -- */ -- public BurlapSkeleton(Object service, Class apiClass) -- { -- super(apiClass); -- -- _service = service; -- } -- -- /** -- * Create a new burlap skeleton. -- * -- * @param service the underlying service object. -- * @param apiClass the API interface -- */ -- public BurlapSkeleton(Class apiClass) -- { -- super(apiClass); -- } -- -- /** -- * Invoke the object with the request from the input stream. -- * -- * @param in the Burlap input stream -- * @param out the Burlap output stream -- */ -- public void invoke(BurlapInput in, BurlapOutput out) -- throws Exception -- { -- invoke(_service, in, out); -- } -- -- /** -- * Invoke the object with the request from the input stream. -- * -- * @param in the Burlap input stream -- * @param out the Burlap output stream -- */ -- public void invoke(Object service, BurlapInput in, BurlapOutput out) -- throws Exception -- { -- in.readCall(); -- -- ServiceContext context = ServiceContext.getContext(); -- -- String header; -- while ((header = in.readHeader()) != null) { -- Object value = in.readObject(); -- -- context.addHeader(header, value); -- } -- -- String methodName = in.readMethod(); -- Method method = getMethod(methodName); -- -- if (log.isLoggable(Level.FINE)) -- log.fine(this + " invoking " + methodName + " (" + method + ")"); -- -- if (method != null) { -- } -- else if ("_burlap_getAttribute".equals(in.getMethod())) { -- String attrName = in.readString(); -- in.completeCall(); -- -- String value = null; -- -- if ("java.api.class".equals(attrName)) -- value = getAPIClassName(); -- else if ("java.home.class".equals(attrName)) -- value = getHomeClassName(); -- else if ("java.object.class".equals(attrName)) -- value = getObjectClassName(); -- -- out.startReply(); -- -- out.writeObject(value); -- -- out.completeReply(); -- return; -- } -- else if (method == null) { -- out.startReply(); -- out.writeFault("NoSuchMethodException", -- "The service has no method named: " + in.getMethod(), -- null); -- out.completeReply(); -- return; -- } -- -- Class []args = method.getParameterTypes(); -- Object []values = new Object[args.length]; -- -- for (int i = 0; i < args.length; i++) -- values[i] = in.readObject(args[i]); -- -- in.completeCall(); -- -- Object result = null; -- -- try { -- result = method.invoke(service, values); -- } catch (Throwable e) { -- log.log(Level.FINE, -- service + "." + method.getName() + "() failed with exception:\n" -- + e.toString(), -- e); -- -- if (e instanceof InvocationTargetException -- && e.getCause() instanceof Exception) -- e = ((InvocationTargetException) e).getTargetException(); -- out.startReply(); -- out.writeFault("ServiceException", e.getMessage(), e); -- out.completeReply(); -- return; -- } -- -- out.startReply(); -- -- out.writeObject(result); -- -- out.completeReply(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.burlap.server; -+ -+import com.caucho.burlap.io.BurlapInput; -+import com.caucho.burlap.io.BurlapOutput; -+import com.caucho.services.server.AbstractSkeleton; -+import com.caucho.services.server.ServiceContext; -+ -+import java.lang.reflect.InvocationTargetException; -+import java.lang.reflect.Method; -+import java.util.logging.*; -+ -+/** -+ * Proxy class for Burlap services. -+ */ -+public class BurlapSkeleton extends AbstractSkeleton { -+ private static final Logger log -+ = Logger.getLogger(BurlapSkeleton.class.getName()); -+ -+ private Object _service; -+ -+ /** -+ * Create a new burlap skeleton. -+ * -+ * @param service the underlying service object. -+ * @param apiClass the API interface -+ */ -+ public BurlapSkeleton(Object service, Class apiClass) -+ { -+ super(apiClass); -+ -+ _service = service; -+ } -+ -+ /** -+ * Create a new burlap skeleton. -+ * -+ * @param service the underlying service object. -+ * @param apiClass the API interface -+ */ -+ public BurlapSkeleton(Class apiClass) -+ { -+ super(apiClass); -+ } -+ -+ /** -+ * Invoke the object with the request from the input stream. -+ * -+ * @param in the Burlap input stream -+ * @param out the Burlap output stream -+ */ -+ public void invoke(BurlapInput in, BurlapOutput out) -+ throws Exception -+ { -+ invoke(_service, in, out); -+ } -+ -+ /** -+ * Invoke the object with the request from the input stream. -+ * -+ * @param in the Burlap input stream -+ * @param out the Burlap output stream -+ */ -+ public void invoke(Object service, BurlapInput in, BurlapOutput out) -+ throws Exception -+ { -+ in.readCall(); -+ -+ ServiceContext context = ServiceContext.getContext(); -+ -+ String header; -+ while ((header = in.readHeader()) != null) { -+ Object value = in.readObject(); -+ -+ context.addHeader(header, value); -+ } -+ -+ String methodName = in.readMethod(); -+ Method method = getMethod(methodName); -+ -+ if (log.isLoggable(Level.FINE)) -+ log.fine(this + " invoking " + methodName + " (" + method + ")"); -+ -+ if (method != null) { -+ } -+ else if ("_burlap_getAttribute".equals(in.getMethod())) { -+ String attrName = in.readString(); -+ in.completeCall(); -+ -+ String value = null; -+ -+ if ("java.api.class".equals(attrName)) -+ value = getAPIClassName(); -+ else if ("java.home.class".equals(attrName)) -+ value = getHomeClassName(); -+ else if ("java.object.class".equals(attrName)) -+ value = getObjectClassName(); -+ -+ out.startReply(); -+ -+ out.writeObject(value); -+ -+ out.completeReply(); -+ return; -+ } -+ else if (method == null) { -+ out.startReply(); -+ out.writeFault("NoSuchMethodException", -+ "The service has no method named: " + in.getMethod(), -+ null); -+ out.completeReply(); -+ return; -+ } -+ -+ Class []args = method.getParameterTypes(); -+ Object []values = new Object[args.length]; -+ -+ for (int i = 0; i < args.length; i++) -+ values[i] = in.readObject(args[i]); -+ -+ in.completeCall(); -+ -+ Object result = null; -+ -+ try { -+ result = method.invoke(service, values); -+ } catch (Throwable e) { -+ log.log(Level.FINE, -+ service + "." + method.getName() + "() failed with exception:\n" -+ + e.toString(), -+ e); -+ -+ if (e instanceof InvocationTargetException -+ && e.getCause() instanceof Exception) -+ e = ((InvocationTargetException) e).getTargetException(); -+ out.startReply(); -+ out.writeFault("ServiceException", e.getMessage(), e); -+ out.completeReply(); -+ return; -+ } -+ -+ out.startReply(); -+ -+ out.writeObject(result); -+ -+ out.completeReply(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/HessianException.java hessian-4.0.65-fix/com/caucho/hessian/HessianException.java ---- hessian-4.0.65-src/com/caucho/hessian/HessianException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/HessianException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,85 +1,85 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian; -- --/** -- * Base runtime exception for Hessian exceptions. -- */ --public class HessianException extends RuntimeException { -- /** -- * Zero-arg constructor. -- */ -- public HessianException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public HessianException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public HessianException(String message, Throwable rootCause) -- { -- super(message, rootCause); -- } -- -- /** -- * Create the exception. -- */ -- public HessianException(Throwable rootCause) -- { -- super(rootCause); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian; -+ -+/** -+ * Base runtime exception for Hessian exceptions. -+ */ -+public class HessianException extends RuntimeException { -+ /** -+ * Zero-arg constructor. -+ */ -+ public HessianException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianException(String message, Throwable rootCause) -+ { -+ super(message, rootCause); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianException(Throwable rootCause) -+ { -+ super(rootCause); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/HessianUnshared.java hessian-4.0.65-fix/com/caucho/hessian/HessianUnshared.java ---- hessian-4.0.65-src/com/caucho/hessian/HessianUnshared.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/HessianUnshared.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,68 +1,68 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- -- --package com.caucho.hessian; -- --import java.lang.annotation.ElementType; --import java.lang.annotation.Retention; --import java.lang.annotation.RetentionPolicy; --import java.lang.annotation.Target; -- --/** -- * Marks the class and all children as unshared. -- * A reference item will be created, but will not be stored in a -- * mapped or checked for duplicated. -- * -- * Used for efficiency to avoid the cost of the map lookup. -- */ --@Target({ElementType.TYPE }) --@Retention(RetentionPolicy.RUNTIME) --public @interface HessianUnshared --{ --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+ -+package com.caucho.hessian; -+ -+import java.lang.annotation.ElementType; -+import java.lang.annotation.Retention; -+import java.lang.annotation.RetentionPolicy; -+import java.lang.annotation.Target; -+ -+/** -+ * Marks the class and all children as unshared. -+ * A reference item will be created, but will not be stored in a -+ * mapped or checked for duplicated. -+ * -+ * Used for efficiency to avoid the cost of the map lookup. -+ */ -+@Target({ElementType.TYPE }) -+@Retention(RetentionPolicy.RUNTIME) -+public @interface HessianUnshared -+{ -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnection.java hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnection.java ---- hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnection.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnection.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,117 +1,117 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import java.net.URL; --import java.io.InputStream; --import java.io.OutputStream; --import java.io.IOException; -- --/** -- * Internal connection to a server. The default connection is based on -- * java.net -- */ --abstract public class AbstractHessianConnection implements HessianConnection { -- /** -- * Adds HTTP headers. -- */ -- public void addHeader(String key, String value) -- { -- } -- -- /** -- * Returns the output stream for the request. -- */ -- abstract public OutputStream getOutputStream() -- throws IOException; -- -- /** -- * Sends the query -- */ -- abstract public void sendRequest() -- throws IOException; -- -- /** -- * Returns the status code. -- */ -- abstract public int getStatusCode(); -- -- /** -- * Returns the status string. -- */ -- abstract public String getStatusMessage(); -- -- /** -- * Returns the InputStream to the result -- */ -- abstract public InputStream getInputStream() -- throws IOException; -- -- @Override -- public String getContentEncoding() -- { -- return null; -- } -- -- /** -- * Close/free the connection, using keepalive if appropriate. -- */ -- public void close() -- throws IOException -- { -- destroy(); -- } -- -- /** -- * Destroy/disconnect the connection -- */ -- abstract public void destroy() -- throws IOException; --} -- -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import java.net.URL; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.IOException; -+ -+/** -+ * Internal connection to a server. The default connection is based on -+ * java.net -+ */ -+abstract public class AbstractHessianConnection implements HessianConnection { -+ /** -+ * Adds HTTP headers. -+ */ -+ public void addHeader(String key, String value) -+ { -+ } -+ -+ /** -+ * Returns the output stream for the request. -+ */ -+ abstract public OutputStream getOutputStream() -+ throws IOException; -+ -+ /** -+ * Sends the query -+ */ -+ abstract public void sendRequest() -+ throws IOException; -+ -+ /** -+ * Returns the status code. -+ */ -+ abstract public int getStatusCode(); -+ -+ /** -+ * Returns the status string. -+ */ -+ abstract public String getStatusMessage(); -+ -+ /** -+ * Returns the InputStream to the result -+ */ -+ abstract public InputStream getInputStream() -+ throws IOException; -+ -+ @Override -+ public String getContentEncoding() -+ { -+ return null; -+ } -+ -+ /** -+ * Close/free the connection, using keepalive if appropriate. -+ */ -+ public void close() -+ throws IOException -+ { -+ destroy(); -+ } -+ -+ /** -+ * Destroy/disconnect the connection -+ */ -+ abstract public void destroy() -+ throws IOException; -+} -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnectionFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnectionFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/client/AbstractHessianConnectionFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/AbstractHessianConnectionFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,86 +1,86 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import java.net.URL; --import java.io.IOException; -- --/** -- * Internal factory for creating connections to the server. The default -- * factory is java.net -- */ --abstract public class AbstractHessianConnectionFactory -- implements HessianConnectionFactory --{ -- private HessianProxyFactory _factory; -- -- /** -- * The HessianProxyFactory contains some common network -- * configuration like timeouts. -- */ -- public void setHessianProxyFactory(HessianProxyFactory factory) -- { -- _factory = factory; -- } -- -- /** -- * The HessianProxyFactory contains some common network -- * configuration like timeouts. -- */ -- public HessianProxyFactory getHessianProxyFactory() -- { -- return _factory; -- } -- -- /** -- * Opens a new or recycled connection to the HTTP server. -- */ -- abstract public HessianConnection open(URL url) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import java.net.URL; -+import java.io.IOException; -+ -+/** -+ * Internal factory for creating connections to the server. The default -+ * factory is java.net -+ */ -+abstract public class AbstractHessianConnectionFactory -+ implements HessianConnectionFactory -+{ -+ private HessianProxyFactory _factory; -+ -+ /** -+ * The HessianProxyFactory contains some common network -+ * configuration like timeouts. -+ */ -+ public void setHessianProxyFactory(HessianProxyFactory factory) -+ { -+ _factory = factory; -+ } -+ -+ /** -+ * The HessianProxyFactory contains some common network -+ * configuration like timeouts. -+ */ -+ public HessianProxyFactory getHessianProxyFactory() -+ { -+ return _factory; -+ } -+ -+ /** -+ * Opens a new or recycled connection to the HTTP server. -+ */ -+ abstract public HessianConnection open(URL url) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianConnection.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnection.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianConnection.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnection.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,112 +1,112 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import java.net.URL; --import java.io.InputStream; --import java.io.OutputStream; --import java.io.IOException; -- --/** -- * Internal connection to a server. The default connection is based on -- * java.net -- */ --public interface HessianConnection { -- /** -- * Adds HTTP headers. -- */ -- public void addHeader(String key, String value); -- -- /** -- * Returns the output stream for the request. -- */ -- public OutputStream getOutputStream() -- throws IOException; -- -- /** -- * Sends the query -- */ -- public void sendRequest() -- throws IOException; -- -- /** -- * Returns the status code. -- */ -- public int getStatusCode(); -- -- /** -- * Returns the status string. -- */ -- public String getStatusMessage(); -- -- /** -- * Returns the content encoding -- */ -- public String getContentEncoding(); -- -- -- /** -- * Returns the InputStream to the result -- */ -- public InputStream getInputStream() -- throws IOException; -- -- /** -- * Close/free the connection. If keepalive is allowed, it may be used. -- */ -- public void close() -- throws IOException; -- -- /** -- * Shut the connection down. -- */ -- public void destroy() -- throws IOException; --} -- -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import java.net.URL; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.IOException; -+ -+/** -+ * Internal connection to a server. The default connection is based on -+ * java.net -+ */ -+public interface HessianConnection { -+ /** -+ * Adds HTTP headers. -+ */ -+ public void addHeader(String key, String value); -+ -+ /** -+ * Returns the output stream for the request. -+ */ -+ public OutputStream getOutputStream() -+ throws IOException; -+ -+ /** -+ * Sends the query -+ */ -+ public void sendRequest() -+ throws IOException; -+ -+ /** -+ * Returns the status code. -+ */ -+ public int getStatusCode(); -+ -+ /** -+ * Returns the status string. -+ */ -+ public String getStatusMessage(); -+ -+ /** -+ * Returns the content encoding -+ */ -+ public String getContentEncoding(); -+ -+ -+ /** -+ * Returns the InputStream to the result -+ */ -+ public InputStream getInputStream() -+ throws IOException; -+ -+ /** -+ * Close/free the connection. If keepalive is allowed, it may be used. -+ */ -+ public void close() -+ throws IOException; -+ -+ /** -+ * Shut the connection down. -+ */ -+ public void destroy() -+ throws IOException; -+} -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionException.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionException.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,87 +1,87 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import com.caucho.hessian.HessianException; -- --/** -- * Exception caused by failure of the client proxy to connect to the server. -- */ --public class HessianConnectionException extends HessianException { -- /** -- * Zero-arg constructor. -- */ -- public HessianConnectionException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public HessianConnectionException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public HessianConnectionException(String message, Throwable rootCause) -- { -- super(message, rootCause); -- } -- -- /** -- * Create the exception. -- */ -- public HessianConnectionException(Throwable rootCause) -- { -- super(rootCause); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Exception caused by failure of the client proxy to connect to the server. -+ */ -+public class HessianConnectionException extends HessianException { -+ /** -+ * Zero-arg constructor. -+ */ -+ public HessianConnectionException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianConnectionException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianConnectionException(String message, Throwable rootCause) -+ { -+ super(message, rootCause); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianConnectionException(Throwable rootCause) -+ { -+ super(rootCause); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianConnectionFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianConnectionFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,69 +1,69 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import java.net.URL; --import java.io.IOException; -- --/** -- * Internal factory for creating connections to the server. The default -- * factory is java.net -- */ --public interface HessianConnectionFactory { -- /** -- * Sets the HessianProxyFactory -- */ -- public void setHessianProxyFactory(HessianProxyFactory factory); -- -- /** -- * Opens a new or recycled connection to the HTTP server. -- */ -- public HessianConnection open(URL url) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import java.net.URL; -+import java.io.IOException; -+ -+/** -+ * Internal factory for creating connections to the server. The default -+ * factory is java.net -+ */ -+public interface HessianConnectionFactory { -+ /** -+ * Sets the HessianProxyFactory -+ */ -+ public void setHessianProxyFactory(HessianProxyFactory factory); -+ -+ /** -+ * Opens a new or recycled connection to the HTTP server. -+ */ -+ public HessianConnection open(URL url) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianMetaInfoAPI.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianMetaInfoAPI.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianMetaInfoAPI.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianMetaInfoAPI.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,66 +1,66 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --/** -- * API retrieving hessian meta information. -- */ --public interface HessianMetaInfoAPI { -- /** -- * Returns a service attribute. -- * -- *
    -- *
  • java.api.class - the Java interface for the object interface. -- *
  • java.ejb.home.class - the EJB home interface -- *
  • java.ejb.remote.class - the EJB remote interface -- *
  • java.primary.key.class - the EJB primary key class -- *
-- */ -- public Object _hessian_getAttribute(String name); --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+/** -+ * API retrieving hessian meta information. -+ */ -+public interface HessianMetaInfoAPI { -+ /** -+ * Returns a service attribute. -+ * -+ *
    -+ *
  • java.api.class - the Java interface for the object interface. -+ *
  • java.ejb.home.class - the EJB home interface -+ *
  • java.ejb.remote.class - the EJB remote interface -+ *
  • java.primary.key.class - the EJB primary key class -+ *
-+ */ -+ public Object _hessian_getAttribute(String name); -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianProxy.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxy.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianProxy.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxy.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,483 +1,483 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import com.caucho.hessian.io.*; --import com.caucho.services.server.*; -- --import java.io.*; --import java.util.logging.*; --import java.lang.reflect.InvocationHandler; --import java.lang.reflect.Method; --import java.lang.reflect.Proxy; --import java.util.WeakHashMap; --import java.net.HttpURLConnection; --import java.net.URL; --import java.net.URLConnection; --import java.util.zip.*; -- --/** -- * Proxy implementation for Hessian clients. Applications will generally -- * use HessianProxyFactory to create proxy clients. -- */ --public class HessianProxy implements InvocationHandler, Serializable { -- private static final Logger log -- = Logger.getLogger(HessianProxy.class.getName()); -- -- protected HessianProxyFactory _factory; -- -- private WeakHashMap _mangleMap -- = new WeakHashMap(); -- -- private Class _type; -- private URL _url; -- -- /** -- * Protected constructor for subclassing -- */ -- protected HessianProxy(URL url, HessianProxyFactory factory) -- { -- this(url, factory, null); -- } -- -- /** -- * Protected constructor for subclassing -- */ -- protected HessianProxy(URL url, -- HessianProxyFactory factory, -- Class type) -- { -- _factory = factory; -- _url = url; -- _type = type; -- } -- -- /** -- * Returns the proxy's URL. -- */ -- public URL getURL() -- { -- return _url; -- } -- -- /** -- * Handles the object invocation. -- * -- * @param proxy the proxy object to invoke -- * @param method the method to call -- * @param args the arguments to the proxy object -- */ -- public Object invoke(Object proxy, Method method, Object []args) -- throws Throwable -- { -- String mangleName; -- -- synchronized (_mangleMap) { -- mangleName = _mangleMap.get(method); -- } -- -- if (mangleName == null) { -- String methodName = method.getName(); -- Class []params = method.getParameterTypes(); -- -- // equals and hashCode are special cased -- if (methodName.equals("equals") -- && params.length == 1 && params[0].equals(Object.class)) { -- Object value = args[0]; -- if (value == null || ! Proxy.isProxyClass(value.getClass())) -- return Boolean.FALSE; -- -- Object proxyHandler = Proxy.getInvocationHandler(value); -- -- if (! (proxyHandler instanceof HessianProxy)) -- return Boolean.FALSE; -- -- HessianProxy handler = (HessianProxy) proxyHandler; -- -- return new Boolean(_url.equals(handler.getURL())); -- } -- else if (methodName.equals("hashCode") && params.length == 0) -- return new Integer(_url.hashCode()); -- else if (methodName.equals("getHessianType")) -- return proxy.getClass().getInterfaces()[0].getName(); -- else if (methodName.equals("getHessianURL")) -- return _url.toString(); -- else if (methodName.equals("toString") && params.length == 0) -- return "HessianProxy[" + _url + "]"; -- -- if (! _factory.isOverloadEnabled()) -- mangleName = method.getName(); -- else -- mangleName = mangleName(method); -- -- synchronized (_mangleMap) { -- _mangleMap.put(method, mangleName); -- } -- } -- -- InputStream is = null; -- HessianConnection conn = null; -- -- try { -- if (log.isLoggable(Level.FINER)) -- log.finer("Hessian[" + _url + "] calling " + mangleName); -- -- conn = sendRequest(mangleName, args); -- -- is = getInputStream(conn); -- -- if (log.isLoggable(Level.FINEST)) { -- PrintWriter dbg = new PrintWriter(new LogWriter(log)); -- HessianDebugInputStream dIs -- = new HessianDebugInputStream(is, dbg); -- -- dIs.startTop2(); -- -- is = dIs; -- } -- -- AbstractHessianInput in; -- -- int code = is.read(); -- -- if (code == 'H') { -- int major = is.read(); -- int minor = is.read(); -- -- in = _factory.getHessian2Input(is); -- -- Object value = in.readReply(method.getReturnType()); -- -- if (value instanceof InputStream) { -- value = new ResultInputStream(conn, is, in, (InputStream) value); -- is = null; -- conn = null; -- } -- -- return value; -- } -- else if (code == 'r') { -- int major = is.read(); -- int minor = is.read(); -- -- in = _factory.getHessianInput(is); -- -- in.startReplyBody(); -- -- Object value = in.readObject(method.getReturnType()); -- -- if (value instanceof InputStream) { -- value = new ResultInputStream(conn, is, in, (InputStream) value); -- is = null; -- conn = null; -- } -- else { -- in.completeReply(); -- } -- -- return value; -- } -- else -- throw new HessianProtocolException("'" + (char) code + "' is an unknown code"); -- } catch (HessianProtocolException e) { -- throw new HessianRuntimeException(e); -- } finally { -- try { -- if (is != null) -- is.close(); -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- try { -- if (conn != null) -- conn.destroy(); -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- } -- } -- } -- -- protected InputStream getInputStream(HessianConnection conn) -- throws IOException -- { -- InputStream is = conn.getInputStream(); -- -- if ("deflate".equals(conn.getContentEncoding())) { -- is = new InflaterInputStream(is, new Inflater(true)); -- } -- -- return is; -- } -- -- protected String mangleName(Method method) -- { -- Class []param = method.getParameterTypes(); -- -- if (param == null || param.length == 0) -- return method.getName(); -- else -- return AbstractSkeleton.mangleName(method, false); -- } -- -- /** -- * Sends the HTTP request to the Hessian connection. -- */ -- protected HessianConnection sendRequest(String methodName, Object []args) -- throws IOException -- { -- HessianConnection conn = null; -- -- conn = _factory.getConnectionFactory().open(_url); -- boolean isValid = false; -- -- try { -- addRequestHeaders(conn); -- -- OutputStream os = null; -- -- try { -- os = conn.getOutputStream(); -- } catch (Exception e) { -- throw new HessianRuntimeException(e); -- } -- -- if (log.isLoggable(Level.FINEST)) { -- PrintWriter dbg = new PrintWriter(new LogWriter(log)); -- HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); -- dOs.startTop2(); -- os = dOs; -- } -- -- AbstractHessianOutput out = _factory.getHessianOutput(os); -- -- out.call(methodName, args); -- out.flush(); -- -- conn.sendRequest(); -- -- isValid = true; -- -- return conn; -- } finally { -- if (! isValid && conn != null) -- conn.destroy(); -- } -- } -- -- /** -- * Method that allows subclasses to add request headers such as cookies. -- * Default implementation is empty. -- */ -- protected void addRequestHeaders(HessianConnection conn) -- { -- conn.addHeader("Content-Type", "x-application/hessian"); -- conn.addHeader("Accept-Encoding", "deflate"); -- -- String basicAuth = _factory.getBasicAuth(); -- -- if (basicAuth != null) -- conn.addHeader("Authorization", basicAuth); -- } -- -- /** -- * Method that allows subclasses to parse response headers such as cookies. -- * Default implementation is empty. -- * @param conn -- */ -- protected void parseResponseHeaders(URLConnection conn) -- { -- } -- -- public Object writeReplace() -- { -- return new HessianRemote(_type.getName(), _url.toString()); -- } -- -- static class ResultInputStream extends InputStream { -- private HessianConnection _conn; -- private InputStream _connIs; -- private AbstractHessianInput _in; -- private InputStream _hessianIs; -- -- ResultInputStream(HessianConnection conn, -- InputStream is, -- AbstractHessianInput in, -- InputStream hessianIs) -- { -- _conn = conn; -- _connIs = is; -- _in = in; -- _hessianIs = hessianIs; -- } -- -- public int read() -- throws IOException -- { -- if (_hessianIs != null) { -- int value = _hessianIs.read(); -- -- if (value < 0) -- close(); -- -- return value; -- } -- else -- return -1; -- } -- -- public int read(byte []buffer, int offset, int length) -- throws IOException -- { -- if (_hessianIs != null) { -- int value = _hessianIs.read(buffer, offset, length); -- -- if (value < 0) -- close(); -- -- return value; -- } -- else -- return -1; -- } -- -- public void close() -- throws IOException -- { -- HessianConnection conn = _conn; -- _conn = null; -- -- InputStream connIs = _connIs; -- _connIs = null; -- -- AbstractHessianInput in = _in; -- _in = null; -- -- InputStream hessianIs = _hessianIs; -- _hessianIs = null; -- -- try { -- if (hessianIs != null) -- hessianIs.close(); -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- try { -- if (in != null) { -- in.completeReply(); -- in.close(); -- } -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- try { -- if (connIs != null) { -- connIs.close(); -- } -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- try { -- if (conn != null) { -- conn.close(); -- } -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- } -- } -- } -- -- static class LogWriter extends Writer { -- private Logger _log; -- private Level _level = Level.FINEST; -- private StringBuilder _sb = new StringBuilder(); -- -- LogWriter(Logger log) -- { -- _log = log; -- } -- -- public void write(char ch) -- { -- if (ch == '\n' && _sb.length() > 0) { -- _log.fine(_sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- -- public void write(char []buffer, int offset, int length) -- { -- for (int i = 0; i < length; i++) { -- char ch = buffer[offset + i]; -- -- if (ch == '\n' && _sb.length() > 0) { -- _log.log(_level, _sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- } -- -- public void flush() -- { -- } -- -- public void close() -- { -- if (_sb.length() > 0) -- _log.log(_level, _sb.toString()); -- } -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import com.caucho.hessian.io.*; -+import com.caucho.services.server.*; -+ -+import java.io.*; -+import java.util.logging.*; -+import java.lang.reflect.InvocationHandler; -+import java.lang.reflect.Method; -+import java.lang.reflect.Proxy; -+import java.util.WeakHashMap; -+import java.net.HttpURLConnection; -+import java.net.URL; -+import java.net.URLConnection; -+import java.util.zip.*; -+ -+/** -+ * Proxy implementation for Hessian clients. Applications will generally -+ * use HessianProxyFactory to create proxy clients. -+ */ -+public class HessianProxy implements InvocationHandler, Serializable { -+ private static final Logger log -+ = Logger.getLogger(HessianProxy.class.getName()); -+ -+ protected HessianProxyFactory _factory; -+ -+ private WeakHashMap _mangleMap -+ = new WeakHashMap(); -+ -+ private Class _type; -+ private URL _url; -+ -+ /** -+ * Protected constructor for subclassing -+ */ -+ protected HessianProxy(URL url, HessianProxyFactory factory) -+ { -+ this(url, factory, null); -+ } -+ -+ /** -+ * Protected constructor for subclassing -+ */ -+ protected HessianProxy(URL url, -+ HessianProxyFactory factory, -+ Class type) -+ { -+ _factory = factory; -+ _url = url; -+ _type = type; -+ } -+ -+ /** -+ * Returns the proxy's URL. -+ */ -+ public URL getURL() -+ { -+ return _url; -+ } -+ -+ /** -+ * Handles the object invocation. -+ * -+ * @param proxy the proxy object to invoke -+ * @param method the method to call -+ * @param args the arguments to the proxy object -+ */ -+ public Object invoke(Object proxy, Method method, Object []args) -+ throws Throwable -+ { -+ String mangleName; -+ -+ synchronized (_mangleMap) { -+ mangleName = _mangleMap.get(method); -+ } -+ -+ if (mangleName == null) { -+ String methodName = method.getName(); -+ Class []params = method.getParameterTypes(); -+ -+ // equals and hashCode are special cased -+ if (methodName.equals("equals") -+ && params.length == 1 && params[0].equals(Object.class)) { -+ Object value = args[0]; -+ if (value == null || ! Proxy.isProxyClass(value.getClass())) -+ return Boolean.FALSE; -+ -+ Object proxyHandler = Proxy.getInvocationHandler(value); -+ -+ if (! (proxyHandler instanceof HessianProxy)) -+ return Boolean.FALSE; -+ -+ HessianProxy handler = (HessianProxy) proxyHandler; -+ -+ return new Boolean(_url.equals(handler.getURL())); -+ } -+ else if (methodName.equals("hashCode") && params.length == 0) -+ return new Integer(_url.hashCode()); -+ else if (methodName.equals("getHessianType")) -+ return proxy.getClass().getInterfaces()[0].getName(); -+ else if (methodName.equals("getHessianURL")) -+ return _url.toString(); -+ else if (methodName.equals("toString") && params.length == 0) -+ return "HessianProxy[" + _url + "]"; -+ -+ if (! _factory.isOverloadEnabled()) -+ mangleName = method.getName(); -+ else -+ mangleName = mangleName(method); -+ -+ synchronized (_mangleMap) { -+ _mangleMap.put(method, mangleName); -+ } -+ } -+ -+ InputStream is = null; -+ HessianConnection conn = null; -+ -+ try { -+ if (log.isLoggable(Level.FINER)) -+ log.finer("Hessian[" + _url + "] calling " + mangleName); -+ -+ conn = sendRequest(mangleName, args); -+ -+ is = getInputStream(conn); -+ -+ if (log.isLoggable(Level.FINEST)) { -+ PrintWriter dbg = new PrintWriter(new LogWriter(log)); -+ HessianDebugInputStream dIs -+ = new HessianDebugInputStream(is, dbg); -+ -+ dIs.startTop2(); -+ -+ is = dIs; -+ } -+ -+ AbstractHessianInput in; -+ -+ int code = is.read(); -+ -+ if (code == 'H') { -+ int major = is.read(); -+ int minor = is.read(); -+ -+ in = _factory.getHessian2Input(is); -+ -+ Object value = in.readReply(method.getReturnType()); -+ -+ if (value instanceof InputStream) { -+ value = new ResultInputStream(conn, is, in, (InputStream) value); -+ is = null; -+ conn = null; -+ } -+ -+ return value; -+ } -+ else if (code == 'r') { -+ int major = is.read(); -+ int minor = is.read(); -+ -+ in = _factory.getHessianInput(is); -+ -+ in.startReplyBody(); -+ -+ Object value = in.readObject(method.getReturnType()); -+ -+ if (value instanceof InputStream) { -+ value = new ResultInputStream(conn, is, in, (InputStream) value); -+ is = null; -+ conn = null; -+ } -+ else { -+ in.completeReply(); -+ } -+ -+ return value; -+ } -+ else -+ throw new HessianProtocolException("'" + (char) code + "' is an unknown code"); -+ } catch (HessianProtocolException e) { -+ throw new HessianRuntimeException(e); -+ } finally { -+ try { -+ if (is != null) -+ is.close(); -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ try { -+ if (conn != null) -+ conn.destroy(); -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ } -+ } -+ -+ protected InputStream getInputStream(HessianConnection conn) -+ throws IOException -+ { -+ InputStream is = conn.getInputStream(); -+ -+ if ("deflate".equals(conn.getContentEncoding())) { -+ is = new InflaterInputStream(is, new Inflater(true)); -+ } -+ -+ return is; -+ } -+ -+ protected String mangleName(Method method) -+ { -+ Class []param = method.getParameterTypes(); -+ -+ if (param == null || param.length == 0) -+ return method.getName(); -+ else -+ return AbstractSkeleton.mangleName(method, false); -+ } -+ -+ /** -+ * Sends the HTTP request to the Hessian connection. -+ */ -+ protected HessianConnection sendRequest(String methodName, Object []args) -+ throws IOException -+ { -+ HessianConnection conn = null; -+ -+ conn = _factory.getConnectionFactory().open(_url); -+ boolean isValid = false; -+ -+ try { -+ addRequestHeaders(conn); -+ -+ OutputStream os = null; -+ -+ try { -+ os = conn.getOutputStream(); -+ } catch (Exception e) { -+ throw new HessianRuntimeException(e); -+ } -+ -+ if (log.isLoggable(Level.FINEST)) { -+ PrintWriter dbg = new PrintWriter(new LogWriter(log)); -+ HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); -+ dOs.startTop2(); -+ os = dOs; -+ } -+ -+ AbstractHessianOutput out = _factory.getHessianOutput(os); -+ -+ out.call(methodName, args); -+ out.flush(); -+ -+ conn.sendRequest(); -+ -+ isValid = true; -+ -+ return conn; -+ } finally { -+ if (! isValid && conn != null) -+ conn.destroy(); -+ } -+ } -+ -+ /** -+ * Method that allows subclasses to add request headers such as cookies. -+ * Default implementation is empty. -+ */ -+ protected void addRequestHeaders(HessianConnection conn) -+ { -+ conn.addHeader("Content-Type", "x-application/hessian"); -+ conn.addHeader("Interface-Name", this._type.getCanonicalName()); -+ -+ String basicAuth = _factory.getBasicAuth(); -+ -+ if (basicAuth != null) -+ conn.addHeader("Authorization", basicAuth); -+ } -+ -+ /** -+ * Method that allows subclasses to parse response headers such as cookies. -+ * Default implementation is empty. -+ * @param conn -+ */ -+ protected void parseResponseHeaders(URLConnection conn) -+ { -+ } -+ -+ public Object writeReplace() -+ { -+ return new HessianRemote(_type.getName(), _url.toString()); -+ } -+ -+ static class ResultInputStream extends InputStream { -+ private HessianConnection _conn; -+ private InputStream _connIs; -+ private AbstractHessianInput _in; -+ private InputStream _hessianIs; -+ -+ ResultInputStream(HessianConnection conn, -+ InputStream is, -+ AbstractHessianInput in, -+ InputStream hessianIs) -+ { -+ _conn = conn; -+ _connIs = is; -+ _in = in; -+ _hessianIs = hessianIs; -+ } -+ -+ public int read() -+ throws IOException -+ { -+ if (_hessianIs != null) { -+ int value = _hessianIs.read(); -+ -+ if (value < 0) -+ close(); -+ -+ return value; -+ } -+ else -+ return -1; -+ } -+ -+ public int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (_hessianIs != null) { -+ int value = _hessianIs.read(buffer, offset, length); -+ -+ if (value < 0) -+ close(); -+ -+ return value; -+ } -+ else -+ return -1; -+ } -+ -+ public void close() -+ throws IOException -+ { -+ HessianConnection conn = _conn; -+ _conn = null; -+ -+ InputStream connIs = _connIs; -+ _connIs = null; -+ -+ AbstractHessianInput in = _in; -+ _in = null; -+ -+ InputStream hessianIs = _hessianIs; -+ _hessianIs = null; -+ -+ try { -+ if (hessianIs != null) -+ hessianIs.close(); -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ try { -+ if (in != null) { -+ in.completeReply(); -+ in.close(); -+ } -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ try { -+ if (connIs != null) { -+ connIs.close(); -+ } -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ try { -+ if (conn != null) { -+ conn.close(); -+ } -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ } -+ } -+ -+ static class LogWriter extends Writer { -+ private Logger _log; -+ private Level _level = Level.FINEST; -+ private StringBuilder _sb = new StringBuilder(); -+ -+ LogWriter(Logger log) -+ { -+ _log = log; -+ } -+ -+ public void write(char ch) -+ { -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.fine(_sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ -+ public void write(char []buffer, int offset, int length) -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = buffer[offset + i]; -+ -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.log(_level, _sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ } -+ -+ public void flush() -+ { -+ } -+ -+ public void close() -+ { -+ if (_sb.length() > 0) -+ _log.log(_level, _sb.toString()); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,613 +1,613 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import java.io.InputStream; --import java.io.OutputStream; --import java.io.PrintWriter; --import java.lang.reflect.InvocationHandler; --import java.lang.reflect.Proxy; --import java.net.MalformedURLException; --import java.net.URL; --import java.util.Hashtable; --import java.util.logging.Logger; -- --import javax.naming.Context; --import javax.naming.Name; --import javax.naming.NamingException; --import javax.naming.RefAddr; --import javax.naming.Reference; --import javax.naming.spi.ObjectFactory; -- --import com.caucho.hessian.io.AbstractHessianInput; --import com.caucho.hessian.io.AbstractHessianOutput; --import com.caucho.hessian.io.Hessian2Input; --import com.caucho.hessian.io.Hessian2Output; --import com.caucho.hessian.io.HessianDebugInputStream; --import com.caucho.hessian.io.HessianInput; --import com.caucho.hessian.io.HessianOutput; --import com.caucho.hessian.io.HessianRemoteObject; --import com.caucho.hessian.io.HessianRemoteResolver; --import com.caucho.hessian.io.SerializerFactory; --import com.caucho.services.client.ServiceProxyFactory; -- --/** -- * Factory for creating Hessian client stubs. The returned stub will -- * call the remote object for all methods. -- * -- *
-- * String url = "http://localhost:8080/ejb/hello";
-- * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-- * 
-- * -- * After creation, the stub can be like a regular Java class. Because -- * it makes remote calls, it can throw more exceptions than a Java class. -- * In particular, it may throw protocol exceptions. -- * -- * The factory can also be configured as a JNDI resource. The factory -- * expects to parameters: "type" and "url", corresponding to the two -- * arguments to create -- * -- * In Resin 3.0, the above example would be configured as: -- *
-- * <reference>
-- *   <jndi-name>hessian/hello</jndi-name>
-- *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
-- *   <init-param url="http://localhost:8080/ejb/hello"/>
-- *   <init-param type="test.HelloHome"/>
-- * </reference>
-- * 
-- * -- * To get the above resource, use JNDI as follows: -- *
-- * Context ic = new InitialContext();
-- * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/hessian/hello");
-- *
-- * System.out.println("Hello: " + hello.helloWorld());
-- * 
-- * -- *

Authentication

-- * -- *

The proxy can use HTTP basic authentication if the user and the -- * password are set. -- */ --public class HessianProxyFactory implements ServiceProxyFactory, ObjectFactory { -- protected static Logger log -- = Logger.getLogger(HessianProxyFactory.class.getName()); -- -- private final ClassLoader _loader; -- -- private SerializerFactory _serializerFactory; -- -- private HessianConnectionFactory _connFactory; -- -- private HessianRemoteResolver _resolver; -- -- private String _user; -- private String _password; -- private String _basicAuth; -- -- private boolean _isOverloadEnabled = false; -- -- private boolean _isHessian2Reply = true; -- private boolean _isHessian2Request = false; -- -- private boolean _isChunkedPost = true; -- private boolean _isDebug = false; -- -- private long _readTimeout = -1; -- private long _connectTimeout = -1; -- -- /** -- * Creates the new proxy factory. -- */ -- public HessianProxyFactory() -- { -- this(Thread.currentThread().getContextClassLoader()); -- } -- -- /** -- * Creates the new proxy factory. -- */ -- public HessianProxyFactory(ClassLoader loader) -- { -- _loader = loader; -- _resolver = new HessianProxyResolver(this); -- } -- -- /** -- * Sets the user. -- */ -- public void setUser(String user) -- { -- _user = user; -- _basicAuth = null; -- } -- -- /** -- * Sets the password. -- */ -- public void setPassword(String password) -- { -- _password = password; -- _basicAuth = null; -- } -- -- public String getBasicAuth() -- { -- if (_basicAuth != null) -- return _basicAuth; -- -- else if (_user != null && _password != null) -- return "Basic " + base64(_user + ":" + _password); -- -- else -- return null; -- } -- -- /** -- * Sets the connection factory to use when connecting -- * to the Hessian service. -- */ -- public void setConnectionFactory(HessianConnectionFactory factory) -- { -- _connFactory = factory; -- } -- -- /** -- * Returns the connection factory to be used for the HTTP request. -- */ -- public HessianConnectionFactory getConnectionFactory() -- { -- if (_connFactory == null) { -- _connFactory = createHessianConnectionFactory(); -- _connFactory.setHessianProxyFactory(this); -- } -- -- return _connFactory; -- } -- -- /** -- * Sets the debug -- */ -- public void setDebug(boolean isDebug) -- { -- _isDebug = isDebug; -- } -- -- /** -- * Gets the debug -- */ -- public boolean isDebug() -- { -- return _isDebug; -- } -- -- /** -- * Returns true if overloaded methods are allowed (using mangling) -- */ -- public boolean isOverloadEnabled() -- { -- return _isOverloadEnabled; -- } -- -- /** -- * set true if overloaded methods are allowed (using mangling) -- */ -- public void setOverloadEnabled(boolean isOverloadEnabled) -- { -- _isOverloadEnabled = isOverloadEnabled; -- } -- -- /** -- * Set true if should use chunked encoding on the request. -- */ -- public void setChunkedPost(boolean isChunked) -- { -- _isChunkedPost = isChunked; -- } -- -- /** -- * Set true if should use chunked encoding on the request. -- */ -- public boolean isChunkedPost() -- { -- return _isChunkedPost; -- } -- -- /** -- * The socket timeout on requests in milliseconds. -- */ -- public long getReadTimeout() -- { -- return _readTimeout; -- } -- -- /** -- * The socket timeout on requests in milliseconds. -- */ -- public void setReadTimeout(long timeout) -- { -- _readTimeout = timeout; -- } -- -- /** -- * The socket connection timeout in milliseconds. -- */ -- public long getConnectTimeout() -- { -- return _connectTimeout; -- } -- -- /** -- * The socket connect timeout in milliseconds. -- */ -- public void setConnectTimeout(long timeout) -- { -- _connectTimeout = timeout; -- } -- -- /** -- * True if the proxy can read Hessian 2 responses. -- */ -- public void setHessian2Reply(boolean isHessian2) -- { -- _isHessian2Reply = isHessian2; -- } -- -- /** -- * True if the proxy should send Hessian 2 requests. -- */ -- public void setHessian2Request(boolean isHessian2) -- { -- _isHessian2Request = isHessian2; -- -- if (isHessian2) -- _isHessian2Reply = true; -- } -- -- /** -- * Returns the remote resolver. -- */ -- public HessianRemoteResolver getRemoteResolver() -- { -- return _resolver; -- } -- -- /** -- * Sets the serializer factory. -- */ -- public void setSerializerFactory(SerializerFactory factory) -- { -- _serializerFactory = factory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- public SerializerFactory getSerializerFactory() -- { -- if (_serializerFactory == null) -- _serializerFactory = new SerializerFactory(_loader); -- -- return _serializerFactory; -- } -- -- protected HessianConnectionFactory createHessianConnectionFactory() -- { -- String className -- = System.getProperty(HessianConnectionFactory.class.getName()); -- -- HessianConnectionFactory factory = null; -- -- try { -- if (className != null) { -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- -- Class cl = Class.forName(className, false, loader); -- -- factory = (HessianConnectionFactory) cl.newInstance(); -- -- return factory; -- } -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- -- return new HessianURLConnectionFactory(); -- } -- /** -- * Creates a new proxy with the specified URL. The API class uses -- * the java.api.class value from _hessian_ -- * -- * @param url the URL where the client object is located. -- * -- * @return a proxy to the object with the specified interface. -- */ -- public Object create(String url) -- throws MalformedURLException, ClassNotFoundException -- { -- HessianMetaInfoAPI metaInfo; -- -- metaInfo = (HessianMetaInfoAPI) create(HessianMetaInfoAPI.class, url); -- -- String apiClassName = -- (String) metaInfo._hessian_getAttribute("java.api.class"); -- -- if (apiClassName == null) -- throw new HessianRuntimeException(url + " has an unknown api."); -- -- Class apiClass = Class.forName(apiClassName, false, _loader); -- -- return create(apiClass, url); -- } -- -- /** -- * Creates a new proxy with the specified URL. The returned object -- * is a proxy with the interface specified by api. -- * -- *

--   * String url = "http://localhost:8080/ejb/hello");
--   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
--   * 
-- * -- * @param api the interface the proxy class needs to implement -- * @param url the URL where the client object is located. -- * -- * @return a proxy to the object with the specified interface. -- */ -- public Object create(Class api, String urlName) -- throws MalformedURLException -- { -- return create(api, urlName, _loader); -- } -- -- /** -- * Creates a new proxy with the specified URL. The returned object -- * is a proxy with the interface specified by api. -- * -- *
--   * String url = "http://localhost:8080/ejb/hello");
--   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
--   * 
-- * -- * @param api the interface the proxy class needs to implement -- * @param url the URL where the client object is located. -- * -- * @return a proxy to the object with the specified interface. -- */ -- public Object create(Class api, String urlName, ClassLoader loader) -- throws MalformedURLException -- { -- URL url = new URL(urlName); -- -- return create(api, url, loader); -- } -- -- /** -- * Creates a new proxy with the specified URL. The returned object -- * is a proxy with the interface specified by api. -- * -- *
--   * String url = "http://localhost:8080/ejb/hello");
--   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
--   * 
-- * -- * @param api the interface the proxy class needs to implement -- * @param url the URL where the client object is located. -- * -- * @return a proxy to the object with the specified interface. -- */ -- public Object create(Class api, URL url, ClassLoader loader) -- { -- if (api == null) -- throw new NullPointerException("api must not be null for HessianProxyFactory.create()"); -- InvocationHandler handler = null; -- -- handler = new HessianProxy(url, this, api); -- -- return Proxy.newProxyInstance(loader, -- new Class[] { api, -- HessianRemoteObject.class }, -- handler); -- } -- -- public AbstractHessianInput getHessianInput(InputStream is) -- { -- return getHessian2Input(is); -- } -- -- public AbstractHessianInput getHessian1Input(InputStream is) -- { -- AbstractHessianInput in; -- -- if (_isDebug) -- is = new HessianDebugInputStream(is, new PrintWriter(System.out)); -- -- in = new HessianInput(is); -- -- in.setRemoteResolver(getRemoteResolver()); -- -- in.setSerializerFactory(getSerializerFactory()); -- -- return in; -- } -- -- public AbstractHessianInput getHessian2Input(InputStream is) -- { -- AbstractHessianInput in; -- -- if (_isDebug) -- is = new HessianDebugInputStream(is, new PrintWriter(System.out)); -- -- in = new Hessian2Input(is); -- -- in.setRemoteResolver(getRemoteResolver()); -- -- in.setSerializerFactory(getSerializerFactory()); -- -- return in; -- } -- -- public AbstractHessianOutput getHessianOutput(OutputStream os) -- { -- AbstractHessianOutput out; -- -- if (_isHessian2Request) -- out = new Hessian2Output(os); -- else { -- HessianOutput out1 = new HessianOutput(os); -- out = out1; -- -- if (_isHessian2Reply) -- out1.setVersion(2); -- } -- -- out.setSerializerFactory(getSerializerFactory()); -- -- return out; -- } -- -- /** -- * JNDI object factory so the proxy can be used as a resource. -- */ -- public Object getObjectInstance(Object obj, Name name, -- Context nameCtx, Hashtable environment) -- throws Exception -- { -- Reference ref = (Reference) obj; -- -- String api = null; -- String url = null; -- -- for (int i = 0; i < ref.size(); i++) { -- RefAddr addr = ref.get(i); -- -- String type = addr.getType(); -- String value = (String) addr.getContent(); -- -- if (type.equals("type")) -- api = value; -- else if (type.equals("url")) -- url = value; -- else if (type.equals("user")) -- setUser(value); -- else if (type.equals("password")) -- setPassword(value); -- } -- -- if (url == null) -- throw new NamingException("`url' must be configured for HessianProxyFactory."); -- // XXX: could use meta protocol to grab this -- if (api == null) -- throw new NamingException("`type' must be configured for HessianProxyFactory."); -- -- Class apiClass = Class.forName(api, false, _loader); -- -- return create(apiClass, url); -- } -- -- /** -- * Creates the Base64 value. -- */ -- private String base64(String value) -- { -- StringBuffer cb = new StringBuffer(); -- -- int i = 0; -- for (i = 0; i + 2 < value.length(); i += 3) { -- long chunk = (int) value.charAt(i); -- chunk = (chunk << 8) + (int) value.charAt(i + 1); -- chunk = (chunk << 8) + (int) value.charAt(i + 2); -- -- cb.append(encode(chunk >> 18)); -- cb.append(encode(chunk >> 12)); -- cb.append(encode(chunk >> 6)); -- cb.append(encode(chunk)); -- } -- -- if (i + 1 < value.length()) { -- long chunk = (int) value.charAt(i); -- chunk = (chunk << 8) + (int) value.charAt(i + 1); -- chunk <<= 8; -- -- cb.append(encode(chunk >> 18)); -- cb.append(encode(chunk >> 12)); -- cb.append(encode(chunk >> 6)); -- cb.append('='); -- } -- else if (i < value.length()) { -- long chunk = (int) value.charAt(i); -- chunk <<= 16; -- -- cb.append(encode(chunk >> 18)); -- cb.append(encode(chunk >> 12)); -- cb.append('='); -- cb.append('='); -- } -- -- return cb.toString(); -- } -- -- public static char encode(long d) -- { -- d &= 0x3f; -- if (d < 26) -- return (char) (d + 'A'); -- else if (d < 52) -- return (char) (d + 'a' - 26); -- else if (d < 62) -- return (char) (d + '0' - 52); -- else if (d == 62) -- return '+'; -- else -- return '/'; -- } --} -- -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.PrintWriter; -+import java.lang.reflect.InvocationHandler; -+import java.lang.reflect.Proxy; -+import java.net.MalformedURLException; -+import java.net.URL; -+import java.util.Hashtable; -+import java.util.logging.Logger; -+ -+import javax.naming.Context; -+import javax.naming.Name; -+import javax.naming.NamingException; -+import javax.naming.RefAddr; -+import javax.naming.Reference; -+import javax.naming.spi.ObjectFactory; -+ -+import com.caucho.hessian.io.AbstractHessianInput; -+import com.caucho.hessian.io.AbstractHessianOutput; -+import com.caucho.hessian.io.Hessian2Input; -+import com.caucho.hessian.io.Hessian2Output; -+import com.caucho.hessian.io.HessianDebugInputStream; -+import com.caucho.hessian.io.HessianInput; -+import com.caucho.hessian.io.HessianOutput; -+import com.caucho.hessian.io.HessianRemoteObject; -+import com.caucho.hessian.io.HessianRemoteResolver; -+import com.caucho.hessian.io.SerializerFactory; -+import com.caucho.services.client.ServiceProxyFactory; -+ -+/** -+ * Factory for creating Hessian client stubs. The returned stub will -+ * call the remote object for all methods. -+ * -+ *
-+ * String url = "http://localhost:8080/ejb/hello";
-+ * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+ * 
-+ * -+ * After creation, the stub can be like a regular Java class. Because -+ * it makes remote calls, it can throw more exceptions than a Java class. -+ * In particular, it may throw protocol exceptions. -+ * -+ * The factory can also be configured as a JNDI resource. The factory -+ * expects to parameters: "type" and "url", corresponding to the two -+ * arguments to create -+ * -+ * In Resin 3.0, the above example would be configured as: -+ *
-+ * <reference>
-+ *   <jndi-name>hessian/hello</jndi-name>
-+ *   <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
-+ *   <init-param url="http://localhost:8080/ejb/hello"/>
-+ *   <init-param type="test.HelloHome"/>
-+ * </reference>
-+ * 
-+ * -+ * To get the above resource, use JNDI as follows: -+ *
-+ * Context ic = new InitialContext();
-+ * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/hessian/hello");
-+ *
-+ * System.out.println("Hello: " + hello.helloWorld());
-+ * 
-+ * -+ *

Authentication

-+ * -+ *

The proxy can use HTTP basic authentication if the user and the -+ * password are set. -+ */ -+public class HessianProxyFactory implements ServiceProxyFactory, ObjectFactory { -+ protected static Logger log -+ = Logger.getLogger(HessianProxyFactory.class.getName()); -+ -+ private final ClassLoader _loader; -+ -+ private SerializerFactory _serializerFactory; -+ -+ private HessianConnectionFactory _connFactory; -+ -+ private HessianRemoteResolver _resolver; -+ -+ private String _user; -+ private String _password; -+ private String _basicAuth; -+ -+ private boolean _isOverloadEnabled = false; -+ -+ private boolean _isHessian2Reply = true; -+ private boolean _isHessian2Request = false; -+ -+ private boolean _isChunkedPost = true; -+ private boolean _isDebug = false; -+ -+ private long _readTimeout = -1; -+ private long _connectTimeout = -1; -+ -+ /** -+ * Creates the new proxy factory. -+ */ -+ public HessianProxyFactory() -+ { -+ this(Thread.currentThread().getContextClassLoader()); -+ } -+ -+ /** -+ * Creates the new proxy factory. -+ */ -+ public HessianProxyFactory(ClassLoader loader) -+ { -+ _loader = loader; -+ _resolver = new HessianProxyResolver(this); -+ } -+ -+ /** -+ * Sets the user. -+ */ -+ public void setUser(String user) -+ { -+ _user = user; -+ _basicAuth = null; -+ } -+ -+ /** -+ * Sets the password. -+ */ -+ public void setPassword(String password) -+ { -+ _password = password; -+ _basicAuth = null; -+ } -+ -+ public String getBasicAuth() -+ { -+ if (_basicAuth != null) -+ return _basicAuth; -+ -+ else if (_user != null && _password != null) -+ return "Basic " + base64(_user + ":" + _password); -+ -+ else -+ return null; -+ } -+ -+ /** -+ * Sets the connection factory to use when connecting -+ * to the Hessian service. -+ */ -+ public void setConnectionFactory(HessianConnectionFactory factory) -+ { -+ _connFactory = factory; -+ } -+ -+ /** -+ * Returns the connection factory to be used for the HTTP request. -+ */ -+ public HessianConnectionFactory getConnectionFactory() -+ { -+ if (_connFactory == null) { -+ _connFactory = createHessianConnectionFactory(); -+ _connFactory.setHessianProxyFactory(this); -+ } -+ -+ return _connFactory; -+ } -+ -+ /** -+ * Sets the debug -+ */ -+ public void setDebug(boolean isDebug) -+ { -+ _isDebug = isDebug; -+ } -+ -+ /** -+ * Gets the debug -+ */ -+ public boolean isDebug() -+ { -+ return _isDebug; -+ } -+ -+ /** -+ * Returns true if overloaded methods are allowed (using mangling) -+ */ -+ public boolean isOverloadEnabled() -+ { -+ return _isOverloadEnabled; -+ } -+ -+ /** -+ * set true if overloaded methods are allowed (using mangling) -+ */ -+ public void setOverloadEnabled(boolean isOverloadEnabled) -+ { -+ _isOverloadEnabled = isOverloadEnabled; -+ } -+ -+ /** -+ * Set true if should use chunked encoding on the request. -+ */ -+ public void setChunkedPost(boolean isChunked) -+ { -+ _isChunkedPost = isChunked; -+ } -+ -+ /** -+ * Set true if should use chunked encoding on the request. -+ */ -+ public boolean isChunkedPost() -+ { -+ return _isChunkedPost; -+ } -+ -+ /** -+ * The socket timeout on requests in milliseconds. -+ */ -+ public long getReadTimeout() -+ { -+ return _readTimeout; -+ } -+ -+ /** -+ * The socket timeout on requests in milliseconds. -+ */ -+ public void setReadTimeout(long timeout) -+ { -+ _readTimeout = timeout; -+ } -+ -+ /** -+ * The socket connection timeout in milliseconds. -+ */ -+ public long getConnectTimeout() -+ { -+ return _connectTimeout; -+ } -+ -+ /** -+ * The socket connect timeout in milliseconds. -+ */ -+ public void setConnectTimeout(long timeout) -+ { -+ _connectTimeout = timeout; -+ } -+ -+ /** -+ * True if the proxy can read Hessian 2 responses. -+ */ -+ public void setHessian2Reply(boolean isHessian2) -+ { -+ _isHessian2Reply = isHessian2; -+ } -+ -+ /** -+ * True if the proxy should send Hessian 2 requests. -+ */ -+ public void setHessian2Request(boolean isHessian2) -+ { -+ _isHessian2Request = isHessian2; -+ -+ if (isHessian2) -+ _isHessian2Reply = true; -+ } -+ -+ /** -+ * Returns the remote resolver. -+ */ -+ public HessianRemoteResolver getRemoteResolver() -+ { -+ return _resolver; -+ } -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ public SerializerFactory getSerializerFactory() -+ { -+ if (_serializerFactory == null) -+ _serializerFactory = new SerializerFactory(_loader); -+ -+ return _serializerFactory; -+ } -+ -+ protected HessianConnectionFactory createHessianConnectionFactory() -+ { -+ String className -+ = System.getProperty(HessianConnectionFactory.class.getName()); -+ -+ HessianConnectionFactory factory = null; -+ -+ try { -+ if (className != null) { -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ -+ Class cl = Class.forName(className, false, loader); -+ -+ factory = (HessianConnectionFactory) cl.newInstance(); -+ -+ return factory; -+ } -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ -+ return new HessianURLConnectionFactory(); -+ } -+ /** -+ * Creates a new proxy with the specified URL. The API class uses -+ * the java.api.class value from _hessian_ -+ * -+ * @param url the URL where the client object is located. -+ * -+ * @return a proxy to the object with the specified interface. -+ */ -+ public Object create(String url) -+ throws MalformedURLException, ClassNotFoundException -+ { -+ HessianMetaInfoAPI metaInfo; -+ -+ metaInfo = (HessianMetaInfoAPI) create(HessianMetaInfoAPI.class, url); -+ -+ String apiClassName = -+ (String) metaInfo._hessian_getAttribute("java.api.class"); -+ -+ if (apiClassName == null) -+ throw new HessianRuntimeException(url + " has an unknown api."); -+ -+ Class apiClass = Class.forName(apiClassName, false, _loader); -+ -+ return create(apiClass, url); -+ } -+ -+ /** -+ * Creates a new proxy with the specified URL. The returned object -+ * is a proxy with the interface specified by api. -+ * -+ *

-+   * String url = "http://localhost:8080/ejb/hello");
-+   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+   * 
-+ * -+ * @param api the interface the proxy class needs to implement -+ * @param url the URL where the client object is located. -+ * -+ * @return a proxy to the object with the specified interface. -+ */ -+ public Object create(Class api, String urlName) -+ throws MalformedURLException -+ { -+ return create(api, urlName, _loader); -+ } -+ -+ /** -+ * Creates a new proxy with the specified URL. The returned object -+ * is a proxy with the interface specified by api. -+ * -+ *
-+   * String url = "http://localhost:8080/ejb/hello");
-+   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+   * 
-+ * -+ * @param api the interface the proxy class needs to implement -+ * @param url the URL where the client object is located. -+ * -+ * @return a proxy to the object with the specified interface. -+ */ -+ public Object create(Class api, String urlName, ClassLoader loader) -+ throws MalformedURLException -+ { -+ URL url = new URL(urlName); -+ -+ return create(api, url, loader); -+ } -+ -+ /** -+ * Creates a new proxy with the specified URL. The returned object -+ * is a proxy with the interface specified by api. -+ * -+ *
-+   * String url = "http://localhost:8080/ejb/hello");
-+   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+   * 
-+ * -+ * @param api the interface the proxy class needs to implement -+ * @param url the URL where the client object is located. -+ * -+ * @return a proxy to the object with the specified interface. -+ */ -+ public Object create(Class api, URL url, ClassLoader loader) -+ { -+ if (api == null) -+ throw new NullPointerException("api must not be null for HessianProxyFactory.create()"); -+ InvocationHandler handler = null; -+ -+ handler = new HessianProxy(url, this, api); -+ -+ return Proxy.newProxyInstance(loader, -+ new Class[] { api, -+ HessianRemoteObject.class }, -+ handler); -+ } -+ -+ public AbstractHessianInput getHessianInput(InputStream is) -+ { -+ return getHessian2Input(is); -+ } -+ -+ public AbstractHessianInput getHessian1Input(InputStream is) -+ { -+ AbstractHessianInput in; -+ -+ if (_isDebug) -+ is = new HessianDebugInputStream(is, new PrintWriter(System.out)); -+ -+ in = new HessianInput(is); -+ -+ in.setRemoteResolver(getRemoteResolver()); -+ -+ in.setSerializerFactory(getSerializerFactory()); -+ -+ return in; -+ } -+ -+ public AbstractHessianInput getHessian2Input(InputStream is) -+ { -+ AbstractHessianInput in; -+ -+ if (_isDebug) -+ is = new HessianDebugInputStream(is, new PrintWriter(System.out)); -+ -+ in = new Hessian2Input(is); -+ -+ in.setRemoteResolver(getRemoteResolver()); -+ -+ in.setSerializerFactory(getSerializerFactory()); -+ -+ return in; -+ } -+ -+ public AbstractHessianOutput getHessianOutput(OutputStream os) -+ { -+ AbstractHessianOutput out; -+ -+ if (_isHessian2Request) -+ out = new Hessian2Output(os); -+ else { -+ HessianOutput out1 = new HessianOutput(os); -+ out = out1; -+ -+ if (_isHessian2Reply) -+ out1.setVersion(2); -+ } -+ -+ out.setSerializerFactory(getSerializerFactory()); -+ -+ return out; -+ } -+ -+ /** -+ * JNDI object factory so the proxy can be used as a resource. -+ */ -+ public Object getObjectInstance(Object obj, Name name, -+ Context nameCtx, Hashtable environment) -+ throws Exception -+ { -+ Reference ref = (Reference) obj; -+ -+ String api = null; -+ String url = null; -+ -+ for (int i = 0; i < ref.size(); i++) { -+ RefAddr addr = ref.get(i); -+ -+ String type = addr.getType(); -+ String value = (String) addr.getContent(); -+ -+ if (type.equals("type")) -+ api = value; -+ else if (type.equals("url")) -+ url = value; -+ else if (type.equals("user")) -+ setUser(value); -+ else if (type.equals("password")) -+ setPassword(value); -+ } -+ -+ if (url == null) -+ throw new NamingException("`url' must be configured for HessianProxyFactory."); -+ // XXX: could use meta protocol to grab this -+ if (api == null) -+ throw new NamingException("`type' must be configured for HessianProxyFactory."); -+ -+ Class apiClass = Class.forName(api, false, _loader); -+ -+ return create(apiClass, url); -+ } -+ -+ /** -+ * Creates the Base64 value. -+ */ -+ private String base64(String value) -+ { -+ StringBuffer cb = new StringBuffer(); -+ -+ int i = 0; -+ for (i = 0; i + 2 < value.length(); i += 3) { -+ long chunk = (int) value.charAt(i); -+ chunk = (chunk << 8) + (int) value.charAt(i + 1); -+ chunk = (chunk << 8) + (int) value.charAt(i + 2); -+ -+ cb.append(encode(chunk >> 18)); -+ cb.append(encode(chunk >> 12)); -+ cb.append(encode(chunk >> 6)); -+ cb.append(encode(chunk)); -+ } -+ -+ if (i + 1 < value.length()) { -+ long chunk = (int) value.charAt(i); -+ chunk = (chunk << 8) + (int) value.charAt(i + 1); -+ chunk <<= 8; -+ -+ cb.append(encode(chunk >> 18)); -+ cb.append(encode(chunk >> 12)); -+ cb.append(encode(chunk >> 6)); -+ cb.append('='); -+ } -+ else if (i < value.length()) { -+ long chunk = (int) value.charAt(i); -+ chunk <<= 16; -+ -+ cb.append(encode(chunk >> 18)); -+ cb.append(encode(chunk >> 12)); -+ cb.append('='); -+ cb.append('='); -+ } -+ -+ return cb.toString(); -+ } -+ -+ public static char encode(long d) -+ { -+ d &= 0x3f; -+ if (d < 26) -+ return (char) (d + 'A'); -+ else if (d < 52) -+ return (char) (d + 'a' - 26); -+ else if (d < 62) -+ return (char) (d + '0' - 52); -+ else if (d == 62) -+ return '+'; -+ else -+ return '/'; -+ } -+} -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyResolver.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyResolver.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianProxyResolver.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianProxyResolver.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,85 +1,85 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import com.caucho.hessian.io.HessianRemoteResolver; -- --import java.io.IOException; -- --/** -- * Looks up remote objects in the proxy. -- */ --public class HessianProxyResolver implements HessianRemoteResolver { -- private HessianProxyFactory _factory; -- -- /** -- * Creates an uninitialized Hessian remote resolver. -- */ -- public HessianProxyResolver(HessianProxyFactory factory) -- { -- _factory = factory; -- } -- -- /** -- * Looks up a proxy object. -- */ -- public Object lookup(String type, String url) -- throws IOException -- { -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- -- try { -- Class api = Class.forName(type, false, loader); -- -- return _factory.create(api, url); -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import com.caucho.hessian.io.HessianRemoteResolver; -+ -+import java.io.IOException; -+ -+/** -+ * Looks up remote objects in the proxy. -+ */ -+public class HessianProxyResolver implements HessianRemoteResolver { -+ private HessianProxyFactory _factory; -+ -+ /** -+ * Creates an uninitialized Hessian remote resolver. -+ */ -+ public HessianProxyResolver(HessianProxyFactory factory) -+ { -+ _factory = factory; -+ } -+ -+ /** -+ * Looks up a proxy object. -+ */ -+ public Object lookup(String type, String url) -+ throws IOException -+ { -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ -+ try { -+ Class api = Class.forName(type, false, loader); -+ -+ return _factory.create(api, url); -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianRuntimeException.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianRuntimeException.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianRuntimeException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianRuntimeException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,107 +1,107 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --/** -- * Wrapper for protocol exceptions thrown in the proxy. -- */ --public class HessianRuntimeException extends RuntimeException { -- private Throwable rootCause; -- -- /** -- * Zero-arg constructor. -- */ -- public HessianRuntimeException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public HessianRuntimeException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public HessianRuntimeException(String message, Throwable rootCause) -- { -- super(message); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Create the exception. -- */ -- public HessianRuntimeException(Throwable rootCause) -- { -- super(String.valueOf(rootCause)); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getRootCause() -- { -- return this.rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getCause() -- { -- return getRootCause(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+/** -+ * Wrapper for protocol exceptions thrown in the proxy. -+ */ -+public class HessianRuntimeException extends RuntimeException { -+ private Throwable rootCause; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public HessianRuntimeException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianRuntimeException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianRuntimeException(String message, Throwable rootCause) -+ { -+ super(message); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianRuntimeException(Throwable rootCause) -+ { -+ super(String.valueOf(rootCause)); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getRootCause() -+ { -+ return this.rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getCause() -+ { -+ return getRootCause(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnection.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnection.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnection.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnection.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,219 +1,219 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import java.net.URL; --import java.net.URLConnection; --import java.net.HttpURLConnection; --import java.util.zip.Inflater; --import java.util.zip.InflaterInputStream; -- --import java.io.InputStream; --import java.io.OutputStream; --import java.io.IOException; --import java.io.FileNotFoundException; -- --/** -- * Internal connection to a server. The default connection is based on -- * java.net -- */ --public class HessianURLConnection extends AbstractHessianConnection { -- private URL _url; -- private URLConnection _conn; -- -- private int _statusCode; -- private String _statusMessage; -- -- private InputStream _inputStream; -- private InputStream _errorStream; -- -- HessianURLConnection(URL url, URLConnection conn) -- { -- _url = url; -- _conn = conn; -- } -- -- /** -- * Adds a HTTP header. -- */ -- @Override -- public void addHeader(String key, String value) -- { -- _conn.setRequestProperty(key, value); -- } -- -- /** -- * Returns the output stream for the request. -- */ -- public OutputStream getOutputStream() -- throws IOException -- { -- return _conn.getOutputStream(); -- } -- -- /** -- * Sends the request -- */ -- public void sendRequest() -- throws IOException -- { -- if (_conn instanceof HttpURLConnection) { -- HttpURLConnection httpConn = (HttpURLConnection) _conn; -- -- _statusCode = 500; -- -- try { -- _statusCode = httpConn.getResponseCode(); -- } catch (Exception e) { -- } -- -- parseResponseHeaders(httpConn); -- -- InputStream is = null; -- -- if (_statusCode != 200) { -- StringBuffer sb = new StringBuffer(); -- int ch; -- -- try { -- is = httpConn.getInputStream(); -- -- if (is != null) { -- while ((ch = is.read()) >= 0) -- sb.append((char) ch); -- -- is.close(); -- } -- -- is = httpConn.getErrorStream(); -- if (is != null) { -- while ((ch = is.read()) >= 0) -- sb.append((char) ch); -- } -- -- _statusMessage = sb.toString(); -- } catch (FileNotFoundException e) { -- throw new HessianConnectionException("HessianProxy cannot connect to '" + _url, e); -- } catch (IOException e) { -- if (is == null) -- throw new HessianConnectionException(_statusCode + ": " + e, e); -- else -- throw new HessianConnectionException(_statusCode + ": " + sb, e); -- } -- -- if (is != null) -- is.close(); -- -- throw new HessianConnectionException(_statusCode + ": " + sb.toString()); -- } -- } -- } -- -- protected void parseResponseHeaders(HttpURLConnection conn) -- throws IOException -- { -- } -- -- /** -- * Returns the status code. -- */ -- public int getStatusCode() -- { -- return _statusCode; -- } -- -- /** -- * Returns the status string. -- */ -- public String getStatusMessage() -- { -- return _statusMessage; -- } -- -- /** -- * Returns the InputStream to the result -- */ -- @Override -- public InputStream getInputStream() -- throws IOException -- { -- return _conn.getInputStream(); -- } -- -- @Override -- public String getContentEncoding() -- { -- return _conn.getContentEncoding(); -- } -- -- /** -- * Close/free the connection -- */ -- @Override -- public void close() -- { -- _inputStream = null; -- } -- -- /** -- * Disconnect the connection -- */ -- @Override -- public void destroy() -- { -- close(); -- -- URLConnection conn = _conn; -- _conn = null; -- -- if (conn instanceof HttpURLConnection) -- ((HttpURLConnection) conn).disconnect(); -- } --} -- -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import java.net.URL; -+import java.net.URLConnection; -+import java.net.HttpURLConnection; -+import java.util.zip.Inflater; -+import java.util.zip.InflaterInputStream; -+ -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.IOException; -+import java.io.FileNotFoundException; -+ -+/** -+ * Internal connection to a server. The default connection is based on -+ * java.net -+ */ -+public class HessianURLConnection extends AbstractHessianConnection { -+ private URL _url; -+ private URLConnection _conn; -+ -+ private int _statusCode; -+ private String _statusMessage; -+ -+ private InputStream _inputStream; -+ private InputStream _errorStream; -+ -+ HessianURLConnection(URL url, URLConnection conn) -+ { -+ _url = url; -+ _conn = conn; -+ } -+ -+ /** -+ * Adds a HTTP header. -+ */ -+ @Override -+ public void addHeader(String key, String value) -+ { -+ _conn.setRequestProperty(key, value); -+ } -+ -+ /** -+ * Returns the output stream for the request. -+ */ -+ public OutputStream getOutputStream() -+ throws IOException -+ { -+ return _conn.getOutputStream(); -+ } -+ -+ /** -+ * Sends the request -+ */ -+ public void sendRequest() -+ throws IOException -+ { -+ if (_conn instanceof HttpURLConnection) { -+ HttpURLConnection httpConn = (HttpURLConnection) _conn; -+ -+ _statusCode = 500; -+ -+ try { -+ _statusCode = httpConn.getResponseCode(); -+ } catch (Exception e) { -+ } -+ -+ parseResponseHeaders(httpConn); -+ -+ InputStream is = null; -+ -+ if (_statusCode != 200) { -+ StringBuffer sb = new StringBuffer(); -+ int ch; -+ -+ try { -+ is = httpConn.getInputStream(); -+ -+ if (is != null) { -+ while ((ch = is.read()) >= 0) -+ sb.append((char) ch); -+ -+ is.close(); -+ } -+ -+ is = httpConn.getErrorStream(); -+ if (is != null) { -+ while ((ch = is.read()) >= 0) -+ sb.append((char) ch); -+ } -+ -+ _statusMessage = sb.toString(); -+ } catch (FileNotFoundException e) { -+ throw new HessianConnectionException("HessianProxy cannot connect to '" + _url, e); -+ } catch (IOException e) { -+ if (is == null) -+ throw new HessianConnectionException(_statusCode + ": " + e, e); -+ else -+ throw new HessianConnectionException(_statusCode + ": " + sb, e); -+ } -+ -+ if (is != null) -+ is.close(); -+ -+ throw new HessianConnectionException(_statusCode + ": " + sb.toString()); -+ } -+ } -+ } -+ -+ protected void parseResponseHeaders(HttpURLConnection conn) -+ throws IOException -+ { -+ } -+ -+ /** -+ * Returns the status code. -+ */ -+ public int getStatusCode() -+ { -+ return _statusCode; -+ } -+ -+ /** -+ * Returns the status string. -+ */ -+ public String getStatusMessage() -+ { -+ return _statusMessage; -+ } -+ -+ /** -+ * Returns the InputStream to the result -+ */ -+ @Override -+ public InputStream getInputStream() -+ throws IOException -+ { -+ return _conn.getInputStream(); -+ } -+ -+ @Override -+ public String getContentEncoding() -+ { -+ return _conn.getContentEncoding(); -+ } -+ -+ /** -+ * Close/free the connection -+ */ -+ @Override -+ public void close() -+ { -+ _inputStream = null; -+ } -+ -+ /** -+ * Disconnect the connection -+ */ -+ @Override -+ public void destroy() -+ { -+ close(); -+ -+ URLConnection conn = _conn; -+ _conn = null; -+ -+ if (conn instanceof HttpURLConnection) -+ ((HttpURLConnection) conn).disconnect(); -+ } -+} -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnectionFactory.java hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnectionFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/client/HessianURLConnectionFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/HessianURLConnectionFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,120 +1,120 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.client; -- --import java.net.URL; --import java.net.URLConnection; --import java.net.HttpURLConnection; -- --import java.io.IOException; -- --import java.util.logging.Logger; --import java.util.logging.Level; -- --/** -- * Internal factory for creating connections to the server. The default -- * factory is java.net -- */ --public class HessianURLConnectionFactory implements HessianConnectionFactory { -- private static final Logger log -- = Logger.getLogger(HessianURLConnectionFactory.class.getName()); -- -- private HessianProxyFactory _proxyFactory; -- -- public void setHessianProxyFactory(HessianProxyFactory factory) -- { -- _proxyFactory = factory; -- } -- -- /** -- * Opens a new or recycled connection to the HTTP server. -- */ -- public HessianConnection open(URL url) -- throws IOException -- { -- if (log.isLoggable(Level.FINER)) -- log.finer(this + " open(" + url + ")"); -- -- URLConnection conn = url.openConnection(); -- -- // HttpURLConnection httpConn = (HttpURLConnection) conn; -- // httpConn.setRequestMethod("POST"); -- // conn.setDoInput(true); -- -- long connectTimeout = _proxyFactory.getConnectTimeout(); -- -- if (connectTimeout >= 0) -- conn.setConnectTimeout((int) connectTimeout); -- -- conn.setDoOutput(true); -- -- long readTimeout = _proxyFactory.getReadTimeout(); -- -- if (readTimeout > 0) { -- try { -- conn.setReadTimeout((int) readTimeout); -- } catch (Throwable e) { -- } -- } -- -- /* -- // Used chunked mode when available, i.e. JDK 1.5. -- if (_proxyFactory.isChunkedPost() && conn instanceof HttpURLConnection) { -- try { -- HttpURLConnection httpConn = (HttpURLConnection) conn; -- -- httpConn.setChunkedStreamingMode(8 * 1024); -- } catch (Throwable e) { -- } -- } -- */ -- -- return new HessianURLConnection(url, conn); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.client; -+ -+import java.net.URL; -+import java.net.URLConnection; -+import java.net.HttpURLConnection; -+ -+import java.io.IOException; -+ -+import java.util.logging.Logger; -+import java.util.logging.Level; -+ -+/** -+ * Internal factory for creating connections to the server. The default -+ * factory is java.net -+ */ -+public class HessianURLConnectionFactory implements HessianConnectionFactory { -+ private static final Logger log -+ = Logger.getLogger(HessianURLConnectionFactory.class.getName()); -+ -+ private HessianProxyFactory _proxyFactory; -+ -+ public void setHessianProxyFactory(HessianProxyFactory factory) -+ { -+ _proxyFactory = factory; -+ } -+ -+ /** -+ * Opens a new or recycled connection to the HTTP server. -+ */ -+ public HessianConnection open(URL url) -+ throws IOException -+ { -+ if (log.isLoggable(Level.FINER)) -+ log.finer(this + " open(" + url + ")"); -+ -+ URLConnection conn = url.openConnection(); -+ -+ // HttpURLConnection httpConn = (HttpURLConnection) conn; -+ // httpConn.setRequestMethod("POST"); -+ // conn.setDoInput(true); -+ -+ long connectTimeout = _proxyFactory.getConnectTimeout(); -+ -+ if (connectTimeout >= 0) -+ conn.setConnectTimeout((int) connectTimeout); -+ -+ conn.setDoOutput(true); -+ -+ long readTimeout = _proxyFactory.getReadTimeout(); -+ -+ if (readTimeout > 0) { -+ try { -+ conn.setReadTimeout((int) readTimeout); -+ } catch (Throwable e) { -+ } -+ } -+ -+ /* -+ // Used chunked mode when available, i.e. JDK 1.5. -+ if (_proxyFactory.isChunkedPost() && conn instanceof HttpURLConnection) { -+ try { -+ HttpURLConnection httpConn = (HttpURLConnection) conn; -+ -+ httpConn.setChunkedStreamingMode(8 * 1024); -+ } catch (Throwable e) { -+ } -+ } -+ */ -+ -+ return new HessianURLConnection(url, conn); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/client/package.html hessian-4.0.65-fix/com/caucho/hessian/client/package.html ---- hessian-4.0.65-src/com/caucho/hessian/client/package.html 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/client/package.html 2023-08-15 18:39:22.000000000 +0800 -@@ -1,59 +1,59 @@ -- -- --Portable client code for using Hessian services. Since this package is --independent of all Resin code, its classes can be copied to a --non-Resin client jar. -- --

RPC Proxy Clients - HessianProxyFactory

-- --Most application clients will use HessianProxyFactory to --create stub objects. The stub objects can be called with normal --Java calls. Because the objects are remote, the client application needs --to be able to deal with IOException caused by an unavailable server or --a protocol error. -- --
--import com.caucho.hessian.client.HessianProxyFactory;
--
--...
--
--URL url = new URL("http://localhost:8080/ejb/hello");
--HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
--
--System.out.println("hello: " + hello.hello());
--
-- --

Serialization

-- --Since the Hessian protocol serializes Java objects to XML, the --HessianSerializerOutput and HessianSerializerInput --can be used for serialization. -- --

Serialization

--
--OutputStream os = new FileOutputStream("test.xml");
--HessianOutput out = new HessianSerializerOutput(os);
--
--out.writeObject(obj);
--os.close();
--
-- --

Deserialization

--
--InputStream is = new FileInputStream("test.xml");
--HessianInput in = new HessianSerializerInput(in);
--
--Object obj = in.readObject();
--
--is.close();
--
-- --

MicroHessianInput and MicroHessianOutput

-- --These two classes only require classes from Java MicroEdition. So they --can be extracted separately into a hessian-micro.jar. Because of this --restriction and their small size, these two classes --are ideal for limited size devices like mobile phones and PDAs. -- -- -+ -+ -+Portable client code for using Hessian services. Since this package is -+independent of all Resin code, its classes can be copied to a -+non-Resin client jar. -+ -+

RPC Proxy Clients - HessianProxyFactory

-+ -+Most application clients will use HessianProxyFactory to -+create stub objects. The stub objects can be called with normal -+Java calls. Because the objects are remote, the client application needs -+to be able to deal with IOException caused by an unavailable server or -+a protocol error. -+ -+
-+import com.caucho.hessian.client.HessianProxyFactory;
-+
-+...
-+
-+URL url = new URL("http://localhost:8080/ejb/hello");
-+HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+
-+System.out.println("hello: " + hello.hello());
-+
-+ -+

Serialization

-+ -+Since the Hessian protocol serializes Java objects to XML, the -+HessianSerializerOutput and HessianSerializerInput -+can be used for serialization. -+ -+

Serialization

-+
-+OutputStream os = new FileOutputStream("test.xml");
-+HessianOutput out = new HessianSerializerOutput(os);
-+
-+out.writeObject(obj);
-+os.close();
-+
-+ -+

Deserialization

-+
-+InputStream is = new FileInputStream("test.xml");
-+HessianInput in = new HessianSerializerInput(in);
-+
-+Object obj = in.readObject();
-+
-+is.close();
-+
-+ -+

MicroHessianInput and MicroHessianOutput

-+ -+These two classes only require classes from Java MicroEdition. So they -+can be extracted separately into a hessian-micro.jar. Because of this -+restriction and their small size, these two classes -+are ideal for limited size devices like mobile phones and PDAs. -+ -+ - -\ No newline at end of file -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,169 +1,169 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Deserializing an object. -- */ --public class AbstractDeserializer implements Deserializer { -- public static final NullDeserializer NULL = new NullDeserializer(); -- -- public Class getType() -- { -- return Object.class; -- } -- -- public boolean isReadResolve() -- { -- return false; -- } -- -- public Object readObject(AbstractHessianInput in) -- throws IOException -- { -- Object obj = in.readObject(); -- -- String className = getClass().getName(); -- -- if (obj != null) -- throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); -- else -- throw error(className + ": unexpected null value"); -- } -- -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- throw new UnsupportedOperationException(String.valueOf(this)); -- } -- -- public Object readLengthList(AbstractHessianInput in, int length) -- throws IOException -- { -- throw new UnsupportedOperationException(String.valueOf(this)); -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- Object obj = in.readObject(); -- -- String className = getClass().getName(); -- -- if (obj != null) -- throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); -- else -- throw error(className + ": unexpected null value"); -- } -- -- /** -- * Creates the field array for a class. The default -- * implementation returns a String[] array. -- * -- * @param len number of items in the array -- * @return the new empty array -- */ -- public Object []createFields(int len) -- { -- return new String[len]; -- } -- -- /** -- * Creates a field value class. The default -- * implementation returns the String. -- * -- * @param len number of items in the array -- * @return the new empty array -- */ -- public Object createField(String name) -- { -- return name; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, -- String []fieldNames) -- throws IOException -- { -- return readObject(in, (Object []) fieldNames); -- } -- -- /** -- * Reads an object instance from the input stream -- */ -- @Override -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException -- { -- throw new UnsupportedOperationException(toString()); -- } -- -- protected HessianProtocolException error(String msg) -- { -- return new HessianProtocolException(msg); -- } -- -- protected String codeName(int ch) -- { -- if (ch < 0) -- return "end of file"; -- else -- return "0x" + Integer.toHexString(ch & 0xff); -- } -- -- /** -- * The NullDeserializer exists as a marker for the factory classes so -- * they save a null result. -- */ -- static final class NullDeserializer extends AbstractDeserializer { -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Deserializing an object. -+ */ -+public class AbstractDeserializer implements Deserializer { -+ public static final NullDeserializer NULL = new NullDeserializer(); -+ -+ public Class getType() -+ { -+ return Object.class; -+ } -+ -+ public boolean isReadResolve() -+ { -+ return false; -+ } -+ -+ public Object readObject(AbstractHessianInput in) -+ throws IOException -+ { -+ Object obj = in.readObject(); -+ -+ String className = getClass().getName(); -+ -+ if (obj != null) -+ throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); -+ else -+ throw error(className + ": unexpected null value"); -+ } -+ -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(String.valueOf(this)); -+ } -+ -+ public Object readLengthList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(String.valueOf(this)); -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ Object obj = in.readObject(); -+ -+ String className = getClass().getName(); -+ -+ if (obj != null) -+ throw error(className + ": unexpected object " + obj.getClass().getName() + " (" + obj + ")"); -+ else -+ throw error(className + ": unexpected null value"); -+ } -+ -+ /** -+ * Creates the field array for a class. The default -+ * implementation returns a String[] array. -+ * -+ * @param len number of items in the array -+ * @return the new empty array -+ */ -+ public Object []createFields(int len) -+ { -+ return new String[len]; -+ } -+ -+ /** -+ * Creates a field value class. The default -+ * implementation returns the String. -+ * -+ * @param len number of items in the array -+ * @return the new empty array -+ */ -+ public Object createField(String name) -+ { -+ return name; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ String []fieldNames) -+ throws IOException -+ { -+ return readObject(in, (Object []) fieldNames); -+ } -+ -+ /** -+ * Reads an object instance from the input stream -+ */ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(toString()); -+ } -+ -+ protected HessianProtocolException error(String msg) -+ { -+ return new HessianProtocolException(msg); -+ } -+ -+ protected String codeName(int ch) -+ { -+ if (ch < 0) -+ return "end of file"; -+ else -+ return "0x" + Integer.toHexString(ch & 0xff); -+ } -+ -+ /** -+ * The NullDeserializer exists as a marker for the factory classes so -+ * they save a null result. -+ */ -+ static final class NullDeserializer extends AbstractDeserializer { -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializerWrapper.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializerWrapper.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractDeserializerWrapper.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractDeserializerWrapper.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,143 +1,143 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Deserializing an object. -- */ --abstract public class AbstractDeserializerWrapper implements Deserializer { -- abstract protected Deserializer getDelegate(); -- -- @Override -- public Class getType() -- { -- return getDelegate().getType(); -- } -- -- @Override -- public boolean isReadResolve() -- { -- return getDelegate().isReadResolve(); -- } -- -- @Override -- public Object readObject(AbstractHessianInput in) -- throws IOException -- { -- return getDelegate().readObject(in); -- } -- -- @Override -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- return getDelegate().readList(in, length); -- } -- -- @Override -- public Object readLengthList(AbstractHessianInput in, int length) -- throws IOException -- { -- return getDelegate().readLengthList(in, length); -- } -- -- @Override -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- return getDelegate().readMap(in); -- } -- -- /** -- * Creates the field array for a class. The default -- * implementation returns a String[] array. -- * -- * @param len number of items in the array -- * @return the new empty array -- */ -- @Override -- public Object []createFields(int len) -- { -- return getDelegate().createFields(len); -- } -- -- /** -- * Creates a field value class. The default -- * implementation returns the String. -- * -- * @param len number of items in the array -- * @return the new empty array -- */ -- @Override -- public Object createField(String name) -- { -- return getDelegate().createField(name); -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, -- String []fieldNames) -- throws IOException -- { -- return getDelegate().readObject(in, fieldNames); -- } -- -- /** -- * Reads an object instance from the input stream -- */ -- @Override -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException -- { -- return getDelegate().readObject(in, fields); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Deserializing an object. -+ */ -+abstract public class AbstractDeserializerWrapper implements Deserializer { -+ abstract protected Deserializer getDelegate(); -+ -+ @Override -+ public Class getType() -+ { -+ return getDelegate().getType(); -+ } -+ -+ @Override -+ public boolean isReadResolve() -+ { -+ return getDelegate().isReadResolve(); -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in) -+ throws IOException -+ { -+ return getDelegate().readObject(in); -+ } -+ -+ @Override -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ return getDelegate().readList(in, length); -+ } -+ -+ @Override -+ public Object readLengthList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ return getDelegate().readLengthList(in, length); -+ } -+ -+ @Override -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ return getDelegate().readMap(in); -+ } -+ -+ /** -+ * Creates the field array for a class. The default -+ * implementation returns a String[] array. -+ * -+ * @param len number of items in the array -+ * @return the new empty array -+ */ -+ @Override -+ public Object []createFields(int len) -+ { -+ return getDelegate().createFields(len); -+ } -+ -+ /** -+ * Creates a field value class. The default -+ * implementation returns the String. -+ * -+ * @param len number of items in the array -+ * @return the new empty array -+ */ -+ @Override -+ public Object createField(String name) -+ { -+ return getDelegate().createField(name); -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ String []fieldNames) -+ throws IOException -+ { -+ return getDelegate().readObject(in, fieldNames); -+ } -+ -+ /** -+ * Reads an object instance from the input stream -+ */ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ return getDelegate().readObject(in, fields); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianInput.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianInput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,487 +1,487 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; --import java.io.Reader; -- --/** -- * Abstract base class for Hessian requests. Hessian users should only -- * need to use the methods in this class. -- * -- *
-- * AbstractHessianInput in = ...; // get input
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --abstract public class AbstractHessianInput { -- private HessianRemoteResolver resolver; -- private byte []_buffer; -- -- /** -- * Initialize the Hessian stream with the underlying input stream. -- */ -- public void init(InputStream is) -- { -- } -- -- /** -- * Returns the call's method -- */ -- abstract public String getMethod(); -- -- /** -- * Sets the resolver used to lookup remote objects. -- */ -- public void setRemoteResolver(HessianRemoteResolver resolver) -- { -- this.resolver = resolver; -- } -- -- /** -- * Sets the resolver used to lookup remote objects. -- */ -- public HessianRemoteResolver getRemoteResolver() -- { -- return resolver; -- } -- -- /** -- * Sets the serializer factory. -- */ -- public void setSerializerFactory(SerializerFactory ser) -- { -- } -- -- /** -- * Reads the call -- * -- *
--   * c major minor
--   * 
-- */ -- abstract public int readCall() -- throws IOException; -- -- /** -- * For backward compatibility with HessianSkeleton -- */ -- public void skipOptionalCall() -- throws IOException -- { -- } -- -- /** -- * Reads a header, returning null if there are no headers. -- * -- *
--   * H b16 b8 value
--   * 
-- */ -- abstract public String readHeader() -- throws IOException; -- -- /** -- * Starts reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * m b16 b8 method
--   * 
-- */ -- abstract public String readMethod() -- throws IOException; -- -- /** -- * Reads the number of method arguments -- * -- * @return -1 for a variable length (hessian 1.0) -- */ -- public int readMethodArgLength() -- throws IOException -- { -- return -1; -- } -- -- /** -- * Starts reading the call, including the headers. -- * -- *

The call expects the following protocol data -- * -- *

--   * c major minor
--   * m b16 b8 method
--   * 
-- */ -- abstract public void startCall() -- throws IOException; -- -- /** -- * Completes reading the call -- * -- *

The call expects the following protocol data -- * -- *

--   * Z
--   * 
-- */ -- abstract public void completeCall() -- throws IOException; -- -- /** -- * Reads a reply as an object. -- * If the reply has a fault, throws the exception. -- */ -- abstract public Object readReply(Class expectedClass) -- throws Throwable; -- -- /** -- * Starts reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * r
--   * v
--   * 
-- */ -- abstract public void startReply() -- throws Throwable; -- -- /** -- * Starts reading the body of the reply, i.e. after the 'r' has been -- * parsed. -- */ -- public void startReplyBody() -- throws Throwable -- { -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- abstract public void completeReply() -- throws IOException; -- -- /** -- * Reads a boolean -- * -- *
--   * T
--   * F
--   * 
-- */ -- abstract public boolean readBoolean() -- throws IOException; -- -- /** -- * Reads a null -- * -- *
--   * N
--   * 
-- */ -- abstract public void readNull() -- throws IOException; -- -- /** -- * Reads an integer -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- */ -- abstract public int readInt() -- throws IOException; -- -- /** -- * Reads a long -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- abstract public long readLong() -- throws IOException; -- -- /** -- * Reads a double. -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- abstract public double readDouble() -- throws IOException; -- -- /** -- * Reads a date. -- * -- *
--   * T b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- abstract public long readUTCDate() -- throws IOException; -- -- /** -- * Reads a string encoded in UTF-8 -- * -- *
--   * s b16 b8 non-final string chunk
--   * S b16 b8 final string chunk
--   * 
-- */ -- abstract public String readString() -- throws IOException; -- -- /** -- * Reads an XML node encoded in UTF-8 -- * -- *
--   * x b16 b8 non-final xml chunk
--   * X b16 b8 final xml chunk
--   * 
-- */ -- public org.w3c.dom.Node readNode() -- throws IOException -- { -- throw new UnsupportedOperationException(getClass().getSimpleName()); -- } -- -- /** -- * Starts reading a string. All the characters must be read before -- * calling the next method. The actual characters will be read with -- * the reader's read() or read(char [], int, int). -- * -- *
--   * s b16 b8 non-final string chunk
--   * S b16 b8 final string chunk
--   * 
-- */ -- abstract public Reader getReader() -- throws IOException; -- -- /** -- * Starts reading a byte array using an input stream. All the bytes -- * must be read before calling the following method. -- * -- *
--   * b b16 b8 non-final binary chunk
--   * B b16 b8 final binary chunk
--   * 
-- */ -- abstract public InputStream readInputStream() -- throws IOException; -- -- /** -- * Reads data to an output stream. -- * -- *
--   * b b16 b8 non-final binary chunk
--   * B b16 b8 final binary chunk
--   * 
-- */ -- public boolean readToOutputStream(OutputStream os) -- throws IOException -- { -- InputStream is = readInputStream(); -- -- if (is == null) -- return false; -- -- if (_buffer == null) -- _buffer = new byte[256]; -- -- try { -- int len; -- -- while ((len = is.read(_buffer, 0, _buffer.length)) > 0) { -- os.write(_buffer, 0, len); -- } -- -- return true; -- } finally { -- is.close(); -- } -- } -- -- -- -- /** -- * Reads a byte array. -- * -- *
--   * b b16 b8 non-final binary chunk
--   * B b16 b8 final binary chunk
--   * 
-- */ -- abstract public byte []readBytes() -- throws IOException; -- -- /** -- * Reads an arbitrary object from the input stream. -- * -- * @param expectedClass the expected class if the protocol doesn't supply it. -- */ -- abstract public Object readObject(Class expectedClass) -- throws IOException; -- -- /** -- * Reads an arbitrary object from the input stream. -- */ -- abstract public Object readObject() -- throws IOException; -- -- /** -- * Reads a remote object reference to the stream. The type is the -- * type of the remote interface. -- * -- *
--   * 'r' 't' b16 b8 type url
--   * 
-- */ -- abstract public Object readRemote() -- throws IOException; -- -- /** -- * Reads a reference -- * -- *
--   * R b32 b24 b16 b8
--   * 
-- */ -- abstract public Object readRef() -- throws IOException; -- -- /** -- * Adds an object reference. -- */ -- abstract public int addRef(Object obj) -- throws IOException; -- -- /** -- * Sets an object reference. -- */ -- abstract public void setRef(int i, Object obj) -- throws IOException; -- -- /** -- * Resets the references for streaming. -- */ -- public void resetReferences() -- { -- } -- -- /** -- * Reads the start of a list -- */ -- abstract public int readListStart() -- throws IOException; -- -- /** -- * Reads the length of a list. -- */ -- abstract public int readLength() -- throws IOException; -- -- /** -- * Reads the start of a map -- */ -- abstract public int readMapStart() -- throws IOException; -- -- /** -- * Reads an object type. -- */ -- abstract public String readType() -- throws IOException; -- -- /** -- * Returns true if the data has ended. -- */ -- abstract public boolean isEnd() -- throws IOException; -- -- /** -- * Read the end byte -- */ -- abstract public void readEnd() -- throws IOException; -- -- /** -- * Read the end byte -- */ -- abstract public void readMapEnd() -- throws IOException; -- -- /** -- * Read the end byte -- */ -- abstract public void readListEnd() -- throws IOException; -- -- public void close() -- throws IOException -- { -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.Reader; -+ -+/** -+ * Abstract base class for Hessian requests. Hessian users should only -+ * need to use the methods in this class. -+ * -+ *
-+ * AbstractHessianInput in = ...; // get input
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+abstract public class AbstractHessianInput { -+ private HessianRemoteResolver resolver; -+ private byte []_buffer; -+ -+ /** -+ * Initialize the Hessian stream with the underlying input stream. -+ */ -+ public void init(InputStream is) -+ { -+ } -+ -+ /** -+ * Returns the call's method -+ */ -+ abstract public String getMethod(); -+ -+ /** -+ * Sets the resolver used to lookup remote objects. -+ */ -+ public void setRemoteResolver(HessianRemoteResolver resolver) -+ { -+ this.resolver = resolver; -+ } -+ -+ /** -+ * Sets the resolver used to lookup remote objects. -+ */ -+ public HessianRemoteResolver getRemoteResolver() -+ { -+ return resolver; -+ } -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory ser) -+ { -+ } -+ -+ /** -+ * Reads the call -+ * -+ *
-+   * c major minor
-+   * 
-+ */ -+ abstract public int readCall() -+ throws IOException; -+ -+ /** -+ * For backward compatibility with HessianSkeleton -+ */ -+ public void skipOptionalCall() -+ throws IOException -+ { -+ } -+ -+ /** -+ * Reads a header, returning null if there are no headers. -+ * -+ *
-+   * H b16 b8 value
-+   * 
-+ */ -+ abstract public String readHeader() -+ throws IOException; -+ -+ /** -+ * Starts reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * m b16 b8 method
-+   * 
-+ */ -+ abstract public String readMethod() -+ throws IOException; -+ -+ /** -+ * Reads the number of method arguments -+ * -+ * @return -1 for a variable length (hessian 1.0) -+ */ -+ public int readMethodArgLength() -+ throws IOException -+ { -+ return -1; -+ } -+ -+ /** -+ * Starts reading the call, including the headers. -+ * -+ *

The call expects the following protocol data -+ * -+ *

-+   * c major minor
-+   * m b16 b8 method
-+   * 
-+ */ -+ abstract public void startCall() -+ throws IOException; -+ -+ /** -+ * Completes reading the call -+ * -+ *

The call expects the following protocol data -+ * -+ *

-+   * Z
-+   * 
-+ */ -+ abstract public void completeCall() -+ throws IOException; -+ -+ /** -+ * Reads a reply as an object. -+ * If the reply has a fault, throws the exception. -+ */ -+ abstract public Object readReply(Class expectedClass) -+ throws Throwable; -+ -+ /** -+ * Starts reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * r
-+   * v
-+   * 
-+ */ -+ abstract public void startReply() -+ throws Throwable; -+ -+ /** -+ * Starts reading the body of the reply, i.e. after the 'r' has been -+ * parsed. -+ */ -+ public void startReplyBody() -+ throws Throwable -+ { -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ abstract public void completeReply() -+ throws IOException; -+ -+ /** -+ * Reads a boolean -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ */ -+ abstract public boolean readBoolean() -+ throws IOException; -+ -+ /** -+ * Reads a null -+ * -+ *
-+   * N
-+   * 
-+ */ -+ abstract public void readNull() -+ throws IOException; -+ -+ /** -+ * Reads an integer -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ */ -+ abstract public int readInt() -+ throws IOException; -+ -+ /** -+ * Reads a long -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ abstract public long readLong() -+ throws IOException; -+ -+ /** -+ * Reads a double. -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ abstract public double readDouble() -+ throws IOException; -+ -+ /** -+ * Reads a date. -+ * -+ *
-+   * T b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ abstract public long readUTCDate() -+ throws IOException; -+ -+ /** -+ * Reads a string encoded in UTF-8 -+ * -+ *
-+   * s b16 b8 non-final string chunk
-+   * S b16 b8 final string chunk
-+   * 
-+ */ -+ abstract public String readString() -+ throws IOException; -+ -+ /** -+ * Reads an XML node encoded in UTF-8 -+ * -+ *
-+   * x b16 b8 non-final xml chunk
-+   * X b16 b8 final xml chunk
-+   * 
-+ */ -+ public org.w3c.dom.Node readNode() -+ throws IOException -+ { -+ throw new UnsupportedOperationException(getClass().getSimpleName()); -+ } -+ -+ /** -+ * Starts reading a string. All the characters must be read before -+ * calling the next method. The actual characters will be read with -+ * the reader's read() or read(char [], int, int). -+ * -+ *
-+   * s b16 b8 non-final string chunk
-+   * S b16 b8 final string chunk
-+   * 
-+ */ -+ abstract public Reader getReader() -+ throws IOException; -+ -+ /** -+ * Starts reading a byte array using an input stream. All the bytes -+ * must be read before calling the following method. -+ * -+ *
-+   * b b16 b8 non-final binary chunk
-+   * B b16 b8 final binary chunk
-+   * 
-+ */ -+ abstract public InputStream readInputStream() -+ throws IOException; -+ -+ /** -+ * Reads data to an output stream. -+ * -+ *
-+   * b b16 b8 non-final binary chunk
-+   * B b16 b8 final binary chunk
-+   * 
-+ */ -+ public boolean readToOutputStream(OutputStream os) -+ throws IOException -+ { -+ InputStream is = readInputStream(); -+ -+ if (is == null) -+ return false; -+ -+ if (_buffer == null) -+ _buffer = new byte[256]; -+ -+ try { -+ int len; -+ -+ while ((len = is.read(_buffer, 0, _buffer.length)) > 0) { -+ os.write(_buffer, 0, len); -+ } -+ -+ return true; -+ } finally { -+ is.close(); -+ } -+ } -+ -+ -+ -+ /** -+ * Reads a byte array. -+ * -+ *
-+   * b b16 b8 non-final binary chunk
-+   * B b16 b8 final binary chunk
-+   * 
-+ */ -+ abstract public byte []readBytes() -+ throws IOException; -+ -+ /** -+ * Reads an arbitrary object from the input stream. -+ * -+ * @param expectedClass the expected class if the protocol doesn't supply it. -+ */ -+ abstract public Object readObject(Class expectedClass) -+ throws IOException; -+ -+ /** -+ * Reads an arbitrary object from the input stream. -+ */ -+ abstract public Object readObject() -+ throws IOException; -+ -+ /** -+ * Reads a remote object reference to the stream. The type is the -+ * type of the remote interface. -+ * -+ *
-+   * 'r' 't' b16 b8 type url
-+   * 
-+ */ -+ abstract public Object readRemote() -+ throws IOException; -+ -+ /** -+ * Reads a reference -+ * -+ *
-+   * R b32 b24 b16 b8
-+   * 
-+ */ -+ abstract public Object readRef() -+ throws IOException; -+ -+ /** -+ * Adds an object reference. -+ */ -+ abstract public int addRef(Object obj) -+ throws IOException; -+ -+ /** -+ * Sets an object reference. -+ */ -+ abstract public void setRef(int i, Object obj) -+ throws IOException; -+ -+ /** -+ * Resets the references for streaming. -+ */ -+ public void resetReferences() -+ { -+ } -+ -+ /** -+ * Reads the start of a list -+ */ -+ abstract public int readListStart() -+ throws IOException; -+ -+ /** -+ * Reads the length of a list. -+ */ -+ abstract public int readLength() -+ throws IOException; -+ -+ /** -+ * Reads the start of a map -+ */ -+ abstract public int readMapStart() -+ throws IOException; -+ -+ /** -+ * Reads an object type. -+ */ -+ abstract public String readType() -+ throws IOException; -+ -+ /** -+ * Returns true if the data has ended. -+ */ -+ abstract public boolean isEnd() -+ throws IOException; -+ -+ /** -+ * Read the end byte -+ */ -+ abstract public void readEnd() -+ throws IOException; -+ -+ /** -+ * Read the end byte -+ */ -+ abstract public void readMapEnd() -+ throws IOException; -+ -+ /** -+ * Read the end byte -+ */ -+ abstract public void readListEnd() -+ throws IOException; -+ -+ public void close() -+ throws IOException -+ { -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianOutput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,592 +1,592 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; -- --/** -- * Abstract output stream for Hessian requests. -- * -- *
-- * OutputStream os = ...; // from http connection
-- * AbstractOutput out = new HessianSerializerOutput(os);
-- * String value;
-- *
-- * out.startCall("hello");  // start hello call
-- * out.writeString("arg1"); // write a string argument
-- * out.completeCall();      // complete the call
-- * 
-- */ --abstract public class AbstractHessianOutput { -- // serializer factory -- private SerializerFactory _defaultSerializerFactory; -- -- // serializer factory -- protected SerializerFactory _serializerFactory; -- -- private byte []_byteBuffer; -- -- /** -- * Sets the serializer factory. -- */ -- public void setSerializerFactory(SerializerFactory factory) -- { -- _serializerFactory = factory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- public SerializerFactory getSerializerFactory() -- { -- // the default serializer factory cannot be modified by external -- // callers -- if (_serializerFactory == _defaultSerializerFactory) { -- _serializerFactory = new SerializerFactory(); -- } -- -- return _serializerFactory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- protected final SerializerFactory findSerializerFactory() -- { -- SerializerFactory factory = _serializerFactory; -- -- if (factory == null) { -- factory = SerializerFactory.createDefault(); -- _defaultSerializerFactory = factory; -- _serializerFactory = factory; -- } -- -- return factory; -- } -- -- /** -- * Initialize the output with a new underlying stream. -- */ -- public void init(OutputStream os) -- { -- } -- -- public boolean setUnshared(boolean isUnshared) -- { -- throw new UnsupportedOperationException(getClass().getSimpleName()); -- } -- -- /** -- * Writes a complete method call. -- */ -- public void call(String method, Object []args) -- throws IOException -- { -- int length = args != null ? args.length : 0; -- -- startCall(method, length); -- -- for (int i = 0; i < length; i++) -- writeObject(args[i]); -- -- completeCall(); -- } -- -- /** -- * Starts the method call: -- * -- *
--   * C
--   * 
-- * -- * @param method the method name to call. -- */ -- abstract public void startCall() -- throws IOException; -- -- /** -- * Starts the method call: -- * -- *
--   * C string int
--   * 
-- * -- * @param method the method name to call. -- */ -- abstract public void startCall(String method, int length) -- throws IOException; -- -- /** -- * For Hessian 2.0, use the Header envelope instead -- * -- * @deprecated -- */ -- public void writeHeader(String name) -- throws IOException -- { -- throw new UnsupportedOperationException(getClass().getSimpleName()); -- } -- -- /** -- * Writes the method tag. -- * -- *
--   * string
--   * 
-- * -- * @param method the method name to call. -- */ -- abstract public void writeMethod(String method) -- throws IOException; -- -- /** -- * Completes the method call: -- * -- *
--   * 
-- */ -- abstract public void completeCall() -- throws IOException; -- -- /** -- * Writes a boolean value to the stream. The boolean will be written -- * with the following syntax: -- * -- *
--   * T
--   * F
--   * 
-- * -- * @param value the boolean value to write. -- */ -- abstract public void writeBoolean(boolean value) -- throws IOException; -- -- /** -- * Writes an integer value to the stream. The integer will be written -- * with the following syntax: -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- * -- * @param value the integer value to write. -- */ -- abstract public void writeInt(int value) -- throws IOException; -- -- /** -- * Writes a long value to the stream. The long will be written -- * with the following syntax: -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param value the long value to write. -- */ -- abstract public void writeLong(long value) -- throws IOException; -- -- /** -- * Writes a double value to the stream. The double will be written -- * with the following syntax: -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param value the double value to write. -- */ -- abstract public void writeDouble(double value) -- throws IOException; -- -- /** -- * Writes a date to the stream. -- * -- *
--   * T  b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param time the date in milliseconds from the epoch in UTC -- */ -- abstract public void writeUTCDate(long time) -- throws IOException; -- -- /** -- * Writes a null value to the stream. -- * The null will be written with the following syntax -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- abstract public void writeNull() -- throws IOException; -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- abstract public void writeString(String value) -- throws IOException; -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- abstract public void writeString(char []buffer, int offset, int length) -- throws IOException; -- -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- abstract public void writeBytes(byte []buffer) -- throws IOException; -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- abstract public void writeBytes(byte []buffer, int offset, int length) -- throws IOException; -- -- /** -- * Writes a byte buffer to the stream. -- */ -- abstract public void writeByteBufferStart() -- throws IOException; -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- * -- * @param value the string value to write. -- */ -- abstract public void writeByteBufferPart(byte []buffer, -- int offset, -- int length) -- throws IOException; -- -- /** -- * Writes the last chunk of a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- * -- * @param value the string value to write. -- */ -- abstract public void writeByteBufferEnd(byte []buffer, -- int offset, -- int length) -- throws IOException; -- -- /** -- * Writes a full output stream. -- */ -- public void writeByteStream(InputStream is) -- throws IOException -- { -- writeByteBufferStart(); -- -- if (_byteBuffer == null) -- _byteBuffer = new byte[1024]; -- -- byte []buffer = _byteBuffer; -- -- int len; -- while ((len = is.read(buffer, 0, buffer.length)) > 0) { -- if (len < buffer.length) { -- int len2 = is.read(buffer, len, buffer.length - len); -- -- if (len2 < 0) { -- writeByteBufferEnd(buffer, 0, len); -- return; -- } -- -- len += len2; -- } -- -- writeByteBufferPart(buffer, 0, len); -- } -- -- writeByteBufferEnd(buffer, 0, 0); -- } -- -- /** -- * Writes a reference. -- * -- *
--   * Q int
--   * 
-- * -- * @param value the integer value to write. -- */ -- abstract protected void writeRef(int value) -- throws IOException; -- -- /** -- * Removes a reference. -- */ -- public boolean removeRef(Object obj) -- throws IOException -- { -- return false; -- } -- -- /** -- * Replaces a reference from one object to another. -- */ -- abstract public boolean replaceRef(Object oldRef, Object newRef) -- throws IOException; -- -- /** -- * Adds an object to the reference list. If the object already exists, -- * writes the reference, otherwise, the caller is responsible for -- * the serialization. -- * -- *
--   * R b32 b24 b16 b8
--   * 
-- * -- * @param object the object to add as a reference. -- * -- * @return true if the object has already been written. -- */ -- abstract public boolean addRef(Object object) -- throws IOException; -- -- /** -- * @param obj -- * @return -- */ -- abstract public int getRef(Object obj); -- -- /** -- * Resets the references for streaming. -- */ -- public void resetReferences() -- { -- } -- -- /** -- * Writes a generic object to the output stream. -- */ -- abstract public void writeObject(Object object) -- throws IOException; -- -- /** -- * Writes the list header to the stream. List writers will call -- * writeListBegin followed by the list contents and then -- * call writeListEnd. -- * -- *
--   * V
--   *   x13 java.util.ArrayList   # type
--   *   x93                       # length=3
--   *   x91                       # 1
--   *   x92                       # 2
--   *   x93                       # 3
--   * </list>
--   * 
-- */ -- abstract public boolean writeListBegin(int length, String type) -- throws IOException; -- -- /** -- * Writes the tail of the list to the stream. -- */ -- abstract public void writeListEnd() -- throws IOException; -- -- /** -- * Writes the map header to the stream. Map writers will call -- * writeMapBegin followed by the map contents and then -- * call writeMapEnd. -- * -- *
--   * M type ( )* Z
--   * 
-- */ -- abstract public void writeMapBegin(String type) -- throws IOException; -- -- /** -- * Writes the tail of the map to the stream. -- */ -- abstract public void writeMapEnd() -- throws IOException; -- -- /** -- * Writes the object header to the stream (for Hessian 2.0), or a -- * Map for Hessian 1.0. Object writers will call -- * writeObjectBegin followed by the map contents and then -- * call writeObjectEnd. -- * -- *
--   * C type int *
--   * C int *
--   * 
-- * -- * @return true if the object has already been defined. -- */ -- public int writeObjectBegin(String type) -- throws IOException -- { -- writeMapBegin(type); -- -- return -2; -- } -- -- /** -- * Writes the end of the class. -- */ -- public void writeClassFieldLength(int len) -- throws IOException -- { -- } -- -- /** -- * Writes the tail of the object to the stream. -- */ -- public void writeObjectEnd() -- throws IOException -- { -- } -- -- public void writeReply(Object o) -- throws IOException -- { -- startReply(); -- writeObject(o); -- completeReply(); -- } -- -- -- public void startReply() -- throws IOException -- { -- } -- -- public void completeReply() -- throws IOException -- { -- } -- -- public void writeFault(String code, String message, Object detail) -- throws IOException -- { -- } -- -- public void flush() -- throws IOException -- { -- } -- -- public void close() -- throws IOException -- { -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+ -+/** -+ * Abstract output stream for Hessian requests. -+ * -+ *
-+ * OutputStream os = ...; // from http connection
-+ * AbstractOutput out = new HessianSerializerOutput(os);
-+ * String value;
-+ *
-+ * out.startCall("hello");  // start hello call
-+ * out.writeString("arg1"); // write a string argument
-+ * out.completeCall();      // complete the call
-+ * 
-+ */ -+abstract public class AbstractHessianOutput { -+ // serializer factory -+ private SerializerFactory _defaultSerializerFactory; -+ -+ // serializer factory -+ protected SerializerFactory _serializerFactory; -+ -+ private byte []_byteBuffer; -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ public SerializerFactory getSerializerFactory() -+ { -+ // the default serializer factory cannot be modified by external -+ // callers -+ if (_serializerFactory == _defaultSerializerFactory) { -+ _serializerFactory = new SerializerFactory(); -+ } -+ -+ return _serializerFactory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ protected final SerializerFactory findSerializerFactory() -+ { -+ SerializerFactory factory = _serializerFactory; -+ -+ if (factory == null) { -+ factory = SerializerFactory.createDefault(); -+ _defaultSerializerFactory = factory; -+ _serializerFactory = factory; -+ } -+ -+ return factory; -+ } -+ -+ /** -+ * Initialize the output with a new underlying stream. -+ */ -+ public void init(OutputStream os) -+ { -+ } -+ -+ public boolean setUnshared(boolean isUnshared) -+ { -+ throw new UnsupportedOperationException(getClass().getSimpleName()); -+ } -+ -+ /** -+ * Writes a complete method call. -+ */ -+ public void call(String method, Object []args) -+ throws IOException -+ { -+ int length = args != null ? args.length : 0; -+ -+ startCall(method, length); -+ -+ for (int i = 0; i < length; i++) -+ writeObject(args[i]); -+ -+ completeCall(); -+ } -+ -+ /** -+ * Starts the method call: -+ * -+ *
-+   * C
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ abstract public void startCall() -+ throws IOException; -+ -+ /** -+ * Starts the method call: -+ * -+ *
-+   * C string int
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ abstract public void startCall(String method, int length) -+ throws IOException; -+ -+ /** -+ * For Hessian 2.0, use the Header envelope instead -+ * -+ * @deprecated -+ */ -+ public void writeHeader(String name) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(getClass().getSimpleName()); -+ } -+ -+ /** -+ * Writes the method tag. -+ * -+ *
-+   * string
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ abstract public void writeMethod(String method) -+ throws IOException; -+ -+ /** -+ * Completes the method call: -+ * -+ *
-+   * 
-+ */ -+ abstract public void completeCall() -+ throws IOException; -+ -+ /** -+ * Writes a boolean value to the stream. The boolean will be written -+ * with the following syntax: -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ * -+ * @param value the boolean value to write. -+ */ -+ abstract public void writeBoolean(boolean value) -+ throws IOException; -+ -+ /** -+ * Writes an integer value to the stream. The integer will be written -+ * with the following syntax: -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ abstract public void writeInt(int value) -+ throws IOException; -+ -+ /** -+ * Writes a long value to the stream. The long will be written -+ * with the following syntax: -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the long value to write. -+ */ -+ abstract public void writeLong(long value) -+ throws IOException; -+ -+ /** -+ * Writes a double value to the stream. The double will be written -+ * with the following syntax: -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the double value to write. -+ */ -+ abstract public void writeDouble(double value) -+ throws IOException; -+ -+ /** -+ * Writes a date to the stream. -+ * -+ *
-+   * T  b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param time the date in milliseconds from the epoch in UTC -+ */ -+ abstract public void writeUTCDate(long time) -+ throws IOException; -+ -+ /** -+ * Writes a null value to the stream. -+ * The null will be written with the following syntax -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ abstract public void writeNull() -+ throws IOException; -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ abstract public void writeString(String value) -+ throws IOException; -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ abstract public void writeString(char []buffer, int offset, int length) -+ throws IOException; -+ -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ abstract public void writeBytes(byte []buffer) -+ throws IOException; -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ abstract public void writeBytes(byte []buffer, int offset, int length) -+ throws IOException; -+ -+ /** -+ * Writes a byte buffer to the stream. -+ */ -+ abstract public void writeByteBufferStart() -+ throws IOException; -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ abstract public void writeByteBufferPart(byte []buffer, -+ int offset, -+ int length) -+ throws IOException; -+ -+ /** -+ * Writes the last chunk of a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ abstract public void writeByteBufferEnd(byte []buffer, -+ int offset, -+ int length) -+ throws IOException; -+ -+ /** -+ * Writes a full output stream. -+ */ -+ public void writeByteStream(InputStream is) -+ throws IOException -+ { -+ writeByteBufferStart(); -+ -+ if (_byteBuffer == null) -+ _byteBuffer = new byte[1024]; -+ -+ byte []buffer = _byteBuffer; -+ -+ int len; -+ while ((len = is.read(buffer, 0, buffer.length)) > 0) { -+ if (len < buffer.length) { -+ int len2 = is.read(buffer, len, buffer.length - len); -+ -+ if (len2 < 0) { -+ writeByteBufferEnd(buffer, 0, len); -+ return; -+ } -+ -+ len += len2; -+ } -+ -+ writeByteBufferPart(buffer, 0, len); -+ } -+ -+ writeByteBufferEnd(buffer, 0, 0); -+ } -+ -+ /** -+ * Writes a reference. -+ * -+ *
-+   * Q int
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ abstract protected void writeRef(int value) -+ throws IOException; -+ -+ /** -+ * Removes a reference. -+ */ -+ public boolean removeRef(Object obj) -+ throws IOException -+ { -+ return false; -+ } -+ -+ /** -+ * Replaces a reference from one object to another. -+ */ -+ abstract public boolean replaceRef(Object oldRef, Object newRef) -+ throws IOException; -+ -+ /** -+ * Adds an object to the reference list. If the object already exists, -+ * writes the reference, otherwise, the caller is responsible for -+ * the serialization. -+ * -+ *
-+   * R b32 b24 b16 b8
-+   * 
-+ * -+ * @param object the object to add as a reference. -+ * -+ * @return true if the object has already been written. -+ */ -+ abstract public boolean addRef(Object object) -+ throws IOException; -+ -+ /** -+ * @param obj -+ * @return -+ */ -+ abstract public int getRef(Object obj); -+ -+ /** -+ * Resets the references for streaming. -+ */ -+ public void resetReferences() -+ { -+ } -+ -+ /** -+ * Writes a generic object to the output stream. -+ */ -+ abstract public void writeObject(Object object) -+ throws IOException; -+ -+ /** -+ * Writes the list header to the stream. List writers will call -+ * writeListBegin followed by the list contents and then -+ * call writeListEnd. -+ * -+ *
-+   * V
-+   *   x13 java.util.ArrayList   # type
-+   *   x93                       # length=3
-+   *   x91                       # 1
-+   *   x92                       # 2
-+   *   x93                       # 3
-+   * </list>
-+   * 
-+ */ -+ abstract public boolean writeListBegin(int length, String type) -+ throws IOException; -+ -+ /** -+ * Writes the tail of the list to the stream. -+ */ -+ abstract public void writeListEnd() -+ throws IOException; -+ -+ /** -+ * Writes the map header to the stream. Map writers will call -+ * writeMapBegin followed by the map contents and then -+ * call writeMapEnd. -+ * -+ *
-+   * M type ( )* Z
-+   * 
-+ */ -+ abstract public void writeMapBegin(String type) -+ throws IOException; -+ -+ /** -+ * Writes the tail of the map to the stream. -+ */ -+ abstract public void writeMapEnd() -+ throws IOException; -+ -+ /** -+ * Writes the object header to the stream (for Hessian 2.0), or a -+ * Map for Hessian 1.0. Object writers will call -+ * writeObjectBegin followed by the map contents and then -+ * call writeObjectEnd. -+ * -+ *
-+   * C type int *
-+   * C int *
-+   * 
-+ * -+ * @return true if the object has already been defined. -+ */ -+ public int writeObjectBegin(String type) -+ throws IOException -+ { -+ writeMapBegin(type); -+ -+ return -2; -+ } -+ -+ /** -+ * Writes the end of the class. -+ */ -+ public void writeClassFieldLength(int len) -+ throws IOException -+ { -+ } -+ -+ /** -+ * Writes the tail of the object to the stream. -+ */ -+ public void writeObjectEnd() -+ throws IOException -+ { -+ } -+ -+ public void writeReply(Object o) -+ throws IOException -+ { -+ startReply(); -+ writeObject(o); -+ completeReply(); -+ } -+ -+ -+ public void startReply() -+ throws IOException -+ { -+ } -+ -+ public void completeReply() -+ throws IOException -+ { -+ } -+ -+ public void writeFault(String code, String message, Object detail) -+ throws IOException -+ { -+ } -+ -+ public void flush() -+ throws IOException -+ { -+ } -+ -+ public void close() -+ throws IOException -+ { -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianResolver.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianResolver.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractHessianResolver.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractHessianResolver.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,65 +1,65 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Looks up remote objects. The default just returns a HessianRemote object. -- */ --public class AbstractHessianResolver implements HessianRemoteResolver { -- /** -- * Looks up a proxy object. -- */ -- public Object lookup(String type, String url) -- throws IOException -- { -- return new HessianRemote(type, url); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Looks up remote objects. The default just returns a HessianRemote object. -+ */ -+public class AbstractHessianResolver implements HessianRemoteResolver { -+ /** -+ * Looks up a proxy object. -+ */ -+ public Object lookup(String type, String url) -+ throws IOException -+ { -+ return new HessianRemote(type, url); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractListDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractListDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractListDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractListDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,67 +1,67 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Deserializing a JDK 1.2 Collection. -- */ --public class AbstractListDeserializer extends AbstractDeserializer { -- public Object readObject(AbstractHessianInput in) -- throws IOException -- { -- Object obj = in.readObject(); -- -- if (obj != null) -- throw error("expected list at " + obj.getClass().getName() + " (" + obj + ")"); -- else -- throw error("expected list at null"); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Deserializing a JDK 1.2 Collection. -+ */ -+public class AbstractListDeserializer extends AbstractDeserializer { -+ public Object readObject(AbstractHessianInput in) -+ throws IOException -+ { -+ Object obj = in.readObject(); -+ -+ if (obj != null) -+ throw error("expected list at " + obj.getClass().getName() + " (" + obj + ")"); -+ else -+ throw error("expected list at null"); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractMapDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractMapDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractMapDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractMapDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,74 +1,74 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.HashMap; -- --/** -- * Serializing an object for known object types. -- */ --public class AbstractMapDeserializer extends AbstractDeserializer { -- -- public Class getType() -- { -- return HashMap.class; -- } -- -- public Object readObject(AbstractHessianInput in) -- throws IOException -- { -- Object obj = in.readObject(); -- -- if (obj != null) -- throw error("expected map/object at " + obj.getClass().getName() + " (" + obj + ")"); -- else -- throw error("expected map/object at null"); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.HashMap; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class AbstractMapDeserializer extends AbstractDeserializer { -+ -+ public Class getType() -+ { -+ return HashMap.class; -+ } -+ -+ public Object readObject(AbstractHessianInput in) -+ throws IOException -+ { -+ Object obj = in.readObject(); -+ -+ if (obj != null) -+ throw error("expected map/object at " + obj.getClass().getName() + " (" + obj + ")"); -+ else -+ throw error("expected map/object at null"); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,152 +1,152 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.logging.*; -- --import com.caucho.hessian.HessianException; -- --/** -- * Serializing an object. -- */ --abstract public class AbstractSerializer implements Serializer { -- public static final NullSerializer NULL = new NullSerializer(); -- -- protected static final Logger log -- = Logger.getLogger(AbstractSerializer.class.getName()); -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) { -- return; -- } -- -- try { -- Object replace = writeReplace(obj); -- -- if (replace != null) { -- // out.removeRef(obj); -- -- out.writeObject(replace); -- -- out.replaceRef(replace, obj); -- -- return; -- } -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- // log.log(Level.FINE, e.toString(), e); -- throw new HessianException(e); -- } -- -- Class cl = getClass(obj); -- -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref < -1) { -- writeObject10(obj, out); -- } -- else { -- if (ref == -1) { -- writeDefinition20(cl, out); -- -- out.writeObjectBegin(cl.getName()); -- } -- -- writeInstance(obj, out); -- } -- } -- -- protected Object writeReplace(Object obj) -- { -- return null; -- } -- -- protected Class getClass(Object obj) -- { -- return obj.getClass(); -- } -- -- protected void writeObject10(Object obj, -- AbstractHessianOutput out) -- throws IOException -- { -- throw new UnsupportedOperationException(getClass().getName()); -- } -- -- protected void writeDefinition20(Class cl, -- AbstractHessianOutput out) -- throws IOException -- { -- throw new UnsupportedOperationException(getClass().getName()); -- } -- -- protected void writeInstance(Object obj, -- AbstractHessianOutput out) -- throws IOException -- { -- throw new UnsupportedOperationException(getClass().getName()); -- } -- -- /** -- * The NullSerializer exists as a marker for the factory classes so -- * they save a null result. -- */ -- static final class NullSerializer extends AbstractSerializer { -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- throw new IllegalStateException(getClass().getName()); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.logging.*; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Serializing an object. -+ */ -+abstract public class AbstractSerializer implements Serializer { -+ public static final NullSerializer NULL = new NullSerializer(); -+ -+ protected static final Logger log -+ = Logger.getLogger(AbstractSerializer.class.getName()); -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) { -+ return; -+ } -+ -+ try { -+ Object replace = writeReplace(obj); -+ -+ if (replace != null) { -+ // out.removeRef(obj); -+ -+ out.writeObject(replace); -+ -+ out.replaceRef(replace, obj); -+ -+ return; -+ } -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ // log.log(Level.FINE, e.toString(), e); -+ throw new HessianException(e); -+ } -+ -+ Class cl = getClass(obj); -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref < -1) { -+ writeObject10(obj, out); -+ } -+ else { -+ if (ref == -1) { -+ writeDefinition20(cl, out); -+ -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ writeInstance(obj, out); -+ } -+ } -+ -+ protected Object writeReplace(Object obj) -+ { -+ return null; -+ } -+ -+ protected Class getClass(Object obj) -+ { -+ return obj.getClass(); -+ } -+ -+ protected void writeObject10(Object obj, -+ AbstractHessianOutput out) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(getClass().getName()); -+ } -+ -+ protected void writeDefinition20(Class cl, -+ AbstractHessianOutput out) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(getClass().getName()); -+ } -+ -+ protected void writeInstance(Object obj, -+ AbstractHessianOutput out) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(getClass().getName()); -+ } -+ -+ /** -+ * The NullSerializer exists as a marker for the factory classes so -+ * they save a null result. -+ */ -+ static final class NullSerializer extends AbstractSerializer { -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ throw new IllegalStateException(getClass().getName()); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,74 +1,74 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --/** -- * Factory for returning serialization methods. -- */ --abstract public class AbstractSerializerFactory { -- /** -- * Returns the serializer for a class. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- abstract public Serializer getSerializer(Class cl) -- throws HessianProtocolException; -- -- /** -- * Returns the deserializer for a class. -- * -- * @param cl the class of the object that needs to be deserialized. -- * -- * @return a deserializer object for the serialization. -- */ -- abstract public Deserializer getDeserializer(Class cl) -- throws HessianProtocolException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+/** -+ * Factory for returning serialization methods. -+ */ -+abstract public class AbstractSerializerFactory { -+ /** -+ * Returns the serializer for a class. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ abstract public Serializer getSerializer(Class cl) -+ throws HessianProtocolException; -+ -+ /** -+ * Returns the deserializer for a class. -+ * -+ * @param cl the class of the object that needs to be deserialized. -+ * -+ * @return a deserializer object for the serialization. -+ */ -+ abstract public Deserializer getDeserializer(Class cl) -+ throws HessianProtocolException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerWrapper.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerWrapper.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractSerializerWrapper.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractSerializerWrapper.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,69 +1,69 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.logging.Logger; -- --/** -- * Serializing an object. -- */ --abstract public class AbstractSerializerWrapper implements Serializer { -- protected static final Logger log -- = Logger.getLogger(AbstractSerializerWrapper.class.getName()); -- -- abstract protected Serializer getDelegate(); -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- getDelegate().writeObject(obj, out); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.logging.Logger; -+ -+/** -+ * Serializing an object. -+ */ -+abstract public class AbstractSerializerWrapper implements Serializer { -+ protected static final Logger log -+ = Logger.getLogger(AbstractSerializerWrapper.class.getName()); -+ -+ abstract protected Serializer getDelegate(); -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ getDelegate().writeObject(obj, out); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,105 +1,105 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Deserializing a byte stream -- */ --abstract public class AbstractStreamDeserializer extends AbstractDeserializer { -- abstract public Class getType(); -- -- /** -- * Reads the Hessian 1.0 style map. -- */ -- @Override -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- Object value = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if (key.equals("value")) -- value = readStreamValue(in); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- return value; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, Object []fields) -- throws IOException -- { -- String []fieldNames = (String []) fields; -- -- Object value = null; -- -- for (int i = 0; i < fieldNames.length; i++) { -- if ("value".equals(fieldNames[i])) { -- value = readStreamValue(in); -- in.addRef(value); -- } -- else { -- in.readObject(); -- } -- } -- -- return value; -- } -- -- abstract protected Object readStreamValue(AbstractHessianInput in) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Deserializing a byte stream -+ */ -+abstract public class AbstractStreamDeserializer extends AbstractDeserializer { -+ abstract public Class getType(); -+ -+ /** -+ * Reads the Hessian 1.0 style map. -+ */ -+ @Override -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ Object value = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if (key.equals("value")) -+ value = readStreamValue(in); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ return value; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, Object []fields) -+ throws IOException -+ { -+ String []fieldNames = (String []) fields; -+ -+ Object value = null; -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ if ("value".equals(fieldNames[i])) { -+ value = readStreamValue(in); -+ in.addRef(value); -+ } -+ else { -+ in.readObject(); -+ } -+ } -+ -+ return value; -+ } -+ -+ abstract protected Object readStreamValue(AbstractHessianInput in) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractStreamSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStreamSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,131 +1,131 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; --import java.util.logging.Level; -- --/** -- * Serializing an object containing a byte stream. -- */ --abstract public class AbstractStreamSerializer extends AbstractSerializer --{ -- /** -- * Writes the object to the output stream. -- */ -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) { -- return; -- } -- -- int ref = out.writeObjectBegin(getClassName(obj)); -- -- if (ref < -1) { -- out.writeString("value"); -- -- InputStream is = null; -- -- try { -- is = getInputStream(obj); -- } catch (Exception e) { -- log.log(Level.WARNING, e.toString(), e); -- } -- -- if (is != null) { -- try { -- out.writeByteStream(is); -- } finally { -- is.close(); -- } -- } else { -- out.writeNull(); -- } -- -- out.writeMapEnd(); -- } -- else { -- if (ref == -1) { -- out.writeClassFieldLength(1); -- out.writeString("value"); -- -- out.writeObjectBegin(getClassName(obj)); -- } -- -- InputStream is = null; -- -- try { -- is = getInputStream(obj); -- } catch (Exception e) { -- log.log(Level.WARNING, e.toString(), e); -- } -- -- try { -- if (is != null) -- out.writeByteStream(is); -- else -- out.writeNull(); -- } finally { -- if (is != null) -- is.close(); -- } -- } -- } -- -- protected String getClassName(Object obj) -- { -- return obj.getClass().getName(); -- } -- -- abstract protected InputStream getInputStream(Object obj) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.util.logging.Level; -+ -+/** -+ * Serializing an object containing a byte stream. -+ */ -+abstract public class AbstractStreamSerializer extends AbstractSerializer -+{ -+ /** -+ * Writes the object to the output stream. -+ */ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) { -+ return; -+ } -+ -+ int ref = out.writeObjectBegin(getClassName(obj)); -+ -+ if (ref < -1) { -+ out.writeString("value"); -+ -+ InputStream is = null; -+ -+ try { -+ is = getInputStream(obj); -+ } catch (Exception e) { -+ log.log(Level.WARNING, e.toString(), e); -+ } -+ -+ if (is != null) { -+ try { -+ out.writeByteStream(is); -+ } finally { -+ is.close(); -+ } -+ } else { -+ out.writeNull(); -+ } -+ -+ out.writeMapEnd(); -+ } -+ else { -+ if (ref == -1) { -+ out.writeClassFieldLength(1); -+ out.writeString("value"); -+ -+ out.writeObjectBegin(getClassName(obj)); -+ } -+ -+ InputStream is = null; -+ -+ try { -+ is = getInputStream(obj); -+ } catch (Exception e) { -+ log.log(Level.WARNING, e.toString(), e); -+ } -+ -+ try { -+ if (is != null) -+ out.writeByteStream(is); -+ else -+ out.writeNull(); -+ } finally { -+ if (is != null) -+ is.close(); -+ } -+ } -+ } -+ -+ protected String getClassName(Object obj) -+ { -+ return obj.getClass().getName(); -+ } -+ -+ abstract protected InputStream getInputStream(Object obj) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AbstractStringValueDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStringValueDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AbstractStringValueDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AbstractStringValueDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,108 +1,108 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Constructor; -- --/** -- * Deserializes a string-valued object like BigDecimal. -- */ --abstract public class AbstractStringValueDeserializer -- extends AbstractDeserializer --{ -- abstract protected Object create(String value) -- throws IOException; -- -- @Override -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String value = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if (key.equals("value")) -- value = in.readString(); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- Object object = create(value); -- -- in.addRef(object); -- -- return object; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, Object []fields) -- throws IOException -- { -- String []fieldNames = (String []) fields; -- -- String value = null; -- -- for (int i = 0; i < fieldNames.length; i++) { -- if ("value".equals(fieldNames[i])) -- value = in.readString(); -- else -- in.readObject(); -- } -- -- Object object = create(value); -- -- in.addRef(object); -- -- return object; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Constructor; -+ -+/** -+ * Deserializes a string-valued object like BigDecimal. -+ */ -+abstract public class AbstractStringValueDeserializer -+ extends AbstractDeserializer -+{ -+ abstract protected Object create(String value) -+ throws IOException; -+ -+ @Override -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String value = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if (key.equals("value")) -+ value = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object object = create(value); -+ -+ in.addRef(object); -+ -+ return object; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, Object []fields) -+ throws IOException -+ { -+ String []fieldNames = (String []) fields; -+ -+ String value = null; -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ if ("value".equals(fieldNames[i])) -+ value = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ Object object = create(value); -+ -+ in.addRef(object); -+ -+ return object; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AnnotationDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AnnotationDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,138 +1,138 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Constructor; --import java.lang.reflect.Field; --import java.lang.reflect.InvocationTargetException; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.lang.reflect.Proxy; --import java.util.HashMap; -- --import java.util.logging.*; -- --import com.caucho.hessian.HessianException; -- --/** -- * Deserializing a java annotation for known object types. -- */ --public class AnnotationDeserializer extends AbstractMapDeserializer { -- private static final Logger log -- = Logger.getLogger(AnnotationDeserializer.class.getName()); -- -- private Class _annType; -- -- public AnnotationDeserializer(Class annType) -- { -- _annType = annType; -- } -- -- public Class getType() -- { -- return _annType; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- try { -- int ref = in.addRef(null); -- -- HashMap valueMap = new HashMap(8); -- -- while (! in.isEnd()) { -- String key = in.readString(); -- Object value = in.readObject(); -- -- valueMap.put(key, value); -- } -- -- in.readMapEnd(); -- -- return Proxy.newProxyInstance(_annType.getClassLoader(), -- new Class[] { _annType }, -- new AnnotationInvocationHandler(_annType, valueMap)); -- -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException -- { -- String []fieldNames = (String []) fields; -- -- try { -- in.addRef(null); -- -- HashMap valueMap = new HashMap(8); -- -- for (int i = 0; i < fieldNames.length; i++) { -- String name = fieldNames[i]; -- -- valueMap.put(name, in.readObject()); -- } -- -- return Proxy.newProxyInstance(_annType.getClassLoader(), -- new Class[] { _annType }, -- new AnnotationInvocationHandler(_annType, valueMap)); -- -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new HessianException(_annType.getName() + ":" + e, e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Constructor; -+import java.lang.reflect.Field; -+import java.lang.reflect.InvocationTargetException; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.lang.reflect.Proxy; -+import java.util.HashMap; -+ -+import java.util.logging.*; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Deserializing a java annotation for known object types. -+ */ -+public class AnnotationDeserializer extends AbstractMapDeserializer { -+ private static final Logger log -+ = Logger.getLogger(AnnotationDeserializer.class.getName()); -+ -+ private Class _annType; -+ -+ public AnnotationDeserializer(Class annType) -+ { -+ _annType = annType; -+ } -+ -+ public Class getType() -+ { -+ return _annType; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(null); -+ -+ HashMap valueMap = new HashMap(8); -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ Object value = in.readObject(); -+ -+ valueMap.put(key, value); -+ } -+ -+ in.readMapEnd(); -+ -+ return Proxy.newProxyInstance(_annType.getClassLoader(), -+ new Class[] { _annType }, -+ new AnnotationInvocationHandler(_annType, valueMap)); -+ -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ String []fieldNames = (String []) fields; -+ -+ try { -+ in.addRef(null); -+ -+ HashMap valueMap = new HashMap(8); -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ String name = fieldNames[i]; -+ -+ valueMap.put(name, in.readObject()); -+ } -+ -+ return Proxy.newProxyInstance(_annType.getClassLoader(), -+ new Class[] { _annType }, -+ new AnnotationInvocationHandler(_annType, valueMap)); -+ -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new HessianException(_annType.getName() + ":" + e, e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AnnotationInvocationHandler.java hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationInvocationHandler.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AnnotationInvocationHandler.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationInvocationHandler.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,143 +1,143 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.annotation.Annotation; --import java.lang.reflect.InvocationHandler; --import java.lang.reflect.Method; --import java.util.HashMap; --import java.util.Map; -- --import java.util.logging.*; -- --import com.caucho.hessian.HessianException; -- --/** -- * Proxy for a java annotation for known object types. -- */ --public class AnnotationInvocationHandler implements InvocationHandler { -- private Class _annType; -- private HashMap _valueMap; -- -- public AnnotationInvocationHandler(Class annType, -- HashMap valueMap) -- { -- _annType = annType; -- _valueMap = valueMap; -- } -- -- @Override -- public Object invoke(Object proxy, Method method, Object []args) -- throws Throwable -- { -- String name = method.getName(); -- -- boolean zeroArgs = args == null || args.length == 0; -- -- if (name.equals("annotationType") && zeroArgs) -- return _annType; -- else if (name.equals("toString") && zeroArgs) -- return toString(); -- else if (name.equals("hashCode") && zeroArgs) -- return doHashCode(); -- else if (name.equals("equals") && ! zeroArgs && args.length == 1) -- return doEquals(args[0]); -- else if (! zeroArgs) -- return null; -- -- -- return _valueMap.get(method.getName()); -- } -- -- public int doHashCode() -- { -- return 13; -- } -- -- public boolean doEquals(Object value) -- { -- if (! (value instanceof Annotation)) -- return false; -- -- Annotation ann = (Annotation) value; -- -- if (! _annType.equals(ann.annotationType())) -- return false; -- -- return true; -- } -- -- public String toString() -- { -- StringBuilder sb = new StringBuilder(); -- -- sb.append("@"); -- sb.append(_annType.getName()); -- sb.append("["); -- -- boolean isFirst = true; -- for (Map.Entry entry : _valueMap.entrySet()) { -- if (! isFirst) -- sb.append(", "); -- isFirst = false; -- -- sb.append(entry.getKey()); -- sb.append("="); -- -- if (entry.getValue() instanceof String) -- sb.append('"').append(entry.getValue()).append('"'); -- else -- sb.append(entry.getValue()); -- } -- sb.append("]"); -- -- return sb.toString(); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.annotation.Annotation; -+import java.lang.reflect.InvocationHandler; -+import java.lang.reflect.Method; -+import java.util.HashMap; -+import java.util.Map; -+ -+import java.util.logging.*; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Proxy for a java annotation for known object types. -+ */ -+public class AnnotationInvocationHandler implements InvocationHandler { -+ private Class _annType; -+ private HashMap _valueMap; -+ -+ public AnnotationInvocationHandler(Class annType, -+ HashMap valueMap) -+ { -+ _annType = annType; -+ _valueMap = valueMap; -+ } -+ -+ @Override -+ public Object invoke(Object proxy, Method method, Object []args) -+ throws Throwable -+ { -+ String name = method.getName(); -+ -+ boolean zeroArgs = args == null || args.length == 0; -+ -+ if (name.equals("annotationType") && zeroArgs) -+ return _annType; -+ else if (name.equals("toString") && zeroArgs) -+ return toString(); -+ else if (name.equals("hashCode") && zeroArgs) -+ return doHashCode(); -+ else if (name.equals("equals") && ! zeroArgs && args.length == 1) -+ return doEquals(args[0]); -+ else if (! zeroArgs) -+ return null; -+ -+ -+ return _valueMap.get(method.getName()); -+ } -+ -+ public int doHashCode() -+ { -+ return 13; -+ } -+ -+ public boolean doEquals(Object value) -+ { -+ if (! (value instanceof Annotation)) -+ return false; -+ -+ Annotation ann = (Annotation) value; -+ -+ if (! _annType.equals(ann.annotationType())) -+ return false; -+ -+ return true; -+ } -+ -+ public String toString() -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ sb.append("@"); -+ sb.append(_annType.getName()); -+ sb.append("["); -+ -+ boolean isFirst = true; -+ for (Map.Entry entry : _valueMap.entrySet()) { -+ if (! isFirst) -+ sb.append(", "); -+ isFirst = false; -+ -+ sb.append(entry.getKey()); -+ sb.append("="); -+ -+ if (entry.getValue() instanceof String) -+ sb.append('"').append(entry.getValue()).append('"'); -+ else -+ sb.append(entry.getValue()); -+ } -+ sb.append("]"); -+ -+ return sb.toString(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/AnnotationSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/AnnotationSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/AnnotationSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,395 +1,395 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.Serializable; --import java.lang.annotation.Annotation; --import java.lang.reflect.Field; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.lang.reflect.InvocationTargetException; --import java.util.ArrayList; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import com.caucho.hessian.HessianException; -- --/** -- * Serializing a Java annotation -- */ --public class AnnotationSerializer extends AbstractSerializer --{ -- private static final Logger log -- = Logger.getLogger(AnnotationSerializer.class.getName()); -- -- private static Object []NULL_ARGS = new Object[0]; -- -- private Class _annType; -- private Method []_methods; -- private MethodSerializer []_methodSerializers; -- -- public AnnotationSerializer(Class annType) -- { -- if (! Annotation.class.isAssignableFrom(annType)) { -- throw new IllegalStateException(annType.getName() + " is invalid because it is not a java.lang.annotation.Annotation"); -- } -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) { -- return; -- } -- -- init(((Annotation) obj).annotationType()); -- -- int ref = out.writeObjectBegin(_annType.getName()); -- -- if (ref < -1) { -- writeObject10(obj, out); -- } -- else { -- if (ref == -1) { -- writeDefinition20(out); -- out.writeObjectBegin(_annType.getName()); -- } -- -- writeInstance(obj, out); -- } -- } -- -- protected void writeObject10(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- for (int i = 0; i < _methods.length; i++) { -- Method method = _methods[i]; -- -- out.writeString(method.getName()); -- -- _methodSerializers[i].serialize(out, obj, method); -- } -- -- out.writeMapEnd(); -- } -- -- private void writeDefinition20(AbstractHessianOutput out) -- throws IOException -- { -- out.writeClassFieldLength(_methods.length); -- -- for (int i = 0; i < _methods.length; i++) { -- Method method = _methods[i]; -- -- out.writeString(method.getName()); -- } -- } -- -- public void writeInstance(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- for (int i = 0; i < _methods.length; i++) { -- Method method = _methods[i]; -- -- _methodSerializers[i].serialize(out, obj, method); -- } -- } -- -- -- private void init(Class cl) -- { -- synchronized (this) { -- if (_annType != null) -- return; -- -- _annType = cl; -- -- ArrayList methods = new ArrayList(); -- -- for (Method method : _annType.getDeclaredMethods()) { -- if (method.getName().equals("hashCode") -- || method.getName().equals("toString") -- || method.getName().equals("annotationType")) { -- continue; -- } -- -- if (method.getParameterTypes().length != 0) -- continue; -- -- methods.add(method); -- -- method.setAccessible(true); -- } -- -- if (_annType == null) -- throw new IllegalStateException(cl.getName() + " is invalid because it does not have a valid annotationType()"); -- -- _methods = new Method[methods.size()]; -- methods.toArray(_methods); -- -- _methodSerializers = new MethodSerializer[_methods.length]; -- -- for (int i = 0; i < _methods.length; i++) { -- _methodSerializers[i] = getMethodSerializer(_methods[i].getReturnType()); -- } -- } -- } -- -- private Class getAnnotationType(Class cl) -- { -- if (cl == null) -- return null; -- -- if (Annotation.class.equals(cl.getSuperclass())) -- return cl; -- -- Class ifaces[] = cl.getInterfaces(); -- -- if (ifaces != null) { -- for (Class iface : ifaces) { -- if (iface.equals(Annotation.class)) -- return cl; -- -- Class annType = getAnnotationType(iface); -- -- if (annType != null) -- return annType; -- } -- } -- -- return getAnnotationType(cl.getSuperclass()); -- } -- -- private static MethodSerializer getMethodSerializer(Class type) -- { -- if (int.class.equals(type) -- || byte.class.equals(type) -- || short.class.equals(type) -- || int.class.equals(type)) { -- return IntMethodSerializer.SER; -- } -- else if (long.class.equals(type)) { -- return LongMethodSerializer.SER; -- } -- else if (double.class.equals(type) || -- float.class.equals(type)) { -- return DoubleMethodSerializer.SER; -- } -- else if (boolean.class.equals(type)) { -- return BooleanMethodSerializer.SER; -- } -- else if (String.class.equals(type)) { -- return StringMethodSerializer.SER; -- } -- else if (java.util.Date.class.equals(type) -- || java.sql.Date.class.equals(type) -- || java.sql.Timestamp.class.equals(type) -- || java.sql.Time.class.equals(type)) { -- return DateMethodSerializer.SER; -- } -- else -- return MethodSerializer.SER; -- } -- -- static HessianException error(Method method, Throwable cause) -- { -- String msg = (method.getDeclaringClass().getSimpleName() -- + "." + method.getName() + "(): " + cause); -- -- throw new HessianMethodSerializationException(msg, cause); -- } -- -- static class MethodSerializer { -- static final MethodSerializer SER = new MethodSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Method method) -- throws IOException -- { -- Object value = null; -- -- try { -- value = method.invoke(obj); -- } catch (InvocationTargetException e) { -- throw error(method, e.getCause()); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- try { -- out.writeObject(value); -- } catch (Exception e) { -- throw error(method, e); -- } -- } -- } -- -- static class BooleanMethodSerializer extends MethodSerializer { -- static final MethodSerializer SER = new BooleanMethodSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Method method) -- throws IOException -- { -- boolean value = false; -- -- try { -- value = (Boolean) method.invoke(obj); -- } catch (InvocationTargetException e) { -- throw error(method, e.getCause()); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeBoolean(value); -- } -- } -- -- static class IntMethodSerializer extends MethodSerializer { -- static final MethodSerializer SER = new IntMethodSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Method method) -- throws IOException -- { -- int value = 0; -- -- try { -- value = (Integer) method.invoke(obj); -- } catch (InvocationTargetException e) { -- throw error(method, e.getCause()); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeInt(value); -- } -- } -- -- static class LongMethodSerializer extends MethodSerializer { -- static final MethodSerializer SER = new LongMethodSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Method method) -- throws IOException -- { -- long value = 0; -- -- try { -- value = (Long) method.invoke(obj); -- } catch (InvocationTargetException e) { -- throw error(method, e.getCause()); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeLong(value); -- } -- } -- -- static class DoubleMethodSerializer extends MethodSerializer { -- static final MethodSerializer SER = new DoubleMethodSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Method method) -- throws IOException -- { -- double value = 0; -- -- try { -- value = (Double) method.invoke(obj); -- } catch (InvocationTargetException e) { -- throw error(method, e.getCause()); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeDouble(value); -- } -- } -- -- static class StringMethodSerializer extends MethodSerializer { -- static final MethodSerializer SER = new StringMethodSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Method method) -- throws IOException -- { -- String value = null; -- -- try { -- value = (String) method.invoke(obj); -- } catch (InvocationTargetException e) { -- throw error(method, e.getCause()); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeString(value); -- } -- } -- -- static class DateMethodSerializer extends MethodSerializer { -- static final MethodSerializer SER = new DateMethodSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Method method) -- throws IOException -- { -- java.util.Date value = null; -- -- try { -- value = (java.util.Date) method.invoke(obj); -- } catch (InvocationTargetException e) { -- throw error(method, e.getCause()); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- if (value == null) -- out.writeNull(); -- else -- out.writeUTCDate(value.getTime()); -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.Serializable; -+import java.lang.annotation.Annotation; -+import java.lang.reflect.Field; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.lang.reflect.InvocationTargetException; -+import java.util.ArrayList; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Serializing a Java annotation -+ */ -+public class AnnotationSerializer extends AbstractSerializer -+{ -+ private static final Logger log -+ = Logger.getLogger(AnnotationSerializer.class.getName()); -+ -+ private static Object []NULL_ARGS = new Object[0]; -+ -+ private Class _annType; -+ private Method []_methods; -+ private MethodSerializer []_methodSerializers; -+ -+ public AnnotationSerializer(Class annType) -+ { -+ if (! Annotation.class.isAssignableFrom(annType)) { -+ throw new IllegalStateException(annType.getName() + " is invalid because it is not a java.lang.annotation.Annotation"); -+ } -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) { -+ return; -+ } -+ -+ init(((Annotation) obj).annotationType()); -+ -+ int ref = out.writeObjectBegin(_annType.getName()); -+ -+ if (ref < -1) { -+ writeObject10(obj, out); -+ } -+ else { -+ if (ref == -1) { -+ writeDefinition20(out); -+ out.writeObjectBegin(_annType.getName()); -+ } -+ -+ writeInstance(obj, out); -+ } -+ } -+ -+ protected void writeObject10(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ for (int i = 0; i < _methods.length; i++) { -+ Method method = _methods[i]; -+ -+ out.writeString(method.getName()); -+ -+ _methodSerializers[i].serialize(out, obj, method); -+ } -+ -+ out.writeMapEnd(); -+ } -+ -+ private void writeDefinition20(AbstractHessianOutput out) -+ throws IOException -+ { -+ out.writeClassFieldLength(_methods.length); -+ -+ for (int i = 0; i < _methods.length; i++) { -+ Method method = _methods[i]; -+ -+ out.writeString(method.getName()); -+ } -+ } -+ -+ public void writeInstance(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ for (int i = 0; i < _methods.length; i++) { -+ Method method = _methods[i]; -+ -+ _methodSerializers[i].serialize(out, obj, method); -+ } -+ } -+ -+ -+ private void init(Class cl) -+ { -+ synchronized (this) { -+ if (_annType != null) -+ return; -+ -+ _annType = cl; -+ -+ ArrayList methods = new ArrayList(); -+ -+ for (Method method : _annType.getDeclaredMethods()) { -+ if (method.getName().equals("hashCode") -+ || method.getName().equals("toString") -+ || method.getName().equals("annotationType")) { -+ continue; -+ } -+ -+ if (method.getParameterTypes().length != 0) -+ continue; -+ -+ methods.add(method); -+ -+ method.setAccessible(true); -+ } -+ -+ if (_annType == null) -+ throw new IllegalStateException(cl.getName() + " is invalid because it does not have a valid annotationType()"); -+ -+ _methods = new Method[methods.size()]; -+ methods.toArray(_methods); -+ -+ _methodSerializers = new MethodSerializer[_methods.length]; -+ -+ for (int i = 0; i < _methods.length; i++) { -+ _methodSerializers[i] = getMethodSerializer(_methods[i].getReturnType()); -+ } -+ } -+ } -+ -+ private Class getAnnotationType(Class cl) -+ { -+ if (cl == null) -+ return null; -+ -+ if (Annotation.class.equals(cl.getSuperclass())) -+ return cl; -+ -+ Class ifaces[] = cl.getInterfaces(); -+ -+ if (ifaces != null) { -+ for (Class iface : ifaces) { -+ if (iface.equals(Annotation.class)) -+ return cl; -+ -+ Class annType = getAnnotationType(iface); -+ -+ if (annType != null) -+ return annType; -+ } -+ } -+ -+ return getAnnotationType(cl.getSuperclass()); -+ } -+ -+ private static MethodSerializer getMethodSerializer(Class type) -+ { -+ if (int.class.equals(type) -+ || byte.class.equals(type) -+ || short.class.equals(type) -+ || int.class.equals(type)) { -+ return IntMethodSerializer.SER; -+ } -+ else if (long.class.equals(type)) { -+ return LongMethodSerializer.SER; -+ } -+ else if (double.class.equals(type) || -+ float.class.equals(type)) { -+ return DoubleMethodSerializer.SER; -+ } -+ else if (boolean.class.equals(type)) { -+ return BooleanMethodSerializer.SER; -+ } -+ else if (String.class.equals(type)) { -+ return StringMethodSerializer.SER; -+ } -+ else if (java.util.Date.class.equals(type) -+ || java.sql.Date.class.equals(type) -+ || java.sql.Timestamp.class.equals(type) -+ || java.sql.Time.class.equals(type)) { -+ return DateMethodSerializer.SER; -+ } -+ else -+ return MethodSerializer.SER; -+ } -+ -+ static HessianException error(Method method, Throwable cause) -+ { -+ String msg = (method.getDeclaringClass().getSimpleName() -+ + "." + method.getName() + "(): " + cause); -+ -+ throw new HessianMethodSerializationException(msg, cause); -+ } -+ -+ static class MethodSerializer { -+ static final MethodSerializer SER = new MethodSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Method method) -+ throws IOException -+ { -+ Object value = null; -+ -+ try { -+ value = method.invoke(obj); -+ } catch (InvocationTargetException e) { -+ throw error(method, e.getCause()); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ try { -+ out.writeObject(value); -+ } catch (Exception e) { -+ throw error(method, e); -+ } -+ } -+ } -+ -+ static class BooleanMethodSerializer extends MethodSerializer { -+ static final MethodSerializer SER = new BooleanMethodSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Method method) -+ throws IOException -+ { -+ boolean value = false; -+ -+ try { -+ value = (Boolean) method.invoke(obj); -+ } catch (InvocationTargetException e) { -+ throw error(method, e.getCause()); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeBoolean(value); -+ } -+ } -+ -+ static class IntMethodSerializer extends MethodSerializer { -+ static final MethodSerializer SER = new IntMethodSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Method method) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = (Integer) method.invoke(obj); -+ } catch (InvocationTargetException e) { -+ throw error(method, e.getCause()); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeInt(value); -+ } -+ } -+ -+ static class LongMethodSerializer extends MethodSerializer { -+ static final MethodSerializer SER = new LongMethodSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Method method) -+ throws IOException -+ { -+ long value = 0; -+ -+ try { -+ value = (Long) method.invoke(obj); -+ } catch (InvocationTargetException e) { -+ throw error(method, e.getCause()); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeLong(value); -+ } -+ } -+ -+ static class DoubleMethodSerializer extends MethodSerializer { -+ static final MethodSerializer SER = new DoubleMethodSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Method method) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = (Double) method.invoke(obj); -+ } catch (InvocationTargetException e) { -+ throw error(method, e.getCause()); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeDouble(value); -+ } -+ } -+ -+ static class StringMethodSerializer extends MethodSerializer { -+ static final MethodSerializer SER = new StringMethodSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Method method) -+ throws IOException -+ { -+ String value = null; -+ -+ try { -+ value = (String) method.invoke(obj); -+ } catch (InvocationTargetException e) { -+ throw error(method, e.getCause()); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeString(value); -+ } -+ } -+ -+ static class DateMethodSerializer extends MethodSerializer { -+ static final MethodSerializer SER = new DateMethodSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Method method) -+ throws IOException -+ { -+ java.util.Date value = null; -+ -+ try { -+ value = (java.util.Date) method.invoke(obj); -+ } catch (InvocationTargetException e) { -+ throw error(method, e.getCause()); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ if (value == null) -+ out.writeNull(); -+ else -+ out.writeUTCDate(value.getTime()); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ArrayDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ArrayDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ArrayDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ArrayDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,164 +1,164 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Array; --import java.util.ArrayList; -- --/** -- * Deserializing a Java array -- */ --public class ArrayDeserializer extends AbstractListDeserializer { -- private Class _componentType; -- private Class _type; -- -- public ArrayDeserializer(Class componentType) -- { -- _componentType = componentType; -- -- if (_componentType != null) { -- try { -- _type = Array.newInstance(_componentType, 0).getClass(); -- } catch (Exception e) { -- } -- } -- -- if (_type == null) -- _type = Object[].class; -- } -- -- public Class getType() -- { -- return _type; -- } -- -- /** -- * Reads the array. -- */ -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- if (length >= 0) { -- Object []data = createArray(length); -- -- in.addRef(data); -- -- if (_componentType != null) { -- for (int i = 0; i < data.length; i++) -- data[i] = in.readObject(_componentType); -- } -- else { -- for (int i = 0; i < data.length; i++) -- data[i] = in.readObject(); -- } -- -- in.readListEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- in.addRef(list); -- -- if (_componentType != null) { -- while (! in.isEnd()) -- list.add(in.readObject(_componentType)); -- } -- else { -- while (! in.isEnd()) -- list.add(in.readObject()); -- } -- -- in.readListEnd(); -- -- Object []data = createArray(list.size()); -- for (int i = 0; i < data.length; i++) -- data[i] = list.get(i); -- -- return data; -- } -- } -- -- /** -- * Reads the array. -- */ -- public Object readLengthList(AbstractHessianInput in, int length) -- throws IOException -- { -- Object []data = createArray(length); -- -- in.addRef(data); -- -- if (_componentType != null) { -- for (int i = 0; i < data.length; i++) -- data[i] = in.readObject(_componentType); -- } -- else { -- for (int i = 0; i < data.length; i++) -- data[i] = in.readObject(); -- } -- -- return data; -- } -- -- protected Object []createArray(int length) -- { -- if (_componentType != null) -- return (Object []) Array.newInstance(_componentType, length); -- else -- return new Object[length]; -- } -- -- public String toString() -- { -- return "ArrayDeserializer[" + _componentType + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Array; -+import java.util.ArrayList; -+ -+/** -+ * Deserializing a Java array -+ */ -+public class ArrayDeserializer extends AbstractListDeserializer { -+ private Class _componentType; -+ private Class _type; -+ -+ public ArrayDeserializer(Class componentType) -+ { -+ _componentType = componentType; -+ -+ if (_componentType != null) { -+ try { -+ _type = Array.newInstance(_componentType, 0).getClass(); -+ } catch (Exception e) { -+ } -+ } -+ -+ if (_type == null) -+ _type = Object[].class; -+ } -+ -+ public Class getType() -+ { -+ return _type; -+ } -+ -+ /** -+ * Reads the array. -+ */ -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ if (length >= 0) { -+ Object []data = createArray(length); -+ -+ in.addRef(data); -+ -+ if (_componentType != null) { -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readObject(_componentType); -+ } -+ else { -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readObject(); -+ } -+ -+ in.readListEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ in.addRef(list); -+ -+ if (_componentType != null) { -+ while (! in.isEnd()) -+ list.add(in.readObject(_componentType)); -+ } -+ else { -+ while (! in.isEnd()) -+ list.add(in.readObject()); -+ } -+ -+ in.readListEnd(); -+ -+ Object []data = createArray(list.size()); -+ for (int i = 0; i < data.length; i++) -+ data[i] = list.get(i); -+ -+ return data; -+ } -+ } -+ -+ /** -+ * Reads the array. -+ */ -+ public Object readLengthList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ Object []data = createArray(length); -+ -+ in.addRef(data); -+ -+ if (_componentType != null) { -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readObject(_componentType); -+ } -+ else { -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readObject(); -+ } -+ -+ return data; -+ } -+ -+ protected Object []createArray(int length) -+ { -+ if (_componentType != null) -+ return (Object []) Array.newInstance(_componentType, length); -+ else -+ return new Object[length]; -+ } -+ -+ public String toString() -+ { -+ return "ArrayDeserializer[" + _componentType + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ArraySerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ArraySerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ArraySerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ArraySerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,94 +1,94 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing a Java array. -- */ --public class ArraySerializer extends AbstractSerializer { -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) -- return; -- -- Object []array = (Object []) obj; -- -- boolean hasEnd = out.writeListBegin(array.length, -- getArrayType(obj.getClass())); -- -- for (int i = 0; i < array.length; i++) -- out.writeObject(array[i]); -- -- if (hasEnd) -- out.writeListEnd(); -- } -- -- /** -- * Returns the <type> name for a <list>. -- */ -- private String getArrayType(Class cl) -- { -- if (cl.isArray()) -- return '[' + getArrayType(cl.getComponentType()); -- -- String name = cl.getName(); -- -- if (name.equals("java.lang.String")) -- return "string"; -- else if (name.equals("java.lang.Object")) -- return "object"; -- else if (name.equals("java.util.Date")) -- return "date"; -- else -- return name; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing a Java array. -+ */ -+public class ArraySerializer extends AbstractSerializer { -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ Object []array = (Object []) obj; -+ -+ boolean hasEnd = out.writeListBegin(array.length, -+ getArrayType(obj.getClass())); -+ -+ for (int i = 0; i < array.length; i++) -+ out.writeObject(array[i]); -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ } -+ -+ /** -+ * Returns the <type> name for a <list>. -+ */ -+ private String getArrayType(Class cl) -+ { -+ if (cl.isArray()) -+ return '[' + getArrayType(cl.getComponentType()); -+ -+ String name = cl.getName(); -+ -+ if (name.equals("java.lang.String")) -+ return "string"; -+ else if (name.equals("java.lang.Object")) -+ return "object"; -+ else if (name.equals("java.util.Date")) -+ return "date"; -+ else -+ return name; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BasicDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BasicDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/BasicDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/BasicDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,615 +1,615 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.ArrayList; --import java.util.Date; -- --/** -- * Serializing an object for known object types. -- */ --public class BasicDeserializer extends AbstractDeserializer { -- public static final int NULL = BasicSerializer.NULL; -- public static final int BOOLEAN = BasicSerializer.BOOLEAN; -- public static final int BYTE = BasicSerializer.BYTE; -- public static final int SHORT = BasicSerializer.SHORT; -- public static final int INTEGER = BasicSerializer.INTEGER; -- public static final int LONG = BasicSerializer.LONG; -- public static final int FLOAT = BasicSerializer.FLOAT; -- public static final int DOUBLE = BasicSerializer.DOUBLE; -- public static final int CHARACTER = BasicSerializer.CHARACTER; -- public static final int CHARACTER_OBJECT = BasicSerializer.CHARACTER_OBJECT; -- public static final int STRING = BasicSerializer.STRING; -- public static final int DATE = BasicSerializer.DATE; -- public static final int NUMBER = BasicSerializer.NUMBER; -- public static final int OBJECT = BasicSerializer.OBJECT; -- -- public static final int BOOLEAN_ARRAY = BasicSerializer.BOOLEAN_ARRAY; -- public static final int BYTE_ARRAY = BasicSerializer.BYTE_ARRAY; -- public static final int SHORT_ARRAY = BasicSerializer.SHORT_ARRAY; -- public static final int INTEGER_ARRAY = BasicSerializer.INTEGER_ARRAY; -- public static final int LONG_ARRAY = BasicSerializer.LONG_ARRAY; -- public static final int FLOAT_ARRAY = BasicSerializer.FLOAT_ARRAY; -- public static final int DOUBLE_ARRAY = BasicSerializer.DOUBLE_ARRAY; -- public static final int CHARACTER_ARRAY = BasicSerializer.CHARACTER_ARRAY; -- public static final int STRING_ARRAY = BasicSerializer.STRING_ARRAY; -- public static final int OBJECT_ARRAY = BasicSerializer.OBJECT_ARRAY; -- -- private int _code; -- -- public BasicDeserializer(int code) -- { -- _code = code; -- } -- -- public Class getType() -- { -- switch (_code) { -- case NULL: -- return void.class; -- case BOOLEAN: -- return Boolean.class; -- case BYTE: -- return Byte.class; -- case SHORT: -- return Short.class; -- case INTEGER: -- return Integer.class; -- case LONG: -- return Long.class; -- case FLOAT: -- return Float.class; -- case DOUBLE: -- return Double.class; -- case CHARACTER: -- return Character.class; -- case CHARACTER_OBJECT: -- return Character.class; -- case STRING: -- return String.class; -- case DATE: -- return Date.class; -- case NUMBER: -- return Number.class; -- case OBJECT: -- return Object.class; -- -- case BOOLEAN_ARRAY: -- return boolean[].class; -- case BYTE_ARRAY: -- return byte[].class; -- case SHORT_ARRAY: -- return short[].class; -- case INTEGER_ARRAY: -- return int[].class; -- case LONG_ARRAY: -- return long[].class; -- case FLOAT_ARRAY: -- return float[].class; -- case DOUBLE_ARRAY: -- return double[].class; -- case CHARACTER_ARRAY: -- return char[].class; -- case STRING_ARRAY: -- return String[].class; -- case OBJECT_ARRAY: -- return Object[].class; -- default: -- throw new UnsupportedOperationException(); -- } -- } -- -- @Override -- public Object readObject(AbstractHessianInput in) -- throws IOException -- { -- switch (_code) { -- case NULL: -- // hessian/3490 -- in.readObject(); -- -- return null; -- -- case BOOLEAN: -- return Boolean.valueOf(in.readBoolean()); -- -- case BYTE: -- return Byte.valueOf((byte) in.readInt()); -- -- case SHORT: -- return Short.valueOf((short) in.readInt()); -- -- case INTEGER: -- return Integer.valueOf(in.readInt()); -- -- case LONG: -- return Long.valueOf(in.readLong()); -- -- case FLOAT: -- return Float.valueOf((float) in.readDouble()); -- -- case DOUBLE: -- return Double.valueOf(in.readDouble()); -- -- case STRING: -- return in.readString(); -- -- case OBJECT: -- return in.readObject(); -- -- case CHARACTER: -- { -- String s = in.readString(); -- if (s == null || s.equals("")) -- return Character.valueOf((char) 0); -- else -- return Character.valueOf(s.charAt(0)); -- } -- -- case CHARACTER_OBJECT: -- { -- String s = in.readString(); -- if (s == null || s.equals("")) -- return null; -- else -- return Character.valueOf(s.charAt(0)); -- } -- -- case DATE: -- return new Date(in.readUTCDate()); -- -- case NUMBER: -- return in.readObject(); -- -- case BYTE_ARRAY: -- return in.readBytes(); -- -- case CHARACTER_ARRAY: -- { -- String s = in.readString(); -- -- if (s == null) -- return null; -- else { -- int len = s.length(); -- char []chars = new char[len]; -- s.getChars(0, len, chars, 0); -- return chars; -- } -- } -- -- case BOOLEAN_ARRAY: -- case SHORT_ARRAY: -- case INTEGER_ARRAY: -- case LONG_ARRAY: -- case FLOAT_ARRAY: -- case DOUBLE_ARRAY: -- case STRING_ARRAY: -- { -- int code = in.readListStart(); -- -- switch (code) { -- case 'N': -- return null; -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- int length = code - 0x10; -- in.readInt(); -- -- return readLengthList(in, length); -- -- default: -- String type = in.readType(); -- length = in.readLength(); -- -- return readList(in, length); -- } -- } -- -- default: -- throw new UnsupportedOperationException(); -- } -- } -- -- @Override -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- switch (_code) { -- case BOOLEAN_ARRAY: { -- if (length >= 0) { -- boolean []data = new boolean[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readBoolean(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- while (! in.isEnd()) -- list.add(Boolean.valueOf(in.readBoolean())); -- -- in.readEnd(); -- -- boolean []data = new boolean[list.size()]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = ((Boolean) list.get(i)).booleanValue(); -- -- return data; -- } -- } -- -- case SHORT_ARRAY: { -- if (length >= 0) { -- short []data = new short[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = (short) in.readInt(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- while (! in.isEnd()) -- list.add(Short.valueOf((short) in.readInt())); -- -- in.readEnd(); -- -- short []data = new short[list.size()]; -- for (int i = 0; i < data.length; i++) -- data[i] = ((Short) list.get(i)).shortValue(); -- -- in.addRef(data); -- -- return data; -- } -- } -- -- case INTEGER_ARRAY: { -- if (length >= 0) { -- int []data = new int[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readInt(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- while (! in.isEnd()) -- list.add(Integer.valueOf(in.readInt())); -- -- -- in.readEnd(); -- -- int []data = new int[list.size()]; -- for (int i = 0; i < data.length; i++) -- data[i] = ((Integer) list.get(i)).intValue(); -- -- in.addRef(data); -- -- return data; -- } -- } -- -- case LONG_ARRAY: { -- if (length >= 0) { -- long []data = new long[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readLong(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- while (! in.isEnd()) -- list.add(Long.valueOf(in.readLong())); -- -- in.readEnd(); -- -- long []data = new long[list.size()]; -- for (int i = 0; i < data.length; i++) -- data[i] = ((Long) list.get(i)).longValue(); -- -- in.addRef(data); -- -- return data; -- } -- } -- -- case FLOAT_ARRAY: { -- if (length >= 0) { -- float []data = new float[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = (float) in.readDouble(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- while (! in.isEnd()) -- list.add(new Float(in.readDouble())); -- -- in.readEnd(); -- -- float []data = new float[list.size()]; -- for (int i = 0; i < data.length; i++) -- data[i] = ((Float) list.get(i)).floatValue(); -- -- in.addRef(data); -- -- return data; -- } -- } -- -- case DOUBLE_ARRAY: { -- if (length >= 0) { -- double []data = new double[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readDouble(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- while (! in.isEnd()) -- list.add(new Double(in.readDouble())); -- -- in.readEnd(); -- -- double []data = new double[list.size()]; -- in.addRef(data); -- for (int i = 0; i < data.length; i++) -- data[i] = ((Double) list.get(i)).doubleValue(); -- -- return data; -- } -- } -- -- case STRING_ARRAY: { -- if (length >= 0) { -- String []data = new String[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readString(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- while (! in.isEnd()) -- list.add(in.readString()); -- -- in.readEnd(); -- -- String []data = new String[list.size()]; -- in.addRef(data); -- for (int i = 0; i < data.length; i++) -- data[i] = (String) list.get(i); -- -- return data; -- } -- } -- -- case OBJECT_ARRAY: { -- if (length >= 0) { -- Object []data = new Object[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readObject(); -- -- in.readEnd(); -- -- return data; -- } -- else { -- ArrayList list = new ArrayList(); -- -- in.addRef(list); // XXX: potential issues here -- -- while (! in.isEnd()) -- list.add(in.readObject()); -- -- in.readEnd(); -- -- Object []data = new Object[list.size()]; -- for (int i = 0; i < data.length; i++) -- data[i] = (Object) list.get(i); -- -- return data; -- } -- } -- -- default: -- throw new UnsupportedOperationException(String.valueOf(this)); -- } -- } -- -- public Object readLengthList(AbstractHessianInput in, int length) -- throws IOException -- { -- switch (_code) { -- case BOOLEAN_ARRAY: { -- boolean []data = new boolean[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readBoolean(); -- -- return data; -- } -- -- case SHORT_ARRAY: { -- short []data = new short[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = (short) in.readInt(); -- -- return data; -- } -- -- case INTEGER_ARRAY: { -- int []data = new int[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readInt(); -- -- return data; -- } -- -- case LONG_ARRAY: { -- long []data = new long[length]; -- -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readLong(); -- -- return data; -- } -- -- case FLOAT_ARRAY: { -- float []data = new float[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = (float) in.readDouble(); -- -- return data; -- } -- -- case DOUBLE_ARRAY: { -- double []data = new double[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readDouble(); -- -- return data; -- } -- -- case STRING_ARRAY: { -- String []data = new String[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readString(); -- -- return data; -- } -- -- case OBJECT_ARRAY: { -- Object []data = new Object[length]; -- in.addRef(data); -- -- for (int i = 0; i < data.length; i++) -- data[i] = in.readObject(); -- -- return data; -- } -- -- default: -- throw new UnsupportedOperationException(String.valueOf(this)); -- } -- } -- -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _code + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.ArrayList; -+import java.util.Date; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class BasicDeserializer extends AbstractDeserializer { -+ public static final int NULL = BasicSerializer.NULL; -+ public static final int BOOLEAN = BasicSerializer.BOOLEAN; -+ public static final int BYTE = BasicSerializer.BYTE; -+ public static final int SHORT = BasicSerializer.SHORT; -+ public static final int INTEGER = BasicSerializer.INTEGER; -+ public static final int LONG = BasicSerializer.LONG; -+ public static final int FLOAT = BasicSerializer.FLOAT; -+ public static final int DOUBLE = BasicSerializer.DOUBLE; -+ public static final int CHARACTER = BasicSerializer.CHARACTER; -+ public static final int CHARACTER_OBJECT = BasicSerializer.CHARACTER_OBJECT; -+ public static final int STRING = BasicSerializer.STRING; -+ public static final int DATE = BasicSerializer.DATE; -+ public static final int NUMBER = BasicSerializer.NUMBER; -+ public static final int OBJECT = BasicSerializer.OBJECT; -+ -+ public static final int BOOLEAN_ARRAY = BasicSerializer.BOOLEAN_ARRAY; -+ public static final int BYTE_ARRAY = BasicSerializer.BYTE_ARRAY; -+ public static final int SHORT_ARRAY = BasicSerializer.SHORT_ARRAY; -+ public static final int INTEGER_ARRAY = BasicSerializer.INTEGER_ARRAY; -+ public static final int LONG_ARRAY = BasicSerializer.LONG_ARRAY; -+ public static final int FLOAT_ARRAY = BasicSerializer.FLOAT_ARRAY; -+ public static final int DOUBLE_ARRAY = BasicSerializer.DOUBLE_ARRAY; -+ public static final int CHARACTER_ARRAY = BasicSerializer.CHARACTER_ARRAY; -+ public static final int STRING_ARRAY = BasicSerializer.STRING_ARRAY; -+ public static final int OBJECT_ARRAY = BasicSerializer.OBJECT_ARRAY; -+ -+ private int _code; -+ -+ public BasicDeserializer(int code) -+ { -+ _code = code; -+ } -+ -+ public Class getType() -+ { -+ switch (_code) { -+ case NULL: -+ return void.class; -+ case BOOLEAN: -+ return Boolean.class; -+ case BYTE: -+ return Byte.class; -+ case SHORT: -+ return Short.class; -+ case INTEGER: -+ return Integer.class; -+ case LONG: -+ return Long.class; -+ case FLOAT: -+ return Float.class; -+ case DOUBLE: -+ return Double.class; -+ case CHARACTER: -+ return Character.class; -+ case CHARACTER_OBJECT: -+ return Character.class; -+ case STRING: -+ return String.class; -+ case DATE: -+ return Date.class; -+ case NUMBER: -+ return Number.class; -+ case OBJECT: -+ return Object.class; -+ -+ case BOOLEAN_ARRAY: -+ return boolean[].class; -+ case BYTE_ARRAY: -+ return byte[].class; -+ case SHORT_ARRAY: -+ return short[].class; -+ case INTEGER_ARRAY: -+ return int[].class; -+ case LONG_ARRAY: -+ return long[].class; -+ case FLOAT_ARRAY: -+ return float[].class; -+ case DOUBLE_ARRAY: -+ return double[].class; -+ case CHARACTER_ARRAY: -+ return char[].class; -+ case STRING_ARRAY: -+ return String[].class; -+ case OBJECT_ARRAY: -+ return Object[].class; -+ default: -+ throw new UnsupportedOperationException(); -+ } -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in) -+ throws IOException -+ { -+ switch (_code) { -+ case NULL: -+ // hessian/3490 -+ in.readObject(); -+ -+ return null; -+ -+ case BOOLEAN: -+ return Boolean.valueOf(in.readBoolean()); -+ -+ case BYTE: -+ return Byte.valueOf((byte) in.readInt()); -+ -+ case SHORT: -+ return Short.valueOf((short) in.readInt()); -+ -+ case INTEGER: -+ return Integer.valueOf(in.readInt()); -+ -+ case LONG: -+ return Long.valueOf(in.readLong()); -+ -+ case FLOAT: -+ return Float.valueOf((float) in.readDouble()); -+ -+ case DOUBLE: -+ return Double.valueOf(in.readDouble()); -+ -+ case STRING: -+ return in.readString(); -+ -+ case OBJECT: -+ return in.readObject(); -+ -+ case CHARACTER: -+ { -+ String s = in.readString(); -+ if (s == null || s.equals("")) -+ return Character.valueOf((char) 0); -+ else -+ return Character.valueOf(s.charAt(0)); -+ } -+ -+ case CHARACTER_OBJECT: -+ { -+ String s = in.readString(); -+ if (s == null || s.equals("")) -+ return null; -+ else -+ return Character.valueOf(s.charAt(0)); -+ } -+ -+ case DATE: -+ return new Date(in.readUTCDate()); -+ -+ case NUMBER: -+ return in.readObject(); -+ -+ case BYTE_ARRAY: -+ return in.readBytes(); -+ -+ case CHARACTER_ARRAY: -+ { -+ String s = in.readString(); -+ -+ if (s == null) -+ return null; -+ else { -+ int len = s.length(); -+ char []chars = new char[len]; -+ s.getChars(0, len, chars, 0); -+ return chars; -+ } -+ } -+ -+ case BOOLEAN_ARRAY: -+ case SHORT_ARRAY: -+ case INTEGER_ARRAY: -+ case LONG_ARRAY: -+ case FLOAT_ARRAY: -+ case DOUBLE_ARRAY: -+ case STRING_ARRAY: -+ { -+ int code = in.readListStart(); -+ -+ switch (code) { -+ case 'N': -+ return null; -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ int length = code - 0x10; -+ in.readInt(); -+ -+ return readLengthList(in, length); -+ -+ default: -+ String type = in.readType(); -+ length = in.readLength(); -+ -+ return readList(in, length); -+ } -+ } -+ -+ default: -+ throw new UnsupportedOperationException(); -+ } -+ } -+ -+ @Override -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ switch (_code) { -+ case BOOLEAN_ARRAY: { -+ if (length >= 0) { -+ boolean []data = new boolean[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readBoolean(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ while (! in.isEnd()) -+ list.add(Boolean.valueOf(in.readBoolean())); -+ -+ in.readEnd(); -+ -+ boolean []data = new boolean[list.size()]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = ((Boolean) list.get(i)).booleanValue(); -+ -+ return data; -+ } -+ } -+ -+ case SHORT_ARRAY: { -+ if (length >= 0) { -+ short []data = new short[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = (short) in.readInt(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ while (! in.isEnd()) -+ list.add(Short.valueOf((short) in.readInt())); -+ -+ in.readEnd(); -+ -+ short []data = new short[list.size()]; -+ for (int i = 0; i < data.length; i++) -+ data[i] = ((Short) list.get(i)).shortValue(); -+ -+ in.addRef(data); -+ -+ return data; -+ } -+ } -+ -+ case INTEGER_ARRAY: { -+ if (length >= 0) { -+ int []data = new int[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readInt(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ while (! in.isEnd()) -+ list.add(Integer.valueOf(in.readInt())); -+ -+ -+ in.readEnd(); -+ -+ int []data = new int[list.size()]; -+ for (int i = 0; i < data.length; i++) -+ data[i] = ((Integer) list.get(i)).intValue(); -+ -+ in.addRef(data); -+ -+ return data; -+ } -+ } -+ -+ case LONG_ARRAY: { -+ if (length >= 0) { -+ long []data = new long[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readLong(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ while (! in.isEnd()) -+ list.add(Long.valueOf(in.readLong())); -+ -+ in.readEnd(); -+ -+ long []data = new long[list.size()]; -+ for (int i = 0; i < data.length; i++) -+ data[i] = ((Long) list.get(i)).longValue(); -+ -+ in.addRef(data); -+ -+ return data; -+ } -+ } -+ -+ case FLOAT_ARRAY: { -+ if (length >= 0) { -+ float []data = new float[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = (float) in.readDouble(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ while (! in.isEnd()) -+ list.add(new Float(in.readDouble())); -+ -+ in.readEnd(); -+ -+ float []data = new float[list.size()]; -+ for (int i = 0; i < data.length; i++) -+ data[i] = ((Float) list.get(i)).floatValue(); -+ -+ in.addRef(data); -+ -+ return data; -+ } -+ } -+ -+ case DOUBLE_ARRAY: { -+ if (length >= 0) { -+ double []data = new double[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readDouble(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ while (! in.isEnd()) -+ list.add(new Double(in.readDouble())); -+ -+ in.readEnd(); -+ -+ double []data = new double[list.size()]; -+ in.addRef(data); -+ for (int i = 0; i < data.length; i++) -+ data[i] = ((Double) list.get(i)).doubleValue(); -+ -+ return data; -+ } -+ } -+ -+ case STRING_ARRAY: { -+ if (length >= 0) { -+ String []data = new String[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readString(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ while (! in.isEnd()) -+ list.add(in.readString()); -+ -+ in.readEnd(); -+ -+ String []data = new String[list.size()]; -+ in.addRef(data); -+ for (int i = 0; i < data.length; i++) -+ data[i] = (String) list.get(i); -+ -+ return data; -+ } -+ } -+ -+ case OBJECT_ARRAY: { -+ if (length >= 0) { -+ Object []data = new Object[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readObject(); -+ -+ in.readEnd(); -+ -+ return data; -+ } -+ else { -+ ArrayList list = new ArrayList(); -+ -+ in.addRef(list); // XXX: potential issues here -+ -+ while (! in.isEnd()) -+ list.add(in.readObject()); -+ -+ in.readEnd(); -+ -+ Object []data = new Object[list.size()]; -+ for (int i = 0; i < data.length; i++) -+ data[i] = (Object) list.get(i); -+ -+ return data; -+ } -+ } -+ -+ default: -+ throw new UnsupportedOperationException(String.valueOf(this)); -+ } -+ } -+ -+ public Object readLengthList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ switch (_code) { -+ case BOOLEAN_ARRAY: { -+ boolean []data = new boolean[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readBoolean(); -+ -+ return data; -+ } -+ -+ case SHORT_ARRAY: { -+ short []data = new short[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = (short) in.readInt(); -+ -+ return data; -+ } -+ -+ case INTEGER_ARRAY: { -+ int []data = new int[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readInt(); -+ -+ return data; -+ } -+ -+ case LONG_ARRAY: { -+ long []data = new long[length]; -+ -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readLong(); -+ -+ return data; -+ } -+ -+ case FLOAT_ARRAY: { -+ float []data = new float[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = (float) in.readDouble(); -+ -+ return data; -+ } -+ -+ case DOUBLE_ARRAY: { -+ double []data = new double[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readDouble(); -+ -+ return data; -+ } -+ -+ case STRING_ARRAY: { -+ String []data = new String[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readString(); -+ -+ return data; -+ } -+ -+ case OBJECT_ARRAY: { -+ Object []data = new Object[length]; -+ in.addRef(data); -+ -+ for (int i = 0; i < data.length; i++) -+ data[i] = in.readObject(); -+ -+ return data; -+ } -+ -+ default: -+ throw new UnsupportedOperationException(String.valueOf(this)); -+ } -+ } -+ -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _code + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BasicSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BasicSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/BasicSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/BasicSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,335 +1,335 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.Date; -- --/** -- * Serializing an object for known object types. -- */ --public class BasicSerializer extends AbstractSerializer -- implements ObjectSerializer --{ -- public static final int NULL = 0; -- public static final int BOOLEAN = NULL + 1; -- public static final int BYTE = BOOLEAN + 1; -- public static final int SHORT = BYTE + 1; -- public static final int INTEGER = SHORT + 1; -- public static final int LONG = INTEGER + 1; -- public static final int FLOAT = LONG + 1; -- public static final int DOUBLE = FLOAT + 1; -- public static final int CHARACTER = DOUBLE + 1; -- public static final int CHARACTER_OBJECT = CHARACTER + 1; -- public static final int STRING = CHARACTER_OBJECT + 1; -- public static final int STRING_BUILDER = STRING + 1; -- public static final int DATE = STRING_BUILDER + 1; -- public static final int NUMBER = DATE + 1; -- public static final int OBJECT = NUMBER + 1; -- -- public static final int BOOLEAN_ARRAY = OBJECT + 1; -- public static final int BYTE_ARRAY = BOOLEAN_ARRAY + 1; -- public static final int SHORT_ARRAY = BYTE_ARRAY + 1; -- public static final int INTEGER_ARRAY = SHORT_ARRAY + 1; -- public static final int LONG_ARRAY = INTEGER_ARRAY + 1; -- public static final int FLOAT_ARRAY = LONG_ARRAY + 1; -- public static final int DOUBLE_ARRAY = FLOAT_ARRAY + 1; -- public static final int CHARACTER_ARRAY = DOUBLE_ARRAY + 1; -- public static final int STRING_ARRAY = CHARACTER_ARRAY + 1; -- public static final int OBJECT_ARRAY = STRING_ARRAY + 1; -- -- public static final int BYTE_HANDLE = OBJECT_ARRAY + 1; -- public static final int SHORT_HANDLE = BYTE_HANDLE + 1; -- public static final int FLOAT_HANDLE = SHORT_HANDLE + 1; -- -- private static final BasicSerializer BYTE_HANDLE_SERIALIZER -- = new BasicSerializer(BYTE_HANDLE); -- -- private static final BasicSerializer SHORT_HANDLE_SERIALIZER -- = new BasicSerializer(SHORT_HANDLE); -- -- private static final BasicSerializer FLOAT_HANDLE_SERIALIZER -- = new BasicSerializer(FLOAT_HANDLE); -- -- private int _code; -- -- public BasicSerializer(int code) -- { -- _code = code; -- } -- -- public Serializer getObjectSerializer() -- { -- switch (_code) { -- case BYTE: -- return BYTE_HANDLE_SERIALIZER; -- case SHORT: -- return SHORT_HANDLE_SERIALIZER; -- case FLOAT: -- return FLOAT_HANDLE_SERIALIZER; -- default: -- return this; -- } -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- switch (_code) { -- case BOOLEAN: -- out.writeBoolean(((Boolean) obj).booleanValue()); -- break; -- -- case BYTE: -- case SHORT: -- case INTEGER: -- out.writeInt(((Number) obj).intValue()); -- break; -- -- case LONG: -- out.writeLong(((Number) obj).longValue()); -- break; -- -- case FLOAT: -- case DOUBLE: -- out.writeDouble(((Number) obj).doubleValue()); -- break; -- -- case CHARACTER: -- case CHARACTER_OBJECT: -- out.writeString(String.valueOf(obj)); -- break; -- -- case STRING: -- out.writeString((String) obj); -- break; -- -- case STRING_BUILDER: -- out.writeString(((StringBuilder) obj).toString()); -- break; -- -- case DATE: -- out.writeUTCDate(((Date) obj).getTime()); -- break; -- -- case BOOLEAN_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- boolean []data = (boolean []) obj; -- boolean hasEnd = out.writeListBegin(data.length, "[boolean"); -- for (int i = 0; i < data.length; i++) -- out.writeBoolean(data[i]); -- -- if (hasEnd) -- out.writeListEnd(); -- -- break; -- } -- -- case BYTE_ARRAY: -- { -- byte []data = (byte []) obj; -- out.writeBytes(data, 0, data.length); -- break; -- } -- -- case SHORT_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- short []data = (short []) obj; -- boolean hasEnd = out.writeListBegin(data.length, "[short"); -- -- for (int i = 0; i < data.length; i++) -- out.writeInt(data[i]); -- -- if (hasEnd) -- out.writeListEnd(); -- break; -- } -- -- case INTEGER_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- int []data = (int []) obj; -- -- boolean hasEnd = out.writeListBegin(data.length, "[int"); -- -- for (int i = 0; i < data.length; i++) -- out.writeInt(data[i]); -- -- if (hasEnd) -- out.writeListEnd(); -- -- break; -- } -- -- case LONG_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- long []data = (long []) obj; -- -- boolean hasEnd = out.writeListBegin(data.length, "[long"); -- -- for (int i = 0; i < data.length; i++) -- out.writeLong(data[i]); -- -- if (hasEnd) -- out.writeListEnd(); -- break; -- } -- -- case FLOAT_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- float []data = (float []) obj; -- -- boolean hasEnd = out.writeListBegin(data.length, "[float"); -- -- for (int i = 0; i < data.length; i++) -- out.writeDouble(data[i]); -- -- if (hasEnd) -- out.writeListEnd(); -- break; -- } -- -- case DOUBLE_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- double []data = (double []) obj; -- boolean hasEnd = out.writeListBegin(data.length, "[double"); -- -- for (int i = 0; i < data.length; i++) -- out.writeDouble(data[i]); -- -- if (hasEnd) -- out.writeListEnd(); -- break; -- } -- -- case STRING_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- String []data = (String []) obj; -- -- boolean hasEnd = out.writeListBegin(data.length, "[string"); -- -- for (int i = 0; i < data.length; i++) { -- out.writeString(data[i]); -- } -- -- if (hasEnd) -- out.writeListEnd(); -- break; -- } -- -- case CHARACTER_ARRAY: -- { -- char []data = (char []) obj; -- out.writeString(data, 0, data.length); -- break; -- } -- -- case OBJECT_ARRAY: -- { -- if (out.addRef(obj)) -- return; -- -- Object []data = (Object []) obj; -- -- boolean hasEnd = out.writeListBegin(data.length, "[object"); -- -- for (int i = 0; i < data.length; i++) { -- out.writeObject(data[i]); -- } -- -- if (hasEnd) -- out.writeListEnd(); -- break; -- } -- -- case NULL: -- out.writeNull(); -- break; -- -- case OBJECT: -- ObjectHandleSerializer.SER.writeObject(obj, out); -- break; -- -- case BYTE_HANDLE: -- out.writeObject(new ByteHandle((Byte) obj)); -- break; -- -- case SHORT_HANDLE: -- out.writeObject(new ShortHandle((Short) obj)); -- break; -- -- case FLOAT_HANDLE: -- out.writeObject(new FloatHandle((Float) obj)); -- break; -- -- default: -- throw new RuntimeException(_code + " unknown code for " + obj.getClass()); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.Date; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class BasicSerializer extends AbstractSerializer -+ implements ObjectSerializer -+{ -+ public static final int NULL = 0; -+ public static final int BOOLEAN = NULL + 1; -+ public static final int BYTE = BOOLEAN + 1; -+ public static final int SHORT = BYTE + 1; -+ public static final int INTEGER = SHORT + 1; -+ public static final int LONG = INTEGER + 1; -+ public static final int FLOAT = LONG + 1; -+ public static final int DOUBLE = FLOAT + 1; -+ public static final int CHARACTER = DOUBLE + 1; -+ public static final int CHARACTER_OBJECT = CHARACTER + 1; -+ public static final int STRING = CHARACTER_OBJECT + 1; -+ public static final int STRING_BUILDER = STRING + 1; -+ public static final int DATE = STRING_BUILDER + 1; -+ public static final int NUMBER = DATE + 1; -+ public static final int OBJECT = NUMBER + 1; -+ -+ public static final int BOOLEAN_ARRAY = OBJECT + 1; -+ public static final int BYTE_ARRAY = BOOLEAN_ARRAY + 1; -+ public static final int SHORT_ARRAY = BYTE_ARRAY + 1; -+ public static final int INTEGER_ARRAY = SHORT_ARRAY + 1; -+ public static final int LONG_ARRAY = INTEGER_ARRAY + 1; -+ public static final int FLOAT_ARRAY = LONG_ARRAY + 1; -+ public static final int DOUBLE_ARRAY = FLOAT_ARRAY + 1; -+ public static final int CHARACTER_ARRAY = DOUBLE_ARRAY + 1; -+ public static final int STRING_ARRAY = CHARACTER_ARRAY + 1; -+ public static final int OBJECT_ARRAY = STRING_ARRAY + 1; -+ -+ public static final int BYTE_HANDLE = OBJECT_ARRAY + 1; -+ public static final int SHORT_HANDLE = BYTE_HANDLE + 1; -+ public static final int FLOAT_HANDLE = SHORT_HANDLE + 1; -+ -+ private static final BasicSerializer BYTE_HANDLE_SERIALIZER -+ = new BasicSerializer(BYTE_HANDLE); -+ -+ private static final BasicSerializer SHORT_HANDLE_SERIALIZER -+ = new BasicSerializer(SHORT_HANDLE); -+ -+ private static final BasicSerializer FLOAT_HANDLE_SERIALIZER -+ = new BasicSerializer(FLOAT_HANDLE); -+ -+ private int _code; -+ -+ public BasicSerializer(int code) -+ { -+ _code = code; -+ } -+ -+ public Serializer getObjectSerializer() -+ { -+ switch (_code) { -+ case BYTE: -+ return BYTE_HANDLE_SERIALIZER; -+ case SHORT: -+ return SHORT_HANDLE_SERIALIZER; -+ case FLOAT: -+ return FLOAT_HANDLE_SERIALIZER; -+ default: -+ return this; -+ } -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ switch (_code) { -+ case BOOLEAN: -+ out.writeBoolean(((Boolean) obj).booleanValue()); -+ break; -+ -+ case BYTE: -+ case SHORT: -+ case INTEGER: -+ out.writeInt(((Number) obj).intValue()); -+ break; -+ -+ case LONG: -+ out.writeLong(((Number) obj).longValue()); -+ break; -+ -+ case FLOAT: -+ case DOUBLE: -+ out.writeDouble(((Number) obj).doubleValue()); -+ break; -+ -+ case CHARACTER: -+ case CHARACTER_OBJECT: -+ out.writeString(String.valueOf(obj)); -+ break; -+ -+ case STRING: -+ out.writeString((String) obj); -+ break; -+ -+ case STRING_BUILDER: -+ out.writeString(((StringBuilder) obj).toString()); -+ break; -+ -+ case DATE: -+ out.writeUTCDate(((Date) obj).getTime()); -+ break; -+ -+ case BOOLEAN_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ boolean []data = (boolean []) obj; -+ boolean hasEnd = out.writeListBegin(data.length, "[boolean"); -+ for (int i = 0; i < data.length; i++) -+ out.writeBoolean(data[i]); -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ -+ break; -+ } -+ -+ case BYTE_ARRAY: -+ { -+ byte []data = (byte []) obj; -+ out.writeBytes(data, 0, data.length); -+ break; -+ } -+ -+ case SHORT_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ short []data = (short []) obj; -+ boolean hasEnd = out.writeListBegin(data.length, "[short"); -+ -+ for (int i = 0; i < data.length; i++) -+ out.writeInt(data[i]); -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ break; -+ } -+ -+ case INTEGER_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ int []data = (int []) obj; -+ -+ boolean hasEnd = out.writeListBegin(data.length, "[int"); -+ -+ for (int i = 0; i < data.length; i++) -+ out.writeInt(data[i]); -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ -+ break; -+ } -+ -+ case LONG_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ long []data = (long []) obj; -+ -+ boolean hasEnd = out.writeListBegin(data.length, "[long"); -+ -+ for (int i = 0; i < data.length; i++) -+ out.writeLong(data[i]); -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ break; -+ } -+ -+ case FLOAT_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ float []data = (float []) obj; -+ -+ boolean hasEnd = out.writeListBegin(data.length, "[float"); -+ -+ for (int i = 0; i < data.length; i++) -+ out.writeDouble(data[i]); -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ break; -+ } -+ -+ case DOUBLE_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ double []data = (double []) obj; -+ boolean hasEnd = out.writeListBegin(data.length, "[double"); -+ -+ for (int i = 0; i < data.length; i++) -+ out.writeDouble(data[i]); -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ break; -+ } -+ -+ case STRING_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ String []data = (String []) obj; -+ -+ boolean hasEnd = out.writeListBegin(data.length, "[string"); -+ -+ for (int i = 0; i < data.length; i++) { -+ out.writeString(data[i]); -+ } -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ break; -+ } -+ -+ case CHARACTER_ARRAY: -+ { -+ char []data = (char []) obj; -+ out.writeString(data, 0, data.length); -+ break; -+ } -+ -+ case OBJECT_ARRAY: -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ Object []data = (Object []) obj; -+ -+ boolean hasEnd = out.writeListBegin(data.length, "[object"); -+ -+ for (int i = 0; i < data.length; i++) { -+ out.writeObject(data[i]); -+ } -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ break; -+ } -+ -+ case NULL: -+ out.writeNull(); -+ break; -+ -+ case OBJECT: -+ ObjectHandleSerializer.SER.writeObject(obj, out); -+ break; -+ -+ case BYTE_HANDLE: -+ out.writeObject(new ByteHandle((Byte) obj)); -+ break; -+ -+ case SHORT_HANDLE: -+ out.writeObject(new ShortHandle((Short) obj)); -+ break; -+ -+ case FLOAT_HANDLE: -+ out.writeObject(new FloatHandle((Float) obj)); -+ break; -+ -+ default: -+ throw new RuntimeException(_code + " unknown code for " + obj.getClass()); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BeanDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BeanDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/BeanDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/BeanDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,296 +1,296 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Constructor; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.HashMap; --import java.util.Locale; -- --/** -- * Serializing an object for known object types. -- */ --public class BeanDeserializer extends AbstractMapDeserializer { -- private Class _type; -- private HashMap _methodMap; -- private Method _readResolve; -- private Constructor _constructor; -- private Object []_constructorArgs; -- -- public BeanDeserializer(Class cl) -- { -- _type = cl; -- _methodMap = getMethodMap(cl); -- -- _readResolve = getReadResolve(cl); -- -- Constructor []constructors = cl.getConstructors(); -- int bestLength = Integer.MAX_VALUE; -- -- for (int i = 0; i < constructors.length; i++) { -- if (constructors[i].getParameterTypes().length < bestLength) { -- _constructor = constructors[i]; -- bestLength = _constructor.getParameterTypes().length; -- } -- } -- -- if (_constructor != null) { -- _constructor.setAccessible(true); -- Class []params = _constructor.getParameterTypes(); -- _constructorArgs = new Object[params.length]; -- for (int i = 0; i < params.length; i++) { -- _constructorArgs[i] = getParamArg(params[i]); -- } -- } -- } -- -- public Class getType() -- { -- return _type; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- try { -- Object obj = instantiate(); -- -- return readMap(in, obj); -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- public Object readMap(AbstractHessianInput in, Object obj) -- throws IOException -- { -- try { -- int ref = in.addRef(obj); -- -- while (! in.isEnd()) { -- Object key = in.readObject(); -- -- Method method = (Method) _methodMap.get(key); -- -- if (method != null) { -- Object value = in.readObject(method.getParameterTypes()[0]); -- -- method.invoke(obj, new Object[] {value }); -- } -- else { -- Object value = in.readObject(); -- } -- } -- -- in.readMapEnd(); -- -- Object resolve = resolve(obj); -- -- if (obj != resolve) -- in.setRef(ref, resolve); -- -- return resolve; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- private Object resolve(Object obj) -- { -- // if there's a readResolve method, call it -- try { -- if (_readResolve != null) -- return _readResolve.invoke(obj, new Object[0]); -- } catch (Exception e) { -- } -- -- return obj; -- } -- -- protected Object instantiate() -- throws Exception -- { -- return _constructor.newInstance(_constructorArgs); -- } -- -- /** -- * Returns the readResolve method -- */ -- protected Method getReadResolve(Class cl) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (method.getName().equals("readResolve") && -- method.getParameterTypes().length == 0) -- return method; -- } -- } -- -- return null; -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- protected HashMap getMethodMap(Class cl) -- { -- HashMap methodMap = new HashMap(); -- -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (Modifier.isStatic(method.getModifiers())) -- continue; -- -- String name = method.getName(); -- -- if (! name.startsWith("set")) -- continue; -- -- Class []paramTypes = method.getParameterTypes(); -- if (paramTypes.length != 1) -- continue; -- -- if (! method.getReturnType().equals(void.class)) -- continue; -- -- if (findGetter(methods, name, paramTypes[0]) == null) -- continue; -- -- // XXX: could parameterize the handler to only deal with public -- try { -- method.setAccessible(true); -- } catch (Throwable e) { -- e.printStackTrace(); -- } -- -- name = name.substring(3); -- -- int j = 0; -- for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { -- } -- -- if (j == 1) -- name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); -- else if (j > 1) -- name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); -- -- -- methodMap.put(name, method); -- } -- } -- -- return methodMap; -- } -- -- /** -- * Finds any matching setter. -- */ -- private Method findGetter(Method []methods, String setterName, Class arg) -- { -- String getterName = "get" + setterName.substring(3); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (! method.getName().equals(getterName)) -- continue; -- -- if (! method.getReturnType().equals(arg)) -- continue; -- -- Class []params = method.getParameterTypes(); -- -- if (params.length == 0) -- return method; -- } -- -- return null; -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- protected static Object getParamArg(Class cl) -- { -- if (! cl.isPrimitive()) -- return null; -- else if (boolean.class.equals(cl)) -- return Boolean.FALSE; -- else if (byte.class.equals(cl)) -- return Byte.valueOf((byte) 0); -- else if (short.class.equals(cl)) -- return Short.valueOf((short) 0); -- else if (char.class.equals(cl)) -- return Character.valueOf((char) 0); -- else if (int.class.equals(cl)) -- return Integer.valueOf(0); -- else if (long.class.equals(cl)) -- return Long.valueOf(0); -- else if (float.class.equals(cl)) -- return Double.valueOf(0); -- else if (double.class.equals(cl)) -- return Double.valueOf(0); -- else -- throw new UnsupportedOperationException(); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Constructor; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.HashMap; -+import java.util.Locale; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class BeanDeserializer extends AbstractMapDeserializer { -+ private Class _type; -+ private HashMap _methodMap; -+ private Method _readResolve; -+ private Constructor _constructor; -+ private Object []_constructorArgs; -+ -+ public BeanDeserializer(Class cl) -+ { -+ _type = cl; -+ _methodMap = getMethodMap(cl); -+ -+ _readResolve = getReadResolve(cl); -+ -+ Constructor []constructors = cl.getConstructors(); -+ int bestLength = Integer.MAX_VALUE; -+ -+ for (int i = 0; i < constructors.length; i++) { -+ if (constructors[i].getParameterTypes().length < bestLength) { -+ _constructor = constructors[i]; -+ bestLength = _constructor.getParameterTypes().length; -+ } -+ } -+ -+ if (_constructor != null) { -+ _constructor.setAccessible(true); -+ Class []params = _constructor.getParameterTypes(); -+ _constructorArgs = new Object[params.length]; -+ for (int i = 0; i < params.length; i++) { -+ _constructorArgs[i] = getParamArg(params[i]); -+ } -+ } -+ } -+ -+ public Class getType() -+ { -+ return _type; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readMap(in, obj); -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ public Object readMap(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ while (! in.isEnd()) { -+ Object key = in.readObject(); -+ -+ Method method = (Method) _methodMap.get(key); -+ -+ if (method != null) { -+ Object value = in.readObject(method.getParameterTypes()[0]); -+ -+ method.invoke(obj, new Object[] {value }); -+ } -+ else { -+ Object value = in.readObject(); -+ } -+ } -+ -+ in.readMapEnd(); -+ -+ Object resolve = resolve(obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ private Object resolve(Object obj) -+ { -+ // if there's a readResolve method, call it -+ try { -+ if (_readResolve != null) -+ return _readResolve.invoke(obj, new Object[0]); -+ } catch (Exception e) { -+ } -+ -+ return obj; -+ } -+ -+ protected Object instantiate() -+ throws Exception -+ { -+ return _constructor.newInstance(_constructorArgs); -+ } -+ -+ /** -+ * Returns the readResolve method -+ */ -+ protected Method getReadResolve(Class cl) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (method.getName().equals("readResolve") && -+ method.getParameterTypes().length == 0) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected HashMap getMethodMap(Class cl) -+ { -+ HashMap methodMap = new HashMap(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (Modifier.isStatic(method.getModifiers())) -+ continue; -+ -+ String name = method.getName(); -+ -+ if (! name.startsWith("set")) -+ continue; -+ -+ Class []paramTypes = method.getParameterTypes(); -+ if (paramTypes.length != 1) -+ continue; -+ -+ if (! method.getReturnType().equals(void.class)) -+ continue; -+ -+ if (findGetter(methods, name, paramTypes[0]) == null) -+ continue; -+ -+ // XXX: could parameterize the handler to only deal with public -+ try { -+ method.setAccessible(true); -+ } catch (Throwable e) { -+ e.printStackTrace(); -+ } -+ -+ name = name.substring(3); -+ -+ int j = 0; -+ for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { -+ } -+ -+ if (j == 1) -+ name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); -+ else if (j > 1) -+ name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); -+ -+ -+ methodMap.put(name, method); -+ } -+ } -+ -+ return methodMap; -+ } -+ -+ /** -+ * Finds any matching setter. -+ */ -+ private Method findGetter(Method []methods, String setterName, Class arg) -+ { -+ String getterName = "get" + setterName.substring(3); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (! method.getName().equals(getterName)) -+ continue; -+ -+ if (! method.getReturnType().equals(arg)) -+ continue; -+ -+ Class []params = method.getParameterTypes(); -+ -+ if (params.length == 0) -+ return method; -+ } -+ -+ return null; -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected static Object getParamArg(Class cl) -+ { -+ if (! cl.isPrimitive()) -+ return null; -+ else if (boolean.class.equals(cl)) -+ return Boolean.FALSE; -+ else if (byte.class.equals(cl)) -+ return Byte.valueOf((byte) 0); -+ else if (short.class.equals(cl)) -+ return Short.valueOf((short) 0); -+ else if (char.class.equals(cl)) -+ return Character.valueOf((char) 0); -+ else if (int.class.equals(cl)) -+ return Integer.valueOf(0); -+ else if (long.class.equals(cl)) -+ return Long.valueOf(0); -+ else if (float.class.equals(cl)) -+ return Double.valueOf(0); -+ else if (double.class.equals(cl)) -+ return Double.valueOf(0); -+ else -+ throw new UnsupportedOperationException(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,316 +1,316 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.ArrayList; --import java.util.Collections; --import java.util.Comparator; --import java.util.Locale; --import java.util.logging.*; -- --/** -- * Serializing an object for known object types. -- */ --public class BeanSerializer extends AbstractSerializer { -- private static final Logger log -- = Logger.getLogger(BeanSerializer.class.getName()); -- -- private static final Object []NULL_ARGS = new Object[0]; -- private Method []_methods; -- private String []_names; -- -- private Object _writeReplaceFactory; -- private Method _writeReplace; -- -- public BeanSerializer(Class cl, ClassLoader loader) -- { -- introspectWriteReplace(cl, loader); -- -- ArrayList primitiveMethods = new ArrayList(); -- ArrayList compoundMethods = new ArrayList(); -- -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (Modifier.isStatic(method.getModifiers())) -- continue; -- -- if (method.getParameterTypes().length != 0) -- continue; -- -- String name = method.getName(); -- -- if (! name.startsWith("get")) -- continue; -- -- Class type = method.getReturnType(); -- -- if (type.equals(void.class)) -- continue; -- -- if (findSetter(methods, name, type) == null) -- continue; -- -- // XXX: could parameterize the handler to only deal with public -- method.setAccessible(true); -- -- if (type.isPrimitive() -- || type.getName().startsWith("java.lang.") -- && ! type.equals(Object.class)) -- primitiveMethods.add(method); -- else -- compoundMethods.add(method); -- } -- } -- -- ArrayList methodList = new ArrayList(); -- methodList.addAll(primitiveMethods); -- methodList.addAll(compoundMethods); -- -- Collections.sort(methodList, new MethodNameCmp()); -- -- _methods = new Method[methodList.size()]; -- methodList.toArray(_methods); -- -- _names = new String[_methods.length]; -- -- for (int i = 0; i < _methods.length; i++) { -- String name = _methods[i].getName(); -- -- name = name.substring(3); -- -- int j = 0; -- for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { -- } -- -- if (j == 1) -- name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); -- else if (j > 1) -- name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); -- -- _names[i] = name; -- } -- } -- -- private void introspectWriteReplace(Class cl, ClassLoader loader) -- { -- try { -- String className = cl.getName() + "HessianSerializer"; -- -- Class serializerClass = Class.forName(className, false, loader); -- -- Object serializerObject = serializerClass.newInstance(); -- -- Method writeReplace = getWriteReplace(serializerClass, cl); -- -- if (writeReplace != null) { -- _writeReplaceFactory = serializerObject; -- _writeReplace = writeReplace; -- -- return; -- } -- } catch (ClassNotFoundException e) { -- } catch (Exception e) { -- log.log(Level.FINER, e.toString(), e); -- } -- -- _writeReplace = getWriteReplace(cl); -- } -- -- /** -- * Returns the writeReplace method -- */ -- protected Method getWriteReplace(Class cl) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (method.getName().equals("writeReplace") && -- method.getParameterTypes().length == 0) -- return method; -- } -- } -- -- return null; -- } -- -- /** -- * Returns the writeReplace method -- */ -- protected Method getWriteReplace(Class cl, Class param) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- for (Method method : cl.getDeclaredMethods()) { -- if (method.getName().equals("writeReplace") -- && method.getParameterTypes().length == 1 -- && param.equals(method.getParameterTypes()[0])) -- return method; -- } -- } -- -- return null; -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) -- return; -- -- Class cl = obj.getClass(); -- -- try { -- if (_writeReplace != null) { -- Object repl; -- -- if (_writeReplaceFactory != null) -- repl = _writeReplace.invoke(_writeReplaceFactory, obj); -- else -- repl = _writeReplace.invoke(obj); -- -- // out.removeRef(obj); -- -- out.writeObject(repl); -- -- out.replaceRef(repl, obj); -- -- return; -- } -- } catch (Exception e) { -- log.log(Level.FINER, e.toString(), e); -- } -- -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref < -1) { -- // Hessian 1.1 uses a map -- -- for (int i = 0; i < _methods.length; i++) { -- Method method = _methods[i]; -- Object value = null; -- -- try { -- value = _methods[i].invoke(obj, (Object []) null); -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeString(_names[i]); -- -- out.writeObject(value); -- } -- -- out.writeMapEnd(); -- } -- else { -- if (ref == -1) { -- out.writeInt(_names.length); -- -- for (int i = 0; i < _names.length; i++) -- out.writeString(_names[i]); -- -- out.writeObjectBegin(cl.getName()); -- } -- -- for (int i = 0; i < _methods.length; i++) { -- Method method = _methods[i]; -- Object value = null; -- -- try { -- value = _methods[i].invoke(obj, (Object []) null); -- } catch (Exception e) { -- log.log(Level.FINER, e.toString(), e); -- } -- -- out.writeObject(value); -- } -- } -- } -- -- /** -- * Finds any matching setter. -- */ -- private Method findSetter(Method []methods, String getterName, Class arg) -- { -- String setterName = "set" + getterName.substring(3); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (! method.getName().equals(setterName)) -- continue; -- -- if (! method.getReturnType().equals(void.class)) -- continue; -- -- Class []params = method.getParameterTypes(); -- -- if (params.length == 1 && params[0].equals(arg)) -- return method; -- } -- -- return null; -- } -- -- static class MethodNameCmp implements Comparator { -- public int compare(Method a, Method b) -- { -- return a.getName().compareTo(b.getName()); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.ArrayList; -+import java.util.Collections; -+import java.util.Comparator; -+import java.util.Locale; -+import java.util.logging.*; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class BeanSerializer extends AbstractSerializer { -+ private static final Logger log -+ = Logger.getLogger(BeanSerializer.class.getName()); -+ -+ private static final Object []NULL_ARGS = new Object[0]; -+ private Method []_methods; -+ private String []_names; -+ -+ private Object _writeReplaceFactory; -+ private Method _writeReplace; -+ -+ public BeanSerializer(Class cl, ClassLoader loader) -+ { -+ introspectWriteReplace(cl, loader); -+ -+ ArrayList primitiveMethods = new ArrayList(); -+ ArrayList compoundMethods = new ArrayList(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (Modifier.isStatic(method.getModifiers())) -+ continue; -+ -+ if (method.getParameterTypes().length != 0) -+ continue; -+ -+ String name = method.getName(); -+ -+ if (! name.startsWith("get")) -+ continue; -+ -+ Class type = method.getReturnType(); -+ -+ if (type.equals(void.class)) -+ continue; -+ -+ if (findSetter(methods, name, type) == null) -+ continue; -+ -+ // XXX: could parameterize the handler to only deal with public -+ method.setAccessible(true); -+ -+ if (type.isPrimitive() -+ || type.getName().startsWith("java.lang.") -+ && ! type.equals(Object.class)) -+ primitiveMethods.add(method); -+ else -+ compoundMethods.add(method); -+ } -+ } -+ -+ ArrayList methodList = new ArrayList(); -+ methodList.addAll(primitiveMethods); -+ methodList.addAll(compoundMethods); -+ -+ Collections.sort(methodList, new MethodNameCmp()); -+ -+ _methods = new Method[methodList.size()]; -+ methodList.toArray(_methods); -+ -+ _names = new String[_methods.length]; -+ -+ for (int i = 0; i < _methods.length; i++) { -+ String name = _methods[i].getName(); -+ -+ name = name.substring(3); -+ -+ int j = 0; -+ for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) { -+ } -+ -+ if (j == 1) -+ name = name.substring(0, j).toLowerCase(Locale.ENGLISH) + name.substring(j); -+ else if (j > 1) -+ name = name.substring(0, j - 1).toLowerCase(Locale.ENGLISH) + name.substring(j - 1); -+ -+ _names[i] = name; -+ } -+ } -+ -+ private void introspectWriteReplace(Class cl, ClassLoader loader) -+ { -+ try { -+ String className = cl.getName() + "HessianSerializer"; -+ -+ Class serializerClass = Class.forName(className, false, loader); -+ -+ Object serializerObject = serializerClass.newInstance(); -+ -+ Method writeReplace = getWriteReplace(serializerClass, cl); -+ -+ if (writeReplace != null) { -+ _writeReplaceFactory = serializerObject; -+ _writeReplace = writeReplace; -+ -+ return; -+ } -+ } catch (ClassNotFoundException e) { -+ } catch (Exception e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ _writeReplace = getWriteReplace(cl); -+ } -+ -+ /** -+ * Returns the writeReplace method -+ */ -+ protected Method getWriteReplace(Class cl) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (method.getName().equals("writeReplace") && -+ method.getParameterTypes().length == 0) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ /** -+ * Returns the writeReplace method -+ */ -+ protected Method getWriteReplace(Class cl, Class param) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ for (Method method : cl.getDeclaredMethods()) { -+ if (method.getName().equals("writeReplace") -+ && method.getParameterTypes().length == 1 -+ && param.equals(method.getParameterTypes()[0])) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ Class cl = obj.getClass(); -+ -+ try { -+ if (_writeReplace != null) { -+ Object repl; -+ -+ if (_writeReplaceFactory != null) -+ repl = _writeReplace.invoke(_writeReplaceFactory, obj); -+ else -+ repl = _writeReplace.invoke(obj); -+ -+ // out.removeRef(obj); -+ -+ out.writeObject(repl); -+ -+ out.replaceRef(repl, obj); -+ -+ return; -+ } -+ } catch (Exception e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref < -1) { -+ // Hessian 1.1 uses a map -+ -+ for (int i = 0; i < _methods.length; i++) { -+ Method method = _methods[i]; -+ Object value = null; -+ -+ try { -+ value = _methods[i].invoke(obj, (Object []) null); -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeString(_names[i]); -+ -+ out.writeObject(value); -+ } -+ -+ out.writeMapEnd(); -+ } -+ else { -+ if (ref == -1) { -+ out.writeInt(_names.length); -+ -+ for (int i = 0; i < _names.length; i++) -+ out.writeString(_names[i]); -+ -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ for (int i = 0; i < _methods.length; i++) { -+ Method method = _methods[i]; -+ Object value = null; -+ -+ try { -+ value = _methods[i].invoke(obj, (Object []) null); -+ } catch (Exception e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ out.writeObject(value); -+ } -+ } -+ } -+ -+ /** -+ * Finds any matching setter. -+ */ -+ private Method findSetter(Method []methods, String getterName, Class arg) -+ { -+ String setterName = "set" + getterName.substring(3); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (! method.getName().equals(setterName)) -+ continue; -+ -+ if (! method.getReturnType().equals(void.class)) -+ continue; -+ -+ Class []params = method.getParameterTypes(); -+ -+ if (params.length == 1 && params[0].equals(arg)) -+ return method; -+ } -+ -+ return null; -+ } -+ -+ static class MethodNameCmp implements Comparator { -+ public int compare(Method a, Method b) -+ { -+ return a.getName().compareTo(b.getName()); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializerFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/BeanSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/BeanSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,82 +1,82 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --/** -- * Factory for returning serialization methods. -- */ --public class BeanSerializerFactory extends SerializerFactory { -- /** -- * Returns the default serializer for a class that isn't matched -- * directly. Application can override this method to produce -- * bean-style serialization instead of field serialization. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- protected Serializer getDefaultSerializer(Class cl) -- { -- return new BeanSerializer(cl, getClassLoader()); -- } -- -- /** -- * Returns the default deserializer for a class that isn't matched -- * directly. Application can override this method to produce -- * bean-style serialization instead of field serialization. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- protected Deserializer getDefaultDeserializer(Class cl) -- { -- return new BeanDeserializer(cl); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+/** -+ * Factory for returning serialization methods. -+ */ -+public class BeanSerializerFactory extends SerializerFactory { -+ /** -+ * Returns the default serializer for a class that isn't matched -+ * directly. Application can override this method to produce -+ * bean-style serialization instead of field serialization. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ protected Serializer getDefaultSerializer(Class cl) -+ { -+ return new BeanSerializer(cl, getClassLoader()); -+ } -+ -+ /** -+ * Returns the default deserializer for a class that isn't matched -+ * directly. Application can override this method to produce -+ * bean-style serialization instead of field serialization. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ protected Deserializer getDefaultDeserializer(Class cl) -+ { -+ return new BeanDeserializer(cl); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/BigDecimalDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/BigDecimalDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/BigDecimalDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/BigDecimalDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,68 +1,68 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.math.BigDecimal; -- --/** -- * Deserializing a BigDecimal -- */ --public class BigDecimalDeserializer extends AbstractStringValueDeserializer { -- @Override -- public Class getType() -- { -- return BigDecimal.class; -- } -- -- @Override -- protected Object create(String value) -- { -- return new BigDecimal(value); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.math.BigDecimal; -+ -+/** -+ * Deserializing a BigDecimal -+ */ -+public class BigDecimalDeserializer extends AbstractStringValueDeserializer { -+ @Override -+ public Class getType() -+ { -+ return BigDecimal.class; -+ } -+ -+ @Override -+ protected Object create(String value) -+ { -+ return new BigDecimal(value); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ByteArraySerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ByteArraySerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ByteArraySerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ByteArraySerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,82 +1,82 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing an object for known object types. -- */ --public class ByteArraySerializer extends AbstractSerializer -- implements ObjectSerializer --{ -- public static final ByteArraySerializer SER = new ByteArraySerializer(); -- -- private ByteArraySerializer() -- { -- } -- -- @Override -- public Serializer getObjectSerializer() -- { -- return this; -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- byte []data = (byte []) obj; -- -- if (data != null) -- out.writeBytes(data, 0, data.length); -- else -- out.writeNull(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class ByteArraySerializer extends AbstractSerializer -+ implements ObjectSerializer -+{ -+ public static final ByteArraySerializer SER = new ByteArraySerializer(); -+ -+ private ByteArraySerializer() -+ { -+ } -+ -+ @Override -+ public Serializer getObjectSerializer() -+ { -+ return this; -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ byte []data = (byte []) obj; -+ -+ if (data != null) -+ out.writeBytes(data, 0, data.length); -+ else -+ out.writeNull(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ByteHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/ByteHandle.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ByteHandle.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ByteHandle.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,83 +1,83 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.net.URL; --import java.io.Serializable; -- --/** -- * Handle for Java Byte objects. -- */ --public class ByteHandle implements Serializable { -- private byte _value; -- -- private ByteHandle() -- { -- } -- -- public ByteHandle(byte value) -- { -- _value = value; -- } -- -- public byte getValue() -- { -- return _value; -- } -- -- public Object readResolve() -- { -- return new Byte(_value); -- } -- -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _value + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.net.URL; -+import java.io.Serializable; -+ -+/** -+ * Handle for Java Byte objects. -+ */ -+public class ByteHandle implements Serializable { -+ private byte _value; -+ -+ private ByteHandle() -+ { -+ } -+ -+ public ByteHandle(byte value) -+ { -+ _value = value; -+ } -+ -+ public byte getValue() -+ { -+ return _value; -+ } -+ -+ public Object readResolve() -+ { -+ return new Byte(_value); -+ } -+ -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _value + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CalendarHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/CalendarHandle.java ---- hessian-4.0.65-src/com/caucho/hessian/io/CalendarHandle.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/CalendarHandle.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,93 +1,93 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.Calendar; --import java.util.Date; --import java.util.GregorianCalendar; -- --/** -- * Handle for a calendar object. -- */ --public class CalendarHandle implements java.io.Serializable, HessianHandle { -- private Class type; -- private Date date; -- -- public CalendarHandle() -- { -- } -- -- public CalendarHandle(Class type, long time) -- { -- if (! GregorianCalendar.class.equals(type)) -- this.type = type; -- -- this.date = new Date(time); -- } -- -- private Object readResolve() -- { -- try { -- Calendar cal; -- -- if (this.type != null) -- cal = (Calendar) this.type.newInstance(); -- else -- cal = new GregorianCalendar(); -- -- cal.setTimeInMillis(this.date.getTime()); -- -- return cal; -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.Calendar; -+import java.util.Date; -+import java.util.GregorianCalendar; -+ -+/** -+ * Handle for a calendar object. -+ */ -+public class CalendarHandle implements java.io.Serializable, HessianHandle { -+ private Class type; -+ private Date date; -+ -+ public CalendarHandle() -+ { -+ } -+ -+ public CalendarHandle(Class type, long time) -+ { -+ if (! GregorianCalendar.class.equals(type)) -+ this.type = type; -+ -+ this.date = new Date(time); -+ } -+ -+ private Object readResolve() -+ { -+ try { -+ Calendar cal; -+ -+ if (this.type != null) -+ cal = (Calendar) this.type.newInstance(); -+ else -+ cal = new GregorianCalendar(); -+ -+ cal.setTimeInMillis(this.date.getTime()); -+ -+ return cal; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CalendarSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/CalendarSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/CalendarSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/CalendarSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,70 +1,70 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.Calendar; -- --/** -- * Serializing a calendar. -- */ --public class CalendarSerializer extends AbstractSerializer { -- public static final Serializer SER = new CalendarSerializer(); -- -- /** -- * java.util.Calendar serializes to com.caucho.hessian.io.CalendarHandle -- */ -- @Override -- public Object writeReplace(Object obj) -- { -- Calendar cal = (Calendar) obj; -- -- return new CalendarHandle(cal.getClass(), cal.getTimeInMillis()); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.Calendar; -+ -+/** -+ * Serializing a calendar. -+ */ -+public class CalendarSerializer extends AbstractSerializer { -+ public static final Serializer SER = new CalendarSerializer(); -+ -+ /** -+ * java.util.Calendar serializes to com.caucho.hessian.io.CalendarHandle -+ */ -+ @Override -+ public Object writeReplace(Object obj) -+ { -+ Calendar cal = (Calendar) obj; -+ -+ return new CalendarHandle(cal.getClass(), cal.getTimeInMillis()); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ClassDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ClassDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ClassDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ClassDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,162 +1,162 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.HashMap; -- --/** -- * Deserializing a JDK 1.2 Class. -- */ --public class ClassDeserializer extends AbstractMapDeserializer { -- private static final HashMap _primClasses -- = new HashMap(); -- -- private ClassLoader _loader; -- -- public ClassDeserializer(ClassLoader loader) -- { -- _loader = loader; -- } -- -- public Class getType() -- { -- return Class.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- int ref = in.addRef(null); -- -- String name = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if (key.equals("name")) -- name = in.readString(); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- Object value = create(name); -- -- in.setRef(ref, value); -- -- return value; -- } -- -- public Object readObject(AbstractHessianInput in, Object []fields) -- throws IOException -- { -- String []fieldNames = (String []) fields; -- -- int ref = in.addRef(null); -- -- String name = null; -- -- for (int i = 0; i < fieldNames.length; i++) { -- if ("name".equals(fieldNames[i])) -- name = in.readString(); -- else -- in.readObject(); -- } -- -- Object value = create(name); -- -- in.setRef(ref, value); -- -- return value; -- } -- -- Object create(String name) -- throws IOException -- { -- if (name == null) -- throw new IOException("Serialized Class expects name."); -- -- Class cl = _primClasses.get(name); -- -- if (cl != null) -- return cl; -- -- try { -- if (_loader != null) -- return Class.forName(name, false, _loader); -- else -- return Class.forName(name); -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- static { -- _primClasses.put("void", void.class); -- _primClasses.put("boolean", boolean.class); -- _primClasses.put("java.lang.Boolean", Boolean.class); -- _primClasses.put("byte", byte.class); -- _primClasses.put("java.lang.Byte", Byte.class); -- _primClasses.put("char", char.class); -- _primClasses.put("java.lang.Character", Character.class); -- _primClasses.put("short", short.class); -- _primClasses.put("java.lang.Short", Short.class); -- _primClasses.put("int", int.class); -- _primClasses.put("java.lang.Integer", Integer.class); -- _primClasses.put("long", long.class); -- _primClasses.put("java.lang.Long", Long.class); -- _primClasses.put("float", float.class); -- _primClasses.put("java.lang.Float", Float.class); -- _primClasses.put("double", double.class); -- _primClasses.put("java.lang.Double", Double.class); -- _primClasses.put("java.lang.String", String.class); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.HashMap; -+ -+/** -+ * Deserializing a JDK 1.2 Class. -+ */ -+public class ClassDeserializer extends AbstractMapDeserializer { -+ private static final HashMap _primClasses -+ = new HashMap(); -+ -+ private ClassLoader _loader; -+ -+ public ClassDeserializer(ClassLoader loader) -+ { -+ _loader = loader; -+ } -+ -+ public Class getType() -+ { -+ return Class.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ int ref = in.addRef(null); -+ -+ String name = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if (key.equals("name")) -+ name = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object value = create(name); -+ -+ in.setRef(ref, value); -+ -+ return value; -+ } -+ -+ public Object readObject(AbstractHessianInput in, Object []fields) -+ throws IOException -+ { -+ String []fieldNames = (String []) fields; -+ -+ int ref = in.addRef(null); -+ -+ String name = null; -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ if ("name".equals(fieldNames[i])) -+ name = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ Object value = create(name); -+ -+ in.setRef(ref, value); -+ -+ return value; -+ } -+ -+ Object create(String name) -+ throws IOException -+ { -+ if (name == null) -+ throw new IOException("Serialized Class expects name."); -+ -+ Class cl = _primClasses.get(name); -+ -+ if (cl != null) -+ return cl; -+ -+ try { -+ if (_loader != null) -+ return Class.forName(name, false, _loader); -+ else -+ return Class.forName(name); -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ static { -+ _primClasses.put("void", void.class); -+ _primClasses.put("boolean", boolean.class); -+ _primClasses.put("java.lang.Boolean", Boolean.class); -+ _primClasses.put("byte", byte.class); -+ _primClasses.put("java.lang.Byte", Byte.class); -+ _primClasses.put("char", char.class); -+ _primClasses.put("java.lang.Character", Character.class); -+ _primClasses.put("short", short.class); -+ _primClasses.put("java.lang.Short", Short.class); -+ _primClasses.put("int", int.class); -+ _primClasses.put("java.lang.Integer", Integer.class); -+ _primClasses.put("long", long.class); -+ _primClasses.put("java.lang.Long", Long.class); -+ _primClasses.put("float", float.class); -+ _primClasses.put("java.lang.Float", Float.class); -+ _primClasses.put("double", double.class); -+ _primClasses.put("java.lang.Double", Double.class); -+ _primClasses.put("java.lang.String", String.class); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ClassFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/ClassFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ClassFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ClassFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,225 +1,225 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.ArrayList; --import java.util.HashMap; --import java.util.regex.Pattern; -- --/** -- * Loads a class from the classloader. -- */ --public class ClassFactory --{ -- private static ArrayList _staticAllowList; -- -- private static ArrayList _staticDenyList; -- -- private ClassLoader _loader; -- -- private boolean _isWhitelist; -- -- private ArrayList _allowList; -- -- ClassFactory(ClassLoader loader) -- { -- _loader = loader; -- } -- -- public Class load(String className) -- throws ClassNotFoundException -- { -- if (isAllow(className)) { -- return Class.forName(className, false, _loader); -- } -- else { -- return HashMap.class; -- } -- } -- -- private boolean isAllow(String className) -- { -- ArrayList allowList = _allowList; -- -- if (allowList == null) { -- Boolean isAllow = isAllow(_staticDenyList, className); -- -- if (isAllow != null) { -- return isAllow; -- } -- else { -- return true; -- } -- -- } -- -- Boolean isAllow = isAllow(_allowList, className); -- if (isAllow != null) { -- return isAllow; -- } -- -- isAllow = isAllow(_staticAllowList, className); -- -- if (isAllow != null) { -- return isAllow; -- } -- -- return ! _isWhitelist; -- } -- -- private Boolean isAllow(ArrayList allowList, String className) -- { -- if (allowList == null) { -- return null; -- } -- -- int size = allowList.size(); -- for (int i = 0; i < size; i++) { -- Allow allow = allowList.get(i); -- -- Boolean isAllow = allow.allow(className); -- -- if (isAllow != null) { -- return isAllow; -- } -- } -- -- return null; -- } -- -- public void setWhitelist(boolean isWhitelist) -- { -- initAllow(); -- -- _isWhitelist = isWhitelist; -- } -- -- /** -- * Allow a class or package based on a pattern. -- * -- * Examples: "java.util.*", "com.foo.io.Bean" -- */ -- public void allow(String pattern) -- { -- initAllow(); -- -- synchronized (this) { -- _allowList.add(new Allow(toPattern(pattern), true)); -- } -- } -- -- /** -- * Deny a class or package based on a pattern. -- * -- * Examples: "java.util.*", "com.foo.io.Bean" -- */ -- public void deny(String pattern) -- { -- initAllow(); -- -- synchronized (this) { -- _allowList.add(new Allow(toPattern(pattern), false)); -- } -- } -- -- private String toPattern(String pattern) -- { -- pattern = pattern.replace(".", "\\."); -- pattern = pattern.replace("*", ".*"); -- -- return pattern; -- } -- -- private void initAllow() -- { -- synchronized (this) { -- if (_allowList == null) { -- _allowList = new ArrayList(); -- _isWhitelist = true; -- } -- } -- } -- -- static class Allow { -- private Boolean _isAllow; -- private Pattern _pattern; -- -- private Allow(String pattern, boolean isAllow) -- { -- _isAllow = isAllow; -- _pattern = Pattern.compile(pattern); -- } -- -- Boolean allow(String className) -- { -- if (_pattern.matcher(className).matches()) { -- return _isAllow; -- } -- else { -- return null; -- } -- } -- } -- -- static { -- ArrayList blacklist = new ArrayList(); -- -- blacklist.add(new Allow("java\\.lang\\.Runtime", false)); -- blacklist.add(new Allow("java\\.lang\\.Process", false)); -- blacklist.add(new Allow("java\\.lang\\.System", false)); -- blacklist.add(new Allow("java\\.lang\\.Thread", false)); -- -- _staticAllowList = new ArrayList(blacklist); -- -- _staticAllowList.add(new Allow("java\\..+", true)); -- _staticAllowList.add(new Allow("javax\\.management\\..+", true)); -- -- _staticDenyList = new ArrayList(blacklist); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.ArrayList; -+import java.util.HashMap; -+import java.util.regex.Pattern; -+ -+/** -+ * Loads a class from the classloader. -+ */ -+public class ClassFactory -+{ -+ private static ArrayList _staticAllowList; -+ -+ private static ArrayList _staticDenyList; -+ -+ private ClassLoader _loader; -+ -+ private boolean _isWhitelist; -+ -+ private ArrayList _allowList; -+ -+ ClassFactory(ClassLoader loader) -+ { -+ _loader = loader; -+ } -+ -+ public Class load(String className) -+ throws ClassNotFoundException -+ { -+ if (isAllow(className)) { -+ return Class.forName(className, false, _loader); -+ } -+ else { -+ return HashMap.class; -+ } -+ } -+ -+ private boolean isAllow(String className) -+ { -+ ArrayList allowList = _allowList; -+ -+ if (allowList == null) { -+ Boolean isAllow = isAllow(_staticDenyList, className); -+ -+ if (isAllow != null) { -+ return isAllow; -+ } -+ else { -+ return true; -+ } -+ -+ } -+ -+ Boolean isAllow = isAllow(_allowList, className); -+ if (isAllow != null) { -+ return isAllow; -+ } -+ -+ isAllow = isAllow(_staticAllowList, className); -+ -+ if (isAllow != null) { -+ return isAllow; -+ } -+ -+ return ! _isWhitelist; -+ } -+ -+ private Boolean isAllow(ArrayList allowList, String className) -+ { -+ if (allowList == null) { -+ return null; -+ } -+ -+ int size = allowList.size(); -+ for (int i = 0; i < size; i++) { -+ Allow allow = allowList.get(i); -+ -+ Boolean isAllow = allow.allow(className); -+ -+ if (isAllow != null) { -+ return isAllow; -+ } -+ } -+ -+ return null; -+ } -+ -+ public void setWhitelist(boolean isWhitelist) -+ { -+ initAllow(); -+ -+ _isWhitelist = isWhitelist; -+ } -+ -+ /** -+ * Allow a class or package based on a pattern. -+ * -+ * Examples: "java.util.*", "com.foo.io.Bean" -+ */ -+ public void allow(String pattern) -+ { -+ initAllow(); -+ -+ synchronized (this) { -+ _allowList.add(new Allow(toPattern(pattern), true)); -+ } -+ } -+ -+ /** -+ * Deny a class or package based on a pattern. -+ * -+ * Examples: "java.util.*", "com.foo.io.Bean" -+ */ -+ public void deny(String pattern) -+ { -+ initAllow(); -+ -+ synchronized (this) { -+ _allowList.add(new Allow(toPattern(pattern), false)); -+ } -+ } -+ -+ private String toPattern(String pattern) -+ { -+ pattern = pattern.replace(".", "\\."); -+ pattern = pattern.replace("*", ".*"); -+ -+ return pattern; -+ } -+ -+ private void initAllow() -+ { -+ synchronized (this) { -+ if (_allowList == null) { -+ _allowList = new ArrayList(); -+ _isWhitelist = true; -+ } -+ } -+ } -+ -+ static class Allow { -+ private Boolean _isAllow; -+ private Pattern _pattern; -+ -+ private Allow(String pattern, boolean isAllow) -+ { -+ _isAllow = isAllow; -+ _pattern = Pattern.compile(pattern); -+ } -+ -+ Boolean allow(String className) -+ { -+ if (_pattern.matcher(className).matches()) { -+ return _isAllow; -+ } -+ else { -+ return null; -+ } -+ } -+ } -+ -+ static { -+ ArrayList blacklist = new ArrayList(); -+ -+ blacklist.add(new Allow("java\\.lang\\.Runtime", false)); -+ blacklist.add(new Allow("java\\.lang\\.Process", false)); -+ blacklist.add(new Allow("java\\.lang\\.System", false)); -+ blacklist.add(new Allow("java\\.lang\\.Thread", false)); -+ -+ _staticAllowList = new ArrayList(blacklist); -+ -+ _staticAllowList.add(new Allow("java\\..+", true)); -+ _staticAllowList.add(new Allow("javax\\.management\\..+", true)); -+ -+ _staticDenyList = new ArrayList(blacklist); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ClassSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ClassSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ClassSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ClassSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,87 +1,87 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing a remote object. -- */ --public class ClassSerializer extends AbstractSerializer { -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- Class cl = (Class) obj; -- -- if (cl == null) { -- out.writeNull(); -- } -- else if (out.addRef(obj)) { -- return; -- } -- else { -- int ref = out.writeObjectBegin("java.lang.Class"); -- -- if (ref < -1) { -- out.writeString("name"); -- out.writeString(cl.getName()); -- out.writeMapEnd(); -- } -- else { -- if (ref == -1) { -- out.writeInt(1); -- out.writeString("name"); -- out.writeObjectBegin("java.lang.Class"); -- } -- -- out.writeString(cl.getName()); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing a remote object. -+ */ -+public class ClassSerializer extends AbstractSerializer { -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ Class cl = (Class) obj; -+ -+ if (cl == null) { -+ out.writeNull(); -+ } -+ else if (out.addRef(obj)) { -+ return; -+ } -+ else { -+ int ref = out.writeObjectBegin("java.lang.Class"); -+ -+ if (ref < -1) { -+ out.writeString("name"); -+ out.writeString(cl.getName()); -+ out.writeMapEnd(); -+ } -+ else { -+ if (ref == -1) { -+ out.writeInt(1); -+ out.writeString("name"); -+ out.writeObjectBegin("java.lang.Class"); -+ } -+ -+ out.writeString(cl.getName()); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CollectionDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/CollectionDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/CollectionDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/CollectionDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,139 +1,139 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.*; -- --/** -- * Deserializing a JDK 1.2 Collection. -- */ --public class CollectionDeserializer extends AbstractListDeserializer { -- private Class _type; -- -- public CollectionDeserializer(Class type) -- { -- _type = type; -- } -- -- public Class getType() -- { -- return _type; -- } -- -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- Collection list = createList(); -- -- in.addRef(list); -- -- while (! in.isEnd()) -- list.add(in.readObject()); -- -- in.readEnd(); -- -- return list; -- } -- -- public Object readLengthList(AbstractHessianInput in, int length) -- throws IOException -- { -- Collection list = createList(); -- -- in.addRef(list); -- -- for (; length > 0; length--) -- list.add(in.readObject()); -- -- return list; -- } -- -- private Collection createList() -- throws IOException -- { -- Collection list = null; -- -- if (_type == null) -- list = new ArrayList(); -- else if (! _type.isInterface()) { -- try { -- list = (Collection) _type.newInstance(); -- } catch (Exception e) { -- } -- } -- -- if (list != null) { -- } -- else if (SortedSet.class.isAssignableFrom(_type)) -- list = new TreeSet(); -- else if (Set.class.isAssignableFrom(_type)) -- list = new HashSet(); -- else if (List.class.isAssignableFrom(_type)) -- list = new ArrayList(); -- else if (Collection.class.isAssignableFrom(_type)) -- list = new ArrayList(); -- else { -- try { -- list = (Collection) _type.newInstance(); -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- return list; -- } -- -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _type + "]"; -- } --} -- -- -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.*; -+ -+/** -+ * Deserializing a JDK 1.2 Collection. -+ */ -+public class CollectionDeserializer extends AbstractListDeserializer { -+ private Class _type; -+ -+ public CollectionDeserializer(Class type) -+ { -+ _type = type; -+ } -+ -+ public Class getType() -+ { -+ return _type; -+ } -+ -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ Collection list = createList(); -+ -+ in.addRef(list); -+ -+ while (! in.isEnd()) -+ list.add(in.readObject()); -+ -+ in.readEnd(); -+ -+ return list; -+ } -+ -+ public Object readLengthList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ Collection list = createList(); -+ -+ in.addRef(list); -+ -+ for (; length > 0; length--) -+ list.add(in.readObject()); -+ -+ return list; -+ } -+ -+ private Collection createList() -+ throws IOException -+ { -+ Collection list = null; -+ -+ if (_type == null) -+ list = new ArrayList(); -+ else if (! _type.isInterface()) { -+ try { -+ list = (Collection) _type.newInstance(); -+ } catch (Exception e) { -+ } -+ } -+ -+ if (list != null) { -+ } -+ else if (SortedSet.class.isAssignableFrom(_type)) -+ list = new TreeSet(); -+ else if (Set.class.isAssignableFrom(_type)) -+ list = new HashSet(); -+ else if (List.class.isAssignableFrom(_type)) -+ list = new ArrayList(); -+ else if (Collection.class.isAssignableFrom(_type)) -+ list = new ArrayList(); -+ else { -+ try { -+ list = (Collection) _type.newInstance(); -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ return list; -+ } -+ -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _type + "]"; -+ } -+} -+ -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/CollectionSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/CollectionSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/CollectionSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/CollectionSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,123 +1,123 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.Serializable; --import java.util.ArrayList; --import java.util.Collection; --import java.util.Iterator; -- --/** -- * Serializing a JDK 1.2 Collection. -- */ --public class CollectionSerializer extends AbstractSerializer --{ -- private boolean _sendJavaType = true; -- -- /** -- * Set true if the java type of the collection should be sent. -- */ -- public void setSendJavaType(boolean sendJavaType) -- { -- _sendJavaType = sendJavaType; -- } -- -- /** -- * Return true if the java type of the collection should be sent. -- */ -- public boolean getSendJavaType() -- { -- return _sendJavaType; -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) -- return; -- -- Collection list = (Collection) obj; -- -- Class cl = obj.getClass(); -- boolean hasEnd; -- -- if (cl.equals(ArrayList.class) -- || ! Serializable.class.isAssignableFrom(cl)) { -- hasEnd = out.writeListBegin(list.size(), null); -- } -- else if (! _sendJavaType) { -- hasEnd = false; -- -- // hessian/3a19 -- for (; cl != null; cl = cl.getSuperclass()) { -- if (cl.getName().startsWith("java.")) { -- hasEnd = out.writeListBegin(list.size(), cl.getName()); -- break; -- } -- } -- -- if (cl == null) -- hasEnd = out.writeListBegin(list.size(), null); -- } -- else { -- hasEnd = out.writeListBegin(list.size(), obj.getClass().getName()); -- } -- -- Iterator iter = list.iterator(); -- while (iter.hasNext()) { -- Object value = iter.next(); -- -- out.writeObject(value); -- } -- -- if (hasEnd) -- out.writeListEnd(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.Serializable; -+import java.util.ArrayList; -+import java.util.Collection; -+import java.util.Iterator; -+ -+/** -+ * Serializing a JDK 1.2 Collection. -+ */ -+public class CollectionSerializer extends AbstractSerializer -+{ -+ private boolean _sendJavaType = true; -+ -+ /** -+ * Set true if the java type of the collection should be sent. -+ */ -+ public void setSendJavaType(boolean sendJavaType) -+ { -+ _sendJavaType = sendJavaType; -+ } -+ -+ /** -+ * Return true if the java type of the collection should be sent. -+ */ -+ public boolean getSendJavaType() -+ { -+ return _sendJavaType; -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ Collection list = (Collection) obj; -+ -+ Class cl = obj.getClass(); -+ boolean hasEnd; -+ -+ if (cl.equals(ArrayList.class) -+ || ! Serializable.class.isAssignableFrom(cl)) { -+ hasEnd = out.writeListBegin(list.size(), null); -+ } -+ else if (! _sendJavaType) { -+ hasEnd = false; -+ -+ // hessian/3a19 -+ for (; cl != null; cl = cl.getSuperclass()) { -+ if (cl.getName().startsWith("java.")) { -+ hasEnd = out.writeListBegin(list.size(), cl.getName()); -+ break; -+ } -+ } -+ -+ if (cl == null) -+ hasEnd = out.writeListBegin(list.size(), null); -+ } -+ else { -+ hasEnd = out.writeListBegin(list.size(), obj.getClass().getName()); -+ } -+ -+ Iterator iter = list.iterator(); -+ while (iter.hasNext()) { -+ Object value = iter.next(); -+ -+ out.writeObject(value); -+ } -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ContextSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/ContextSerializerFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ContextSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ContextSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,507 +1,519 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.InputStream; --import java.lang.ref.SoftReference; --import java.lang.ref.WeakReference; --import java.net.InetAddress; --import java.net.URL; --import java.util.Enumeration; --import java.util.HashMap; --import java.util.HashSet; --import java.util.Map; --import java.util.Properties; --import java.util.WeakHashMap; --import java.util.concurrent.ConcurrentHashMap; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import com.caucho.hessian.HessianException; -- --/** -- * The classloader-specific Factory for returning serialization -- */ --public class ContextSerializerFactory --{ -- private static final Logger log -- = Logger.getLogger(ContextSerializerFactory.class.getName()); -- -- private static Deserializer OBJECT_DESERIALIZER -- = new BasicDeserializer(BasicDeserializer.OBJECT); -- -- private static final WeakHashMap> -- _contextRefMap -- = new WeakHashMap>(); -- -- private static final ClassLoader _systemClassLoader; -- -- private static HashMap _staticSerializerMap; -- private static HashMap _staticDeserializerMap; -- private static HashMap _staticClassNameMap; -- -- private ContextSerializerFactory _parent; -- private WeakReference _loaderRef; -- -- private final HashSet _serializerFiles = new HashSet(); -- private final HashSet _deserializerFiles = new HashSet(); -- -- private final HashMap _serializerClassMap -- = new HashMap(); -- -- private final ConcurrentHashMap _customSerializerMap -- = new ConcurrentHashMap(); -- -- private final HashMap,Serializer> _serializerInterfaceMap -- = new HashMap,Serializer>(); -- -- private final HashMap _deserializerClassMap -- = new HashMap(); -- -- private final HashMap _deserializerClassNameMap -- = new HashMap(); -- -- private final ConcurrentHashMap _customDeserializerMap -- = new ConcurrentHashMap(); -- -- private final HashMap,Deserializer> _deserializerInterfaceMap -- = new HashMap,Deserializer>(); -- -- public ContextSerializerFactory(ContextSerializerFactory parent, -- ClassLoader loader) -- { -- if (loader == null) -- loader = _systemClassLoader; -- -- _loaderRef = new WeakReference(loader); -- -- init(); -- } -- -- public static ContextSerializerFactory create() -- { -- return create(Thread.currentThread().getContextClassLoader()); -- } -- -- public static ContextSerializerFactory create(ClassLoader loader) -- { -- synchronized (_contextRefMap) { -- SoftReference factoryRef -- = _contextRefMap.get(loader); -- -- ContextSerializerFactory factory = null; -- -- if (factoryRef != null) -- factory = factoryRef.get(); -- -- if (factory == null) { -- ContextSerializerFactory parent = null; -- -- if (loader != null) -- parent = create(loader.getParent()); -- -- factory = new ContextSerializerFactory(parent, loader); -- factoryRef = new SoftReference(factory); -- -- _contextRefMap.put(loader, factoryRef); -- } -- -- return factory; -- } -- } -- -- public ClassLoader getClassLoader() -- { -- WeakReference loaderRef = _loaderRef; -- -- if (loaderRef != null) -- return loaderRef.get(); -- else -- return null; -- } -- -- /** -- * Returns the serializer for a given class. -- */ -- public Serializer getSerializer(String className) -- { -- Serializer serializer = _serializerClassMap.get(className); -- -- if (serializer == AbstractSerializer.NULL) -- return null; -- else -- return serializer; -- } -- -- /** -- * Returns a custom serializer the class -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- public Serializer getCustomSerializer(Class cl) -- { -- Serializer serializer = _customSerializerMap.get(cl.getName()); -- -- if (serializer == AbstractSerializer.NULL) -- return null; -- else if (serializer != null) -- return serializer; -- -- try { -- Class serClass = Class.forName(cl.getName() + "HessianSerializer", -- false, cl.getClassLoader()); -- -- Serializer ser = (Serializer) serClass.newInstance(); -- -- _customSerializerMap.put(cl.getName(), ser); -- -- return ser; -- } catch (ClassNotFoundException e) { -- log.log(Level.ALL, e.toString(), e); -- } catch (Exception e) { -- throw new HessianException(e); -- } -- -- _customSerializerMap.put(cl.getName(), AbstractSerializer.NULL); -- -- return null; -- } -- -- /** -- * Returns the deserializer for a given class. -- */ -- public Deserializer getDeserializer(String className) -- { -- Deserializer deserializer = _deserializerClassMap.get(className); -- -- if (deserializer != null && deserializer != AbstractDeserializer.NULL) { -- return deserializer; -- } -- -- deserializer = _deserializerInterfaceMap.get(className); -- -- if (deserializer != null && deserializer != AbstractDeserializer.NULL) { -- return deserializer; -- } -- -- return null; -- } -- -- /** -- * Returns a custom deserializer the class -- * -- * @param cl the class of the object that needs to be deserialized. -- * -- * @return a deserializer object for the deserialization. -- */ -- public Deserializer getCustomDeserializer(Class cl) -- { -- Deserializer deserializer = _customDeserializerMap.get(cl.getName()); -- -- if (deserializer == AbstractDeserializer.NULL) -- return null; -- else if (deserializer != null) -- return deserializer; -- -- try { -- Class serClass = Class.forName(cl.getName() + "HessianDeserializer", -- false, cl.getClassLoader()); -- -- Deserializer ser = (Deserializer) serClass.newInstance(); -- -- _customDeserializerMap.put(cl.getName(), ser); -- -- return ser; -- } catch (ClassNotFoundException e) { -- log.log(Level.ALL, e.toString(), e); -- } catch (Exception e) { -- throw new HessianException(e); -- } -- -- _customDeserializerMap.put(cl.getName(), AbstractDeserializer.NULL); -- -- return null; -- } -- -- /** -- * Initialize the factory -- */ -- private void init() -- { -- if (_parent != null) { -- _serializerFiles.addAll(_parent._serializerFiles); -- _deserializerFiles.addAll(_parent._deserializerFiles); -- -- _serializerClassMap.putAll(_parent._serializerClassMap); -- _deserializerClassMap.putAll(_parent._deserializerClassMap); -- } -- -- if (_parent == null) { -- _serializerClassMap.putAll(_staticSerializerMap); -- _deserializerClassMap.putAll(_staticDeserializerMap); -- _deserializerClassNameMap.putAll(_staticClassNameMap); -- } -- -- HashMap classMap; -- -- classMap = new HashMap(); -- initSerializerFiles("META-INF/hessian/serializers", -- _serializerFiles, -- classMap, -- Serializer.class); -- -- for (Map.Entry entry : classMap.entrySet()) { -- try { -- Serializer ser = (Serializer) entry.getValue().newInstance(); -- -- if (entry.getKey().isInterface()) -- _serializerInterfaceMap.put(entry.getKey(), ser); -- else -- _serializerClassMap.put(entry.getKey().getName(), ser); -- } catch (Exception e) { -- throw new HessianException(e); -- } -- } -- -- classMap = new HashMap(); -- initSerializerFiles("META-INF/hessian/deserializers", -- _deserializerFiles, -- classMap, -- Deserializer.class); -- -- for (Map.Entry entry : classMap.entrySet()) { -- try { -- Deserializer ser = (Deserializer) entry.getValue().newInstance(); -- -- if (entry.getKey().isInterface()) -- _deserializerInterfaceMap.put(entry.getKey(), ser); -- else { -- _deserializerClassMap.put(entry.getKey().getName(), ser); -- } -- } catch (Exception e) { -- throw new HessianException(e); -- } -- } -- } -- -- private void initSerializerFiles(String fileName, -- HashSet fileList, -- HashMap classMap, -- Class type) -- { -- try { -- ClassLoader classLoader = getClassLoader(); -- -- // on systems with the security manager enabled, the system classloader -- // is null -- if (classLoader == null) -- return; -- -- Enumeration iter; -- -- iter = classLoader.getResources(fileName); -- while (iter.hasMoreElements()) { -- URL url = (URL) iter.nextElement(); -- -- if (fileList.contains(url.toString())) -- continue; -- -- fileList.add(url.toString()); -- -- InputStream is = null; -- try { -- is = url.openStream(); -- -- Properties props = new Properties(); -- props.load(is); -- -- for (Map.Entry entry : props.entrySet()) { -- String apiName = (String) entry.getKey(); -- String serializerName = (String) entry.getValue(); -- -- Class apiClass = null; -- Class serializerClass = null; -- -- try { -- apiClass = Class.forName(apiName, false, classLoader); -- } catch (ClassNotFoundException e) { -- log.fine(url + ": " + apiName + " is not available in this context: " + getClassLoader()); -- continue; -- } -- -- try { -- serializerClass = Class.forName(serializerName, false, classLoader); -- } catch (ClassNotFoundException e) { -- log.fine(url + ": " + serializerName + " is not available in this context: " + getClassLoader()); -- continue; -- } -- -- if (! type.isAssignableFrom(serializerClass)) -- throw new HessianException(url + ": " + serializerClass.getName() + " is invalid because it does not implement " + type.getName()); -- -- classMap.put(apiClass, serializerClass); -- } -- } finally { -- if (is != null) -- is.close(); -- } -- } -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new HessianException(e); -- } -- } -- -- private static void addBasic(Class cl, String typeName, int type) -- { -- _staticSerializerMap.put(cl.getName(), new BasicSerializer(type)); -- -- Deserializer deserializer = new BasicDeserializer(type); -- _staticDeserializerMap.put(cl.getName(), deserializer); -- _staticClassNameMap.put(typeName, deserializer); -- } -- -- static { -- _staticSerializerMap = new HashMap(); -- _staticDeserializerMap = new HashMap(); -- _staticClassNameMap = new HashMap(); -- -- FieldDeserializer2Factory fieldFactory = FieldDeserializer2Factory.create(); -- -- addBasic(void.class, "void", BasicSerializer.NULL); -- -- addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); -- addBasic(Byte.class, "byte", BasicSerializer.BYTE); -- addBasic(Short.class, "short", BasicSerializer.SHORT); -- addBasic(Integer.class, "int", BasicSerializer.INTEGER); -- addBasic(Long.class, "long", BasicSerializer.LONG); -- addBasic(Float.class, "float", BasicSerializer.FLOAT); -- addBasic(Double.class, "double", BasicSerializer.DOUBLE); -- addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); -- addBasic(String.class, "string", BasicSerializer.STRING); -- addBasic(Object.class, "object", BasicSerializer.OBJECT); -- addBasic(java.util.Date.class, "date", BasicSerializer.DATE); -- -- addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); -- addBasic(byte.class, "byte", BasicSerializer.BYTE); -- addBasic(short.class, "short", BasicSerializer.SHORT); -- addBasic(int.class, "int", BasicSerializer.INTEGER); -- addBasic(long.class, "long", BasicSerializer.LONG); -- addBasic(float.class, "float", BasicSerializer.FLOAT); -- addBasic(double.class, "double", BasicSerializer.DOUBLE); -- addBasic(char.class, "char", BasicSerializer.CHARACTER); -- -- addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); -- addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); -- _staticSerializerMap.put(byte[].class.getName(), ByteArraySerializer.SER); -- addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); -- addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); -- addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); -- addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); -- addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); -- addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); -- addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); -- addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); -- -- Deserializer objectDeserializer = new JavaDeserializer(Object.class, fieldFactory); -- _staticDeserializerMap.put("object", objectDeserializer); -- _staticClassNameMap.put("object", objectDeserializer); -- -- _staticSerializerMap.put(Class.class.getName(), new ClassSerializer()); -- -- _staticDeserializerMap.put(Number.class.getName(), new BasicDeserializer(BasicSerializer.NUMBER)); -- -- /* -- for (Class cl : new Class[] { BigDecimal.class, File.class, ObjectName.class }) { -- _staticSerializerMap.put(cl, StringValueSerializer.SER); -- _staticDeserializerMap.put(cl, new StringValueDeserializer(cl)); -- } -- -- _staticSerializerMap.put(ObjectName.class, StringValueSerializer.SER); -- try { -- _staticDeserializerMap.put(ObjectName.class, -- new StringValueDeserializer(ObjectName.class)); -- } catch (Throwable e) { -- } -- */ -- -- _staticSerializerMap.put(InetAddress.class.getName(), -- InetAddressSerializer.create()); -- -- _staticSerializerMap.put(java.sql.Date.class.getName(), -- new SqlDateSerializer()); -- _staticSerializerMap.put(java.sql.Time.class.getName(), -- new SqlDateSerializer()); -- _staticSerializerMap.put(java.sql.Timestamp.class.getName(), -- new SqlDateSerializer()); -- -- _staticDeserializerMap.put(java.sql.Date.class.getName(), -- new SqlDateDeserializer(java.sql.Date.class)); -- _staticDeserializerMap.put(java.sql.Time.class.getName(), -- new SqlDateDeserializer(java.sql.Time.class)); -- _staticDeserializerMap.put(java.sql.Timestamp.class.getName(), -- new SqlDateDeserializer(java.sql.Timestamp.class)); -- -- // hessian/3bb5 -- _staticDeserializerMap.put(StackTraceElement.class.getName(), -- new StackTraceElementDeserializer(fieldFactory)); -- -- ClassLoader systemClassLoader = null; -- try { -- systemClassLoader = ClassLoader.getSystemClassLoader(); -- } catch (Exception e) { -- } -- -- _systemClassLoader = systemClassLoader; -- } --} -- -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.InputStream; -+import java.lang.ref.SoftReference; -+import java.lang.ref.WeakReference; -+import java.net.InetAddress; -+import java.net.URL; -+import java.util.Enumeration; -+import java.util.HashMap; -+import java.util.HashSet; -+import java.util.Map; -+import java.util.Properties; -+import java.util.WeakHashMap; -+import java.util.concurrent.ConcurrentHashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * The classloader-specific Factory for returning serialization -+ */ -+public class ContextSerializerFactory -+{ -+ private static final Logger log -+ = Logger.getLogger(ContextSerializerFactory.class.getName()); -+ -+ private static Deserializer OBJECT_DESERIALIZER -+ = new BasicDeserializer(BasicDeserializer.OBJECT); -+ -+ private static final WeakHashMap> -+ _contextRefMap -+ = new WeakHashMap>(); -+ -+ private static final ClassLoader _systemClassLoader; -+ -+ private static HashMap _staticSerializerMap; -+ private static HashMap _staticDeserializerMap; -+ private static HashMap _staticClassNameMap; -+ -+ private ContextSerializerFactory _parent; -+ private WeakReference _loaderRef; -+ -+ private final HashSet _serializerFiles = new HashSet(); -+ private final HashSet _deserializerFiles = new HashSet(); -+ -+ private final HashMap _serializerClassMap -+ = new HashMap(); -+ -+ private final ConcurrentHashMap _customSerializerMap -+ = new ConcurrentHashMap(); -+ -+ private final HashMap,Serializer> _serializerInterfaceMap -+ = new HashMap,Serializer>(); -+ -+ private final HashMap _deserializerClassMap -+ = new HashMap(); -+ -+ private final HashMap _deserializerClassNameMap -+ = new HashMap(); -+ -+ private final ConcurrentHashMap _customDeserializerMap -+ = new ConcurrentHashMap(); -+ -+ private final HashMap,Deserializer> _deserializerInterfaceMap -+ = new HashMap,Deserializer>(); -+ -+ public ContextSerializerFactory(ContextSerializerFactory parent, -+ ClassLoader loader) -+ { -+ if (loader == null) -+ loader = _systemClassLoader; -+ -+ _loaderRef = new WeakReference(loader); -+ -+ init(); -+ } -+ -+ public static ContextSerializerFactory create() -+ { -+ return create(Thread.currentThread().getContextClassLoader()); -+ } -+ -+ public static ContextSerializerFactory create(ClassLoader loader) -+ { -+ synchronized (_contextRefMap) { -+ SoftReference factoryRef -+ = _contextRefMap.get(loader); -+ -+ ContextSerializerFactory factory = null; -+ -+ if (factoryRef != null) -+ factory = factoryRef.get(); -+ -+ if (factory == null) { -+ ContextSerializerFactory parent = null; -+ -+ if (loader != null) -+ parent = create(loader.getParent()); -+ -+ factory = new ContextSerializerFactory(parent, loader); -+ factoryRef = new SoftReference(factory); -+ -+ _contextRefMap.put(loader, factoryRef); -+ } -+ -+ return factory; -+ } -+ } -+ -+ public ClassLoader getClassLoader() -+ { -+ WeakReference loaderRef = _loaderRef; -+ -+ if (loaderRef != null) -+ return loaderRef.get(); -+ else -+ return null; -+ } -+ -+ /** -+ * Returns the serializer for a given class. -+ */ -+ public Serializer getSerializer(String className) -+ { -+ Serializer serializer = _serializerClassMap.get(className); -+ -+ if (serializer == AbstractSerializer.NULL) -+ return null; -+ else -+ return serializer; -+ } -+ -+ /** -+ * Returns a custom serializer the class -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ public Serializer getCustomSerializer(Class cl) -+ { -+ Serializer serializer = _customSerializerMap.get(cl.getName()); -+ -+ if (serializer == AbstractSerializer.NULL) -+ return null; -+ else if (serializer != null) -+ return serializer; -+ -+ try { -+ String className = cl.getName() + "HessianSerializer"; -+ -+ if (cl.getName().equals("java.util.Locale")) { -+ className = "com.caucho.hessian.io.LocaleHessianSerializer"; -+ } -+ -+ Class serClass = Class.forName(className, false, -+ Thread.currentThread().getContextClassLoader()); -+ -+ Serializer ser = (Serializer) serClass.newInstance(); -+ -+ _customSerializerMap.put(cl.getName(), ser); -+ -+ return ser; -+ } catch (ClassNotFoundException e) { -+ log.log(Level.ALL, e.toString(), e); -+ } catch (Exception e) { -+ throw new HessianException(e); -+ } -+ -+ _customSerializerMap.put(cl.getName(), AbstractSerializer.NULL); -+ -+ return null; -+ } -+ -+ /** -+ * Returns the deserializer for a given class. -+ */ -+ public Deserializer getDeserializer(String className) -+ { -+ Deserializer deserializer = _deserializerClassMap.get(className); -+ -+ if (deserializer != null && deserializer != AbstractDeserializer.NULL) { -+ return deserializer; -+ } -+ -+ deserializer = _deserializerInterfaceMap.get(className); -+ -+ if (deserializer != null && deserializer != AbstractDeserializer.NULL) { -+ return deserializer; -+ } -+ -+ return null; -+ } -+ -+ /** -+ * Returns a custom deserializer the class -+ * -+ * @param cl the class of the object that needs to be deserialized. -+ * -+ * @return a deserializer object for the deserialization. -+ */ -+ public Deserializer getCustomDeserializer(Class cl) -+ { -+ Deserializer deserializer = _customDeserializerMap.get(cl.getName()); -+ -+ if (deserializer == AbstractDeserializer.NULL) -+ return null; -+ else if (deserializer != null) -+ return deserializer; -+ -+ try { -+ String className = cl.getName() + "HessianDeserializer"; -+ -+ if (cl.getName().equals("java.util.Locale")) { -+ className = "com.caucho.hessian.io.LocaleHessianDeserializer"; -+ } -+ -+ Class serClass = Class.forName(className, false, -+ Thread.currentThread().getContextClassLoader()); -+ -+ Deserializer ser = (Deserializer) serClass.newInstance(); -+ -+ _customDeserializerMap.put(cl.getName(), ser); -+ -+ return ser; -+ } catch (ClassNotFoundException e) { -+ log.log(Level.ALL, e.toString(), e); -+ } catch (Exception e) { -+ throw new HessianException(e); -+ } -+ -+ _customDeserializerMap.put(cl.getName(), AbstractDeserializer.NULL); -+ -+ return null; -+ } -+ -+ /** -+ * Initialize the factory -+ */ -+ private void init() -+ { -+ if (_parent != null) { -+ _serializerFiles.addAll(_parent._serializerFiles); -+ _deserializerFiles.addAll(_parent._deserializerFiles); -+ -+ _serializerClassMap.putAll(_parent._serializerClassMap); -+ _deserializerClassMap.putAll(_parent._deserializerClassMap); -+ } -+ -+ if (_parent == null) { -+ _serializerClassMap.putAll(_staticSerializerMap); -+ _deserializerClassMap.putAll(_staticDeserializerMap); -+ _deserializerClassNameMap.putAll(_staticClassNameMap); -+ } -+ -+ HashMap classMap; -+ -+ classMap = new HashMap(); -+ initSerializerFiles("META-INF/hessian/serializers", -+ _serializerFiles, -+ classMap, -+ Serializer.class); -+ -+ for (Map.Entry entry : classMap.entrySet()) { -+ try { -+ Serializer ser = (Serializer) entry.getValue().newInstance(); -+ -+ if (entry.getKey().isInterface()) -+ _serializerInterfaceMap.put(entry.getKey(), ser); -+ else -+ _serializerClassMap.put(entry.getKey().getName(), ser); -+ } catch (Exception e) { -+ throw new HessianException(e); -+ } -+ } -+ -+ classMap = new HashMap(); -+ initSerializerFiles("META-INF/hessian/deserializers", -+ _deserializerFiles, -+ classMap, -+ Deserializer.class); -+ -+ for (Map.Entry entry : classMap.entrySet()) { -+ try { -+ Deserializer ser = (Deserializer) entry.getValue().newInstance(); -+ -+ if (entry.getKey().isInterface()) -+ _deserializerInterfaceMap.put(entry.getKey(), ser); -+ else { -+ _deserializerClassMap.put(entry.getKey().getName(), ser); -+ } -+ } catch (Exception e) { -+ throw new HessianException(e); -+ } -+ } -+ } -+ -+ private void initSerializerFiles(String fileName, -+ HashSet fileList, -+ HashMap classMap, -+ Class type) -+ { -+ try { -+ ClassLoader classLoader = getClassLoader(); -+ -+ // on systems with the security manager enabled, the system classloader -+ // is null -+ if (classLoader == null) -+ return; -+ -+ Enumeration iter; -+ -+ iter = classLoader.getResources(fileName); -+ while (iter.hasMoreElements()) { -+ URL url = (URL) iter.nextElement(); -+ -+ if (fileList.contains(url.toString())) -+ continue; -+ -+ fileList.add(url.toString()); -+ -+ InputStream is = null; -+ try { -+ is = url.openStream(); -+ -+ Properties props = new Properties(); -+ props.load(is); -+ -+ for (Map.Entry entry : props.entrySet()) { -+ String apiName = (String) entry.getKey(); -+ String serializerName = (String) entry.getValue(); -+ -+ Class apiClass = null; -+ Class serializerClass = null; -+ -+ try { -+ apiClass = Class.forName(apiName, false, classLoader); -+ } catch (ClassNotFoundException e) { -+ log.fine(url + ": " + apiName + " is not available in this context: " + getClassLoader()); -+ continue; -+ } -+ -+ try { -+ serializerClass = Class.forName(serializerName, false, classLoader); -+ } catch (ClassNotFoundException e) { -+ log.fine(url + ": " + serializerName + " is not available in this context: " + getClassLoader()); -+ continue; -+ } -+ -+ if (! type.isAssignableFrom(serializerClass)) -+ throw new HessianException(url + ": " + serializerClass.getName() + " is invalid because it does not implement " + type.getName()); -+ -+ classMap.put(apiClass, serializerClass); -+ } -+ } finally { -+ if (is != null) -+ is.close(); -+ } -+ } -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new HessianException(e); -+ } -+ } -+ -+ private static void addBasic(Class cl, String typeName, int type) -+ { -+ _staticSerializerMap.put(cl.getName(), new BasicSerializer(type)); -+ -+ Deserializer deserializer = new BasicDeserializer(type); -+ _staticDeserializerMap.put(cl.getName(), deserializer); -+ _staticClassNameMap.put(typeName, deserializer); -+ } -+ -+ static { -+ _staticSerializerMap = new HashMap(); -+ _staticDeserializerMap = new HashMap(); -+ _staticClassNameMap = new HashMap(); -+ -+ FieldDeserializer2Factory fieldFactory = FieldDeserializer2Factory.create(); -+ -+ addBasic(void.class, "void", BasicSerializer.NULL); -+ -+ addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); -+ addBasic(Byte.class, "byte", BasicSerializer.BYTE); -+ addBasic(Short.class, "short", BasicSerializer.SHORT); -+ addBasic(Integer.class, "int", BasicSerializer.INTEGER); -+ addBasic(Long.class, "long", BasicSerializer.LONG); -+ addBasic(Float.class, "float", BasicSerializer.FLOAT); -+ addBasic(Double.class, "double", BasicSerializer.DOUBLE); -+ addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); -+ addBasic(String.class, "string", BasicSerializer.STRING); -+ addBasic(Object.class, "object", BasicSerializer.OBJECT); -+ addBasic(java.util.Date.class, "date", BasicSerializer.DATE); -+ -+ addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); -+ addBasic(byte.class, "byte", BasicSerializer.BYTE); -+ addBasic(short.class, "short", BasicSerializer.SHORT); -+ addBasic(int.class, "int", BasicSerializer.INTEGER); -+ addBasic(long.class, "long", BasicSerializer.LONG); -+ addBasic(float.class, "float", BasicSerializer.FLOAT); -+ addBasic(double.class, "double", BasicSerializer.DOUBLE); -+ addBasic(char.class, "char", BasicSerializer.CHARACTER); -+ -+ addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); -+ addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); -+ _staticSerializerMap.put(byte[].class.getName(), ByteArraySerializer.SER); -+ addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); -+ addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); -+ addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); -+ addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); -+ addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); -+ addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); -+ addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); -+ addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); -+ -+ Deserializer objectDeserializer = new JavaDeserializer(Object.class, fieldFactory); -+ _staticDeserializerMap.put("object", objectDeserializer); -+ _staticClassNameMap.put("object", objectDeserializer); -+ -+ _staticSerializerMap.put(Class.class.getName(), new ClassSerializer()); -+ -+ _staticDeserializerMap.put(Number.class.getName(), new BasicDeserializer(BasicSerializer.NUMBER)); -+ -+ /* -+ for (Class cl : new Class[] { BigDecimal.class, File.class, ObjectName.class }) { -+ _staticSerializerMap.put(cl, StringValueSerializer.SER); -+ _staticDeserializerMap.put(cl, new StringValueDeserializer(cl)); -+ } -+ -+ _staticSerializerMap.put(ObjectName.class, StringValueSerializer.SER); -+ try { -+ _staticDeserializerMap.put(ObjectName.class, -+ new StringValueDeserializer(ObjectName.class)); -+ } catch (Throwable e) { -+ } -+ */ -+ -+ _staticSerializerMap.put(InetAddress.class.getName(), -+ InetAddressSerializer.create()); -+ -+ _staticSerializerMap.put(java.sql.Date.class.getName(), -+ new SqlDateSerializer()); -+ _staticSerializerMap.put(java.sql.Time.class.getName(), -+ new SqlDateSerializer()); -+ _staticSerializerMap.put(java.sql.Timestamp.class.getName(), -+ new SqlDateSerializer()); -+ -+ _staticDeserializerMap.put(java.sql.Date.class.getName(), -+ new SqlDateDeserializer(java.sql.Date.class)); -+ _staticDeserializerMap.put(java.sql.Time.class.getName(), -+ new SqlDateDeserializer(java.sql.Time.class)); -+ _staticDeserializerMap.put(java.sql.Timestamp.class.getName(), -+ new SqlDateDeserializer(java.sql.Timestamp.class)); -+ -+ // hessian/3bb5 -+ _staticDeserializerMap.put(StackTraceElement.class.getName(), -+ new StackTraceElementDeserializer(fieldFactory)); -+ -+ ClassLoader systemClassLoader = null; -+ try { -+ systemClassLoader = ClassLoader.getSystemClassLoader(); -+ } catch (Exception e) { -+ } -+ -+ _systemClassLoader = systemClassLoader; -+ } -+} -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Deflation.java hessian-4.0.65-fix/com/caucho/hessian/io/Deflation.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Deflation.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Deflation.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,205 +1,205 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.*; --import java.util.zip.*; -- --import java.io.*; -- --import com.caucho.hessian.io.*; -- --public class Deflation extends HessianEnvelope { -- public Deflation() -- { -- } -- -- public Hessian2Output wrap(Hessian2Output out) -- throws IOException -- { -- OutputStream os = new DeflateOutputStream(out); -- -- Hessian2Output filterOut = new Hessian2Output(os); -- -- filterOut.setCloseStreamOnClose(true); -- -- return filterOut; -- } -- -- public Hessian2Input unwrap(Hessian2Input in) -- throws IOException -- { -- int version = in.readEnvelope(); -- -- String method = in.readMethod(); -- -- if (! method.equals(getClass().getName())) -- throw new IOException("expected hessian Envelope method '" + -- getClass().getName() + "' at '" + method + "'"); -- -- return unwrapHeaders(in); -- } -- -- public Hessian2Input unwrapHeaders(Hessian2Input in) -- throws IOException -- { -- InputStream is = new DeflateInputStream(in); -- -- Hessian2Input filter = new Hessian2Input(is); -- -- filter.setCloseStreamOnClose(true); -- -- return filter; -- } -- -- static class DeflateOutputStream extends OutputStream { -- private Hessian2Output _out; -- private OutputStream _bodyOut; -- private DeflaterOutputStream _deflateOut; -- -- DeflateOutputStream(Hessian2Output out) -- throws IOException -- { -- _out = out; -- -- _out.startEnvelope(Deflation.class.getName()); -- -- _out.writeInt(0); -- -- _bodyOut = _out.getBytesOutputStream(); -- -- _deflateOut = new DeflaterOutputStream(_bodyOut); -- } -- -- public void write(int ch) -- throws IOException -- { -- _deflateOut.write(ch); -- } -- -- public void write(byte []buffer, int offset, int length) -- throws IOException -- { -- _deflateOut.write(buffer, offset, length); -- } -- -- public void close() -- throws IOException -- { -- Hessian2Output out = _out; -- _out = null; -- -- if (out != null) { -- _deflateOut.close(); -- _bodyOut.close(); -- -- out.writeInt(0); -- -- out.completeEnvelope(); -- -- out.close(); -- } -- } -- } -- -- static class DeflateInputStream extends InputStream { -- private Hessian2Input _in; -- -- private InputStream _bodyIn; -- private InflaterInputStream _inflateIn; -- -- DeflateInputStream(Hessian2Input in) -- throws IOException -- { -- _in = in; -- -- int len = in.readInt(); -- -- if (len != 0) -- throw new IOException("expected no headers"); -- -- _bodyIn = _in.readInputStream(); -- -- _inflateIn = new InflaterInputStream(_bodyIn); -- } -- -- public int read() -- throws IOException -- { -- return _inflateIn.read(); -- } -- -- public int read(byte []buffer, int offset, int length) -- throws IOException -- { -- return _inflateIn.read(buffer, offset, length); -- } -- -- public void close() -- throws IOException -- { -- Hessian2Input in = _in; -- _in = null; -- -- if (in != null) { -- _inflateIn.close(); -- _bodyIn.close(); -- -- int len = in.readInt(); -- -- if (len != 0) -- throw new IOException("Unexpected footer"); -- -- in.completeEnvelope(); -- -- in.close(); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.*; -+import java.util.zip.*; -+ -+import java.io.*; -+ -+import com.caucho.hessian.io.*; -+ -+public class Deflation extends HessianEnvelope { -+ public Deflation() -+ { -+ } -+ -+ public Hessian2Output wrap(Hessian2Output out) -+ throws IOException -+ { -+ OutputStream os = new DeflateOutputStream(out); -+ -+ Hessian2Output filterOut = new Hessian2Output(os); -+ -+ filterOut.setCloseStreamOnClose(true); -+ -+ return filterOut; -+ } -+ -+ public Hessian2Input unwrap(Hessian2Input in) -+ throws IOException -+ { -+ int version = in.readEnvelope(); -+ -+ String method = in.readMethod(); -+ -+ if (! method.equals(getClass().getName())) -+ throw new IOException("expected hessian Envelope method '" + -+ getClass().getName() + "' at '" + method + "'"); -+ -+ return unwrapHeaders(in); -+ } -+ -+ public Hessian2Input unwrapHeaders(Hessian2Input in) -+ throws IOException -+ { -+ InputStream is = new DeflateInputStream(in); -+ -+ Hessian2Input filter = new Hessian2Input(is); -+ -+ filter.setCloseStreamOnClose(true); -+ -+ return filter; -+ } -+ -+ static class DeflateOutputStream extends OutputStream { -+ private Hessian2Output _out; -+ private OutputStream _bodyOut; -+ private DeflaterOutputStream _deflateOut; -+ -+ DeflateOutputStream(Hessian2Output out) -+ throws IOException -+ { -+ _out = out; -+ -+ _out.startEnvelope(Deflation.class.getName()); -+ -+ _out.writeInt(0); -+ -+ _bodyOut = _out.getBytesOutputStream(); -+ -+ _deflateOut = new DeflaterOutputStream(_bodyOut); -+ } -+ -+ public void write(int ch) -+ throws IOException -+ { -+ _deflateOut.write(ch); -+ } -+ -+ public void write(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ _deflateOut.write(buffer, offset, length); -+ } -+ -+ public void close() -+ throws IOException -+ { -+ Hessian2Output out = _out; -+ _out = null; -+ -+ if (out != null) { -+ _deflateOut.close(); -+ _bodyOut.close(); -+ -+ out.writeInt(0); -+ -+ out.completeEnvelope(); -+ -+ out.close(); -+ } -+ } -+ } -+ -+ static class DeflateInputStream extends InputStream { -+ private Hessian2Input _in; -+ -+ private InputStream _bodyIn; -+ private InflaterInputStream _inflateIn; -+ -+ DeflateInputStream(Hessian2Input in) -+ throws IOException -+ { -+ _in = in; -+ -+ int len = in.readInt(); -+ -+ if (len != 0) -+ throw new IOException("expected no headers"); -+ -+ _bodyIn = _in.readInputStream(); -+ -+ _inflateIn = new InflaterInputStream(_bodyIn); -+ } -+ -+ public int read() -+ throws IOException -+ { -+ return _inflateIn.read(); -+ } -+ -+ public int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ return _inflateIn.read(buffer, offset, length); -+ } -+ -+ public void close() -+ throws IOException -+ { -+ Hessian2Input in = _in; -+ _in = null; -+ -+ if (in != null) { -+ _inflateIn.close(); -+ _bodyIn.close(); -+ -+ int len = in.readInt(); -+ -+ if (len != 0) -+ throw new IOException("Unexpected footer"); -+ -+ in.completeEnvelope(); -+ -+ in.close(); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Deserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/Deserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Deserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Deserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,108 +1,108 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Deserializing an object. Custom deserializers should extend -- * from AbstractDeserializer to avoid issues with signature -- * changes. -- */ --public interface Deserializer { -- public Class getType(); -- -- public boolean isReadResolve(); -- -- public Object readObject(AbstractHessianInput in) -- throws IOException; -- -- public Object readList(AbstractHessianInput in, int length) -- throws IOException; -- -- public Object readLengthList(AbstractHessianInput in, int length) -- throws IOException; -- -- public Object readMap(AbstractHessianInput in) -- throws IOException; -- -- /** -- * Creates an empty array for the deserializers field -- * entries. -- * -- * @param len number of fields to be read -- * @return empty array of the proper field type. -- */ -- public Object []createFields(int len); -- -- /** -- * Returns the deserializer's field reader for the given name. -- * -- * @param name the field name -- * @return the deserializer's internal field reader -- */ -- public Object createField(String name); -- -- /** -- * Reads the object from the input stream, given the field -- * definition. -- * -- * @param in the input stream -- * @param fields the deserializer's own field marshal -- * @return the new object -- * @throws IOException -- */ -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException; -- -- public Object readObject(AbstractHessianInput in, -- String []fieldNames) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Deserializing an object. Custom deserializers should extend -+ * from AbstractDeserializer to avoid issues with signature -+ * changes. -+ */ -+public interface Deserializer { -+ public Class getType(); -+ -+ public boolean isReadResolve(); -+ -+ public Object readObject(AbstractHessianInput in) -+ throws IOException; -+ -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException; -+ -+ public Object readLengthList(AbstractHessianInput in, int length) -+ throws IOException; -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException; -+ -+ /** -+ * Creates an empty array for the deserializers field -+ * entries. -+ * -+ * @param len number of fields to be read -+ * @return empty array of the proper field type. -+ */ -+ public Object []createFields(int len); -+ -+ /** -+ * Returns the deserializer's field reader for the given name. -+ * -+ * @param name the field name -+ * @return the deserializer's internal field reader -+ */ -+ public Object createField(String name); -+ -+ /** -+ * Reads the object from the input stream, given the field -+ * definition. -+ * -+ * @param in the input stream -+ * @param fields the deserializer's own field marshal -+ * @return the new object -+ * @throws IOException -+ */ -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException; -+ -+ public Object readObject(AbstractHessianInput in, -+ String []fieldNames) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/EnumDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,140 +1,140 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Method; -- --/** -- * Deserializing an enum valued object -- */ --public class EnumDeserializer extends AbstractDeserializer { -- private Class _enumType; -- private Method _valueOf; -- -- public EnumDeserializer(Class cl) -- { -- // hessian/33b[34], hessian/3bb[78] -- if (cl.isEnum()) -- _enumType = cl; -- else if (cl.getSuperclass().isEnum()) -- _enumType = cl.getSuperclass(); -- else -- throw new RuntimeException("Class " + cl.getName() + " is not an enum"); -- -- try { -- _valueOf = _enumType.getMethod("valueOf", -- new Class[] { Class.class, String.class }); -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- public Class getType() -- { -- return _enumType; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String name = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if (key.equals("name")) -- name = in.readString(); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- Object obj = create(name); -- -- in.addRef(obj); -- -- return obj; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, Object []fields) -- throws IOException -- { -- String []fieldNames = (String []) fields; -- String name = null; -- -- for (int i = 0; i < fieldNames.length; i++) { -- if ("name".equals(fieldNames[i])) -- name = in.readString(); -- else -- in.readObject(); -- } -- -- Object obj = create(name); -- -- in.addRef(obj); -- -- return obj; -- } -- -- private Object create(String name) -- throws IOException -- { -- if (name == null) -- throw new IOException(_enumType.getName() + " expects name."); -- -- try { -- return _valueOf.invoke(null, _enumType, name); -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Method; -+ -+/** -+ * Deserializing an enum valued object -+ */ -+public class EnumDeserializer extends AbstractDeserializer { -+ private Class _enumType; -+ private Method _valueOf; -+ -+ public EnumDeserializer(Class cl) -+ { -+ // hessian/33b[34], hessian/3bb[78] -+ if (cl.isEnum()) -+ _enumType = cl; -+ else if (cl.getSuperclass().isEnum()) -+ _enumType = cl.getSuperclass(); -+ else -+ throw new RuntimeException("Class " + cl.getName() + " is not an enum"); -+ -+ try { -+ _valueOf = _enumType.getMethod("valueOf", -+ new Class[] { Class.class, String.class }); -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ public Class getType() -+ { -+ return _enumType; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String name = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if (key.equals("name")) -+ name = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object obj = create(name); -+ -+ in.addRef(obj); -+ -+ return obj; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, Object []fields) -+ throws IOException -+ { -+ String []fieldNames = (String []) fields; -+ String name = null; -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ if ("name".equals(fieldNames[i])) -+ name = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ Object obj = create(name); -+ -+ in.addRef(obj); -+ -+ return obj; -+ } -+ -+ private Object create(String name) -+ throws IOException -+ { -+ if (name == null) -+ throw new IOException(_enumType.getName() + " expects name."); -+ -+ try { -+ return _valueOf.invoke(null, _enumType, name); -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/EnumSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,108 +1,108 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Method; -- --/** -- * Serializing an object for known object types. -- */ --public class EnumSerializer extends AbstractSerializer { -- private Method _name; -- -- public EnumSerializer(Class cl) -- { -- // hessian/32b[12], hessian/3ab[23] -- if (! cl.isEnum() && cl.getSuperclass().isEnum()) -- cl = cl.getSuperclass(); -- -- try { -- _name = cl.getMethod("name", new Class[0]); -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) -- return; -- -- Class cl = obj.getClass(); -- -- if (! cl.isEnum() && cl.getSuperclass().isEnum()) -- cl = cl.getSuperclass(); -- -- String name = null; -- try { -- name = (String) _name.invoke(obj, (Object[]) null); -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref < -1) { -- out.writeString("name"); -- out.writeString(name); -- out.writeMapEnd(); -- } -- else { -- if (ref == -1) { -- out.writeClassFieldLength(1); -- out.writeString("name"); -- out.writeObjectBegin(cl.getName()); -- } -- -- out.writeString(name); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Method; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class EnumSerializer extends AbstractSerializer { -+ private Method _name; -+ -+ public EnumSerializer(Class cl) -+ { -+ // hessian/32b[12], hessian/3ab[23] -+ if (! cl.isEnum() && cl.getSuperclass().isEnum()) -+ cl = cl.getSuperclass(); -+ -+ try { -+ _name = cl.getMethod("name", new Class[0]); -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ Class cl = obj.getClass(); -+ -+ if (! cl.isEnum() && cl.getSuperclass().isEnum()) -+ cl = cl.getSuperclass(); -+ -+ String name = null; -+ try { -+ name = (String) _name.invoke(obj, (Object[]) null); -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref < -1) { -+ out.writeString("name"); -+ out.writeString(name); -+ out.writeMapEnd(); -+ } -+ else { -+ if (ref == -1) { -+ out.writeClassFieldLength(1); -+ out.writeString("name"); -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ out.writeString(name); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumerationDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/EnumerationDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,84 +1,84 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.Vector; -- --/** -- * Deserializing a JDK 1.2 Collection. -- */ --public class EnumerationDeserializer extends AbstractListDeserializer { -- private static EnumerationDeserializer _deserializer; -- -- public static EnumerationDeserializer create() -- { -- if (_deserializer == null) -- _deserializer = new EnumerationDeserializer(); -- -- return _deserializer; -- } -- -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- Vector list = new Vector(); -- -- in.addRef(list); -- -- while (! in.isEnd()) -- list.add(in.readObject()); -- -- in.readEnd(); -- -- return list.elements(); -- } --} -- -- -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.Vector; -+ -+/** -+ * Deserializing a JDK 1.2 Collection. -+ */ -+public class EnumerationDeserializer extends AbstractListDeserializer { -+ private static EnumerationDeserializer _deserializer; -+ -+ public static EnumerationDeserializer create() -+ { -+ if (_deserializer == null) -+ _deserializer = new EnumerationDeserializer(); -+ -+ return _deserializer; -+ } -+ -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ Vector list = new Vector(); -+ -+ in.addRef(list); -+ -+ while (! in.isEnd()) -+ list.add(in.readObject()); -+ -+ in.readEnd(); -+ -+ return list.elements(); -+ } -+} -+ -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnumerationSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/EnumerationSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/EnumerationSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,84 +1,84 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.Enumeration; -- --/** -- * Serializing a JDK 1.2 Enumeration. -- */ --public class EnumerationSerializer extends AbstractSerializer { -- private static EnumerationSerializer _serializer; -- -- public static EnumerationSerializer create() -- { -- if (_serializer == null) -- _serializer = new EnumerationSerializer(); -- -- return _serializer; -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- Enumeration iter = (Enumeration) obj; -- -- boolean hasEnd = out.writeListBegin(-1, null); -- -- while (iter.hasMoreElements()) { -- Object value = iter.nextElement(); -- -- out.writeObject(value); -- } -- -- if (hasEnd) -- out.writeListEnd(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.Enumeration; -+ -+/** -+ * Serializing a JDK 1.2 Enumeration. -+ */ -+public class EnumerationSerializer extends AbstractSerializer { -+ private static EnumerationSerializer _serializer; -+ -+ public static EnumerationSerializer create() -+ { -+ if (_serializer == null) -+ _serializer = new EnumerationSerializer(); -+ -+ return _serializer; -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ Enumeration iter = (Enumeration) obj; -+ -+ boolean hasEnd = out.writeListBegin(-1, null); -+ -+ while (iter.hasMoreElements()) { -+ Object value = iter.nextElement(); -+ -+ out.writeObject(value); -+ } -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/EnvelopeFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/EnvelopeFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/EnvelopeFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/EnvelopeFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,57 +1,57 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.logging.*; -- --public class EnvelopeFactory --{ -- private static final Logger log -- = Logger.getLogger(EnvelopeFactory.class.getName()); --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.logging.*; -+ -+public class EnvelopeFactory -+{ -+ private static final Logger log -+ = Logger.getLogger(EnvelopeFactory.class.getName()); -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ExtSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/ExtSerializerFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ExtSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ExtSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,107 +1,107 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.HashMap; -- --/** -- * Factory for returning serialization methods. -- */ --public class ExtSerializerFactory extends AbstractSerializerFactory { -- private HashMap _serializerMap = new HashMap(); -- private HashMap _deserializerMap = new HashMap(); -- -- /** -- * Adds a serializer. -- * -- * @param cl the class of the serializer -- * @param serializer the serializer -- */ -- public void addSerializer(Class cl, Serializer serializer) -- { -- _serializerMap.put(cl, serializer); -- } -- -- /** -- * Adds a deserializer. -- * -- * @param cl the class of the deserializer -- * @param deserializer the deserializer -- */ -- public void addDeserializer(Class cl, Deserializer deserializer) -- { -- _deserializerMap.put(cl, deserializer); -- } -- -- /** -- * Returns the serializer for a class. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- public Serializer getSerializer(Class cl) -- throws HessianProtocolException -- { -- return (Serializer) _serializerMap.get(cl); -- } -- -- /** -- * Returns the deserializer for a class. -- * -- * @param cl the class of the object that needs to be deserialized. -- * -- * @return a deserializer object for the serialization. -- */ -- public Deserializer getDeserializer(Class cl) -- throws HessianProtocolException -- { -- return (Deserializer) _deserializerMap.get(cl); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.HashMap; -+ -+/** -+ * Factory for returning serialization methods. -+ */ -+public class ExtSerializerFactory extends AbstractSerializerFactory { -+ private HashMap _serializerMap = new HashMap(); -+ private HashMap _deserializerMap = new HashMap(); -+ -+ /** -+ * Adds a serializer. -+ * -+ * @param cl the class of the serializer -+ * @param serializer the serializer -+ */ -+ public void addSerializer(Class cl, Serializer serializer) -+ { -+ _serializerMap.put(cl, serializer); -+ } -+ -+ /** -+ * Adds a deserializer. -+ * -+ * @param cl the class of the deserializer -+ * @param deserializer the deserializer -+ */ -+ public void addDeserializer(Class cl, Deserializer deserializer) -+ { -+ _deserializerMap.put(cl, deserializer); -+ } -+ -+ /** -+ * Returns the serializer for a class. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ public Serializer getSerializer(Class cl) -+ throws HessianProtocolException -+ { -+ return (Serializer) _serializerMap.get(cl); -+ } -+ -+ /** -+ * Returns the deserializer for a class. -+ * -+ * @param cl the class of the object that needs to be deserialized. -+ * -+ * @return a deserializer object for the serialization. -+ */ -+ public Deserializer getDeserializer(Class cl) -+ throws HessianProtocolException -+ { -+ return (Deserializer) _deserializerMap.get(cl); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2.java hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2.java ---- hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,59 +1,59 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing an object for known object types. -- */ --public interface FieldDeserializer2 { -- void deserialize(AbstractHessianInput in, Object obj) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public interface FieldDeserializer2 { -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2Factory.java hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2Factory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2Factory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2Factory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,500 +1,500 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Field; --import java.lang.reflect.Modifier; --import java.util.logging.Logger; -- --/** -- * Serializing an object for known object types. -- */ --public class FieldDeserializer2Factory { -- private static final Logger log -- = Logger.getLogger(JavaDeserializer.class.getName()); -- -- public static FieldDeserializer2Factory create() -- { -- boolean isEnableUnsafeSerializer = (UnsafeSerializer.isEnabled() -- && UnsafeDeserializer.isEnabled()); -- -- if (isEnableUnsafeSerializer) { -- return new FieldDeserializer2FactoryUnsafe(); -- } -- else { -- return new FieldDeserializer2Factory(); -- } -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- FieldDeserializer2 create(Field field) -- { -- if (Modifier.isTransient(field.getModifiers()) -- || Modifier.isStatic(field.getModifiers())) { -- return NullFieldDeserializer.DESER; -- } -- -- // XXX: could parameterize the handler to only deal with public -- try { -- field.setAccessible(true); -- } catch (Throwable e) { -- e.printStackTrace(); -- } -- -- Class type = field.getType(); -- FieldDeserializer2 deser; -- -- if (String.class.equals(type)) -- deser = new StringFieldDeserializer(field); -- else if (byte.class.equals(type)) { -- deser = new ByteFieldDeserializer(field); -- } -- else if (short.class.equals(type)) { -- deser = new ShortFieldDeserializer(field); -- } -- else if (int.class.equals(type)) { -- deser = new IntFieldDeserializer(field); -- } -- else if (long.class.equals(type)) { -- deser = new LongFieldDeserializer(field); -- } -- else if (float.class.equals(type)) { -- deser = new FloatFieldDeserializer(field); -- } -- else if (double.class.equals(type)) { -- deser = new DoubleFieldDeserializer(field); -- } -- else if (boolean.class.equals(type)) { -- deser = new BooleanFieldDeserializer(field); -- } -- else if (java.sql.Date.class.equals(type)) { -- deser = new SqlDateFieldDeserializer(field); -- } -- else if (java.sql.Timestamp.class.equals(type)) { -- deser = new SqlTimestampFieldDeserializer(field); -- } -- else if (java.sql.Time.class.equals(type)) { -- deser = new SqlTimeFieldDeserializer(field); -- } -- else { -- deser = new ObjectFieldDeserializer(field); -- } -- -- return deser; -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- protected static Object getParamArg(Class cl) -- { -- if (! cl.isPrimitive()) -- return null; -- else if (boolean.class.equals(cl)) -- return Boolean.FALSE; -- else if (byte.class.equals(cl)) -- return new Byte((byte) 0); -- else if (short.class.equals(cl)) -- return new Short((short) 0); -- else if (char.class.equals(cl)) -- return new Character((char) 0); -- else if (int.class.equals(cl)) -- return Integer.valueOf(0); -- else if (long.class.equals(cl)) -- return Long.valueOf(0); -- else if (float.class.equals(cl)) -- return Float.valueOf(0); -- else if (double.class.equals(cl)) -- return Double.valueOf(0); -- else -- throw new UnsupportedOperationException(); -- } -- -- static class NullFieldDeserializer implements FieldDeserializer2 { -- static NullFieldDeserializer DESER = new NullFieldDeserializer(); -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- in.readObject(); -- } -- } -- -- static class ObjectFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- ObjectFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- Object value = null; -- -- try { -- value = in.readObject(_field.getType()); -- -- _field.set(obj, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class BooleanFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- BooleanFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- boolean value = false; -- -- try { -- value = in.readBoolean(); -- -- _field.setBoolean(obj, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class ByteFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- ByteFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- int value = 0; -- -- try { -- value = in.readInt(); -- -- _field.setByte(obj, (byte) value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class ShortFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- ShortFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- int value = 0; -- -- try { -- value = in.readInt(); -- -- _field.setShort(obj, (short) value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class IntFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- IntFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- int value = 0; -- -- try { -- value = in.readInt(); -- -- _field.setInt(obj, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class LongFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- LongFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- long value = 0; -- -- try { -- value = in.readLong(); -- -- _field.setLong(obj, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class FloatFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- FloatFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- double value = 0; -- -- try { -- value = in.readDouble(); -- -- _field.setFloat(obj, (float) value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class DoubleFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- DoubleFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- double value = 0; -- -- try { -- value = in.readDouble(); -- -- _field.setDouble(obj, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class StringFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- StringFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- String value = null; -- -- try { -- value = in.readString(); -- -- _field.set(obj, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class SqlDateFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- SqlDateFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- java.sql.Date value = null; -- -- try { -- java.util.Date date = (java.util.Date) in.readObject(); -- -- if (date != null) { -- value = new java.sql.Date(date.getTime()); -- -- _field.set(obj, value); -- } -- else { -- _field.set(obj, null); -- } -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- SqlTimestampFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- java.sql.Timestamp value = null; -- -- try { -- java.util.Date date = (java.util.Date) in.readObject(); -- -- if (date != null) { -- value = new java.sql.Timestamp(date.getTime()); -- -- _field.set(obj, value); -- } -- else { -- _field.set(obj, null); -- } -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class SqlTimeFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- -- SqlTimeFieldDeserializer(Field field) -- { -- _field = field; -- } -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- java.sql.Time value = null; -- -- try { -- java.util.Date date = (java.util.Date) in.readObject(); -- -- if (date != null) { -- value = new java.sql.Time(date.getTime()); -- -- _field.set(obj, value); -- } -- else { -- _field.set(obj, null); -- } -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static void logDeserializeError(Field field, Object obj, Object value, -- Throwable e) -- throws IOException -- { -- String fieldName = (field.getDeclaringClass().getName() -- + "." + field.getName()); -- -- if (e instanceof HessianFieldException) -- throw (HessianFieldException) e; -- else if (e instanceof IOException) -- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -- -- if (value != null) -- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -- + " cannot be assigned to '" + field.getType().getName() + "'", e); -- else -- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Field; -+import java.lang.reflect.Modifier; -+import java.util.logging.Logger; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class FieldDeserializer2Factory { -+ private static final Logger log -+ = Logger.getLogger(JavaDeserializer.class.getName()); -+ -+ public static FieldDeserializer2Factory create() -+ { -+ boolean isEnableUnsafeSerializer = (UnsafeSerializer.isEnabled() -+ && UnsafeDeserializer.isEnabled()); -+ -+ if (isEnableUnsafeSerializer) { -+ return new FieldDeserializer2FactoryUnsafe(); -+ } -+ else { -+ return new FieldDeserializer2Factory(); -+ } -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ FieldDeserializer2 create(Field field) -+ { -+ if (Modifier.isTransient(field.getModifiers()) -+ || Modifier.isStatic(field.getModifiers())) { -+ return NullFieldDeserializer.DESER; -+ } -+ -+ // XXX: could parameterize the handler to only deal with public -+ try { -+ field.setAccessible(true); -+ } catch (Throwable e) { -+ e.printStackTrace(); -+ } -+ -+ Class type = field.getType(); -+ FieldDeserializer2 deser; -+ -+ if (String.class.equals(type)) -+ deser = new StringFieldDeserializer(field); -+ else if (byte.class.equals(type)) { -+ deser = new ByteFieldDeserializer(field); -+ } -+ else if (short.class.equals(type)) { -+ deser = new ShortFieldDeserializer(field); -+ } -+ else if (int.class.equals(type)) { -+ deser = new IntFieldDeserializer(field); -+ } -+ else if (long.class.equals(type)) { -+ deser = new LongFieldDeserializer(field); -+ } -+ else if (float.class.equals(type)) { -+ deser = new FloatFieldDeserializer(field); -+ } -+ else if (double.class.equals(type)) { -+ deser = new DoubleFieldDeserializer(field); -+ } -+ else if (boolean.class.equals(type)) { -+ deser = new BooleanFieldDeserializer(field); -+ } -+ else if (java.sql.Date.class.equals(type)) { -+ deser = new SqlDateFieldDeserializer(field); -+ } -+ else if (java.sql.Timestamp.class.equals(type)) { -+ deser = new SqlTimestampFieldDeserializer(field); -+ } -+ else if (java.sql.Time.class.equals(type)) { -+ deser = new SqlTimeFieldDeserializer(field); -+ } -+ else { -+ deser = new ObjectFieldDeserializer(field); -+ } -+ -+ return deser; -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected static Object getParamArg(Class cl) -+ { -+ if (! cl.isPrimitive()) -+ return null; -+ else if (boolean.class.equals(cl)) -+ return Boolean.FALSE; -+ else if (byte.class.equals(cl)) -+ return new Byte((byte) 0); -+ else if (short.class.equals(cl)) -+ return new Short((short) 0); -+ else if (char.class.equals(cl)) -+ return new Character((char) 0); -+ else if (int.class.equals(cl)) -+ return Integer.valueOf(0); -+ else if (long.class.equals(cl)) -+ return Long.valueOf(0); -+ else if (float.class.equals(cl)) -+ return Float.valueOf(0); -+ else if (double.class.equals(cl)) -+ return Double.valueOf(0); -+ else -+ throw new UnsupportedOperationException(); -+ } -+ -+ static class NullFieldDeserializer implements FieldDeserializer2 { -+ static NullFieldDeserializer DESER = new NullFieldDeserializer(); -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ in.readObject(); -+ } -+ } -+ -+ static class ObjectFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ ObjectFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ Object value = null; -+ -+ try { -+ value = in.readObject(_field.getType()); -+ -+ _field.set(obj, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class BooleanFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ BooleanFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ boolean value = false; -+ -+ try { -+ value = in.readBoolean(); -+ -+ _field.setBoolean(obj, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class ByteFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ ByteFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _field.setByte(obj, (byte) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class ShortFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ ShortFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _field.setShort(obj, (short) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class IntFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ IntFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _field.setInt(obj, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class LongFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ LongFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ long value = 0; -+ -+ try { -+ value = in.readLong(); -+ -+ _field.setLong(obj, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class FloatFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ FloatFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = in.readDouble(); -+ -+ _field.setFloat(obj, (float) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class DoubleFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ DoubleFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = in.readDouble(); -+ -+ _field.setDouble(obj, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class StringFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ StringFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ String value = null; -+ -+ try { -+ value = in.readString(); -+ -+ _field.set(obj, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlDateFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ SqlDateFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Date value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ -+ if (date != null) { -+ value = new java.sql.Date(date.getTime()); -+ -+ _field.set(obj, value); -+ } -+ else { -+ _field.set(obj, null); -+ } -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ SqlTimestampFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Timestamp value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ -+ if (date != null) { -+ value = new java.sql.Timestamp(date.getTime()); -+ -+ _field.set(obj, value); -+ } -+ else { -+ _field.set(obj, null); -+ } -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlTimeFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ -+ SqlTimeFieldDeserializer(Field field) -+ { -+ _field = field; -+ } -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Time value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ -+ if (date != null) { -+ value = new java.sql.Time(date.getTime()); -+ -+ _field.set(obj, value); -+ } -+ else { -+ _field.set(obj, null); -+ } -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static void logDeserializeError(Field field, Object obj, Object value, -+ Throwable e) -+ throws IOException -+ { -+ String fieldName = (field.getDeclaringClass().getName() -+ + "." + field.getName()); -+ -+ if (e instanceof HessianFieldException) -+ throw (HessianFieldException) e; -+ else if (e instanceof IOException) -+ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -+ -+ if (value != null) -+ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -+ + " cannot be assigned to '" + field.getType().getName() + "'", e); -+ else -+ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java ---- hessian-4.0.65-src/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/FieldDeserializer2FactoryUnsafe.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,569 +1,569 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Field; --import java.lang.reflect.Modifier; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import sun.misc.Unsafe; -- --/** -- * Serializing an object for known object types. -- */ --public class FieldDeserializer2FactoryUnsafe extends FieldDeserializer2Factory { -- private static final Logger log -- = Logger.getLogger(JavaDeserializer.class.getName()); -- -- private static boolean _isEnabled; -- @SuppressWarnings("restriction") -- private static Unsafe _unsafe; -- -- /** -- * Creates a map of the classes fields. -- */ -- @Override -- public FieldDeserializer2 create(Field field) -- { -- if (Modifier.isTransient(field.getModifiers()) -- || Modifier.isStatic(field.getModifiers())) { -- return NullFieldDeserializer.DESER; -- } -- -- /* -- // XXX: could parameterize the handler to only deal with public -- try { -- field.setAccessible(true); -- } catch (Throwable e) { -- e.printStackTrace(); -- } -- */ -- -- Class type = field.getType(); -- FieldDeserializer2 deser; -- -- if (String.class.equals(type)) { -- deser = new StringFieldDeserializer(field); -- } -- else if (byte.class.equals(type)) { -- deser = new ByteFieldDeserializer(field); -- } -- else if (char.class.equals(type)) { -- deser = new CharFieldDeserializer(field); -- } -- else if (short.class.equals(type)) { -- deser = new ShortFieldDeserializer(field); -- } -- else if (int.class.equals(type)) { -- deser = new IntFieldDeserializer(field); -- } -- else if (long.class.equals(type)) { -- deser = new LongFieldDeserializer(field); -- } -- else if (float.class.equals(type)) { -- deser = new FloatFieldDeserializer(field); -- } -- else if (double.class.equals(type)) { -- deser = new DoubleFieldDeserializer(field); -- } -- else if (boolean.class.equals(type)) { -- deser = new BooleanFieldDeserializer(field); -- } -- else if (java.sql.Date.class.equals(type)) { -- deser = new SqlDateFieldDeserializer(field); -- } -- else if (java.sql.Timestamp.class.equals(type)) { -- deser = new SqlTimestampFieldDeserializer(field); -- } -- else if (java.sql.Time.class.equals(type)) { -- deser = new SqlTimeFieldDeserializer(field); -- } -- else { -- deser = new ObjectFieldDeserializer(field); -- } -- -- return deser; -- } -- -- static class NullFieldDeserializer implements FieldDeserializer2 { -- static NullFieldDeserializer DESER = new NullFieldDeserializer(); -- -- @Override -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- in.readObject(); -- } -- } -- -- static class ObjectFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- ObjectFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- Object value = null; -- -- try { -- value = in.readObject(_field.getType()); -- -- _unsafe.putObject(obj, _offset, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class BooleanFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- BooleanFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- boolean value = false; -- -- try { -- value = in.readBoolean(); -- -- _unsafe.putBoolean(obj, _offset, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class ByteFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- ByteFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- int value = 0; -- -- try { -- value = in.readInt(); -- -- _unsafe.putByte(obj, _offset, (byte) value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class CharFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- CharFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- String value = null; -- -- try { -- value = in.readString(); -- -- char ch; -- -- if (value != null && value.length() > 0) -- ch = value.charAt(0); -- else -- ch = 0; -- -- _unsafe.putChar(obj, _offset, ch); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class ShortFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- ShortFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- int value = 0; -- -- try { -- value = in.readInt(); -- -- _unsafe.putShort(obj, _offset, (short) value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class IntFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- IntFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- int value = 0; -- -- try { -- value = in.readInt(); -- -- _unsafe.putInt(obj, _offset, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class LongFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- LongFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- long value = 0; -- -- try { -- value = in.readLong(); -- -- _unsafe.putLong(obj, _offset, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class FloatFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- FloatFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- double value = 0; -- -- try { -- value = in.readDouble(); -- -- _unsafe.putFloat(obj, _offset, (float) value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class DoubleFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- DoubleFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- double value = 0; -- -- try { -- value = in.readDouble(); -- -- _unsafe.putDouble(obj, _offset, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class StringFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- StringFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- String value = null; -- -- try { -- value = in.readString(); -- -- _unsafe.putObject(obj, _offset, value); -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class SqlDateFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- SqlDateFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- java.sql.Date value = null; -- -- try { -- java.util.Date date = (java.util.Date) in.readObject(); -- -- if (date != null) { -- value = new java.sql.Date(date.getTime()); -- -- _unsafe.putObject(obj, _offset, value); -- } else { -- _unsafe.putObject(obj, _offset, null); -- } -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- SqlTimestampFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- java.sql.Timestamp value = null; -- -- try { -- java.util.Date date = (java.util.Date) in.readObject(); -- -- if (date != null) { -- value = new java.sql.Timestamp(date.getTime()); -- -- _unsafe.putObject(obj, _offset, value); -- } -- else { -- _unsafe.putObject(obj, _offset, null); -- } -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static class SqlTimeFieldDeserializer implements FieldDeserializer2 { -- private final Field _field; -- private final long _offset; -- -- @SuppressWarnings("restriction") -- SqlTimeFieldDeserializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(_field); -- } -- -- @SuppressWarnings("restriction") -- public void deserialize(AbstractHessianInput in, Object obj) -- throws IOException -- { -- java.sql.Time value = null; -- -- try { -- java.util.Date date = (java.util.Date) in.readObject(); -- -- if (date != null) { -- value = new java.sql.Time(date.getTime()); -- -- _unsafe.putObject(obj, _offset, value); -- } else { -- _unsafe.putObject(obj, _offset, null); -- } -- } catch (Exception e) { -- logDeserializeError(_field, obj, value, e); -- } -- } -- } -- -- static void logDeserializeError(Field field, Object obj, Object value, -- Throwable e) -- throws IOException -- { -- String fieldName = (field.getDeclaringClass().getName() -- + "." + field.getName()); -- -- if (e instanceof HessianFieldException) -- throw (HessianFieldException) e; -- else if (e instanceof IOException) -- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -- -- if (value != null) -- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -- + " cannot be assigned to '" + field.getType().getName() + "'", e); -- else -- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -- } -- -- static { -- boolean isEnabled = false; -- -- try { -- Class unsafe = Class.forName("sun.misc.Unsafe"); -- Field theUnsafe = null; -- for (Field field : unsafe.getDeclaredFields()) { -- if (field.getName().equals("theUnsafe")) -- theUnsafe = field; -- } -- -- if (theUnsafe != null) { -- theUnsafe.setAccessible(true); -- _unsafe = (Unsafe) theUnsafe.get(null); -- } -- -- isEnabled = _unsafe != null; -- -- String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -- -- if ("false".equals(unsafeProp)) -- isEnabled = false; -- } catch (Throwable e) { -- log.log(Level.FINER, e.toString(), e); -- } -- -- _isEnabled = isEnabled; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Field; -+import java.lang.reflect.Modifier; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import sun.misc.Unsafe; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class FieldDeserializer2FactoryUnsafe extends FieldDeserializer2Factory { -+ private static final Logger log -+ = Logger.getLogger(JavaDeserializer.class.getName()); -+ -+ private static boolean _isEnabled; -+ @SuppressWarnings("restriction") -+ private static Unsafe _unsafe; -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ @Override -+ public FieldDeserializer2 create(Field field) -+ { -+ if (Modifier.isTransient(field.getModifiers()) -+ || Modifier.isStatic(field.getModifiers())) { -+ return NullFieldDeserializer.DESER; -+ } -+ -+ /* -+ // XXX: could parameterize the handler to only deal with public -+ try { -+ field.setAccessible(true); -+ } catch (Throwable e) { -+ e.printStackTrace(); -+ } -+ */ -+ -+ Class type = field.getType(); -+ FieldDeserializer2 deser; -+ -+ if (String.class.equals(type)) { -+ deser = new StringFieldDeserializer(field); -+ } -+ else if (byte.class.equals(type)) { -+ deser = new ByteFieldDeserializer(field); -+ } -+ else if (char.class.equals(type)) { -+ deser = new CharFieldDeserializer(field); -+ } -+ else if (short.class.equals(type)) { -+ deser = new ShortFieldDeserializer(field); -+ } -+ else if (int.class.equals(type)) { -+ deser = new IntFieldDeserializer(field); -+ } -+ else if (long.class.equals(type)) { -+ deser = new LongFieldDeserializer(field); -+ } -+ else if (float.class.equals(type)) { -+ deser = new FloatFieldDeserializer(field); -+ } -+ else if (double.class.equals(type)) { -+ deser = new DoubleFieldDeserializer(field); -+ } -+ else if (boolean.class.equals(type)) { -+ deser = new BooleanFieldDeserializer(field); -+ } -+ else if (java.sql.Date.class.equals(type)) { -+ deser = new SqlDateFieldDeserializer(field); -+ } -+ else if (java.sql.Timestamp.class.equals(type)) { -+ deser = new SqlTimestampFieldDeserializer(field); -+ } -+ else if (java.sql.Time.class.equals(type)) { -+ deser = new SqlTimeFieldDeserializer(field); -+ } -+ else { -+ deser = new ObjectFieldDeserializer(field); -+ } -+ -+ return deser; -+ } -+ -+ static class NullFieldDeserializer implements FieldDeserializer2 { -+ static NullFieldDeserializer DESER = new NullFieldDeserializer(); -+ -+ @Override -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ in.readObject(); -+ } -+ } -+ -+ static class ObjectFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ ObjectFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ Object value = null; -+ -+ try { -+ value = in.readObject(_field.getType()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class BooleanFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ BooleanFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ boolean value = false; -+ -+ try { -+ value = in.readBoolean(); -+ -+ _unsafe.putBoolean(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class ByteFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ ByteFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _unsafe.putByte(obj, _offset, (byte) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class CharFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ CharFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ String value = null; -+ -+ try { -+ value = in.readString(); -+ -+ char ch; -+ -+ if (value != null && value.length() > 0) -+ ch = value.charAt(0); -+ else -+ ch = 0; -+ -+ _unsafe.putChar(obj, _offset, ch); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class ShortFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ ShortFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _unsafe.putShort(obj, _offset, (short) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class IntFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ IntFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _unsafe.putInt(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class LongFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ LongFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ long value = 0; -+ -+ try { -+ value = in.readLong(); -+ -+ _unsafe.putLong(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class FloatFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ FloatFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = in.readDouble(); -+ -+ _unsafe.putFloat(obj, _offset, (float) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class DoubleFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ DoubleFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = in.readDouble(); -+ -+ _unsafe.putDouble(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class StringFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ StringFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ String value = null; -+ -+ try { -+ value = in.readString(); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlDateFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ SqlDateFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Date value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ -+ if (date != null) { -+ value = new java.sql.Date(date.getTime()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } else { -+ _unsafe.putObject(obj, _offset, null); -+ } -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlTimestampFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ SqlTimestampFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Timestamp value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ -+ if (date != null) { -+ value = new java.sql.Timestamp(date.getTime()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } -+ else { -+ _unsafe.putObject(obj, _offset, null); -+ } -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlTimeFieldDeserializer implements FieldDeserializer2 { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ SqlTimeFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ public void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Time value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ -+ if (date != null) { -+ value = new java.sql.Time(date.getTime()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } else { -+ _unsafe.putObject(obj, _offset, null); -+ } -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static void logDeserializeError(Field field, Object obj, Object value, -+ Throwable e) -+ throws IOException -+ { -+ String fieldName = (field.getDeclaringClass().getName() -+ + "." + field.getName()); -+ -+ if (e instanceof HessianFieldException) -+ throw (HessianFieldException) e; -+ else if (e instanceof IOException) -+ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -+ -+ if (value != null) -+ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -+ + " cannot be assigned to '" + field.getType().getName() + "'", e); -+ else -+ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -+ } -+ -+ static { -+ boolean isEnabled = false; -+ -+ try { -+ Class unsafe = Class.forName("sun.misc.Unsafe"); -+ Field theUnsafe = null; -+ for (Field field : unsafe.getDeclaredFields()) { -+ if (field.getName().equals("theUnsafe")) -+ theUnsafe = field; -+ } -+ -+ if (theUnsafe != null) { -+ theUnsafe.setAccessible(true); -+ _unsafe = (Unsafe) theUnsafe.get(null); -+ } -+ -+ isEnabled = _unsafe != null; -+ -+ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -+ -+ if ("false".equals(unsafeProp)) -+ isEnabled = false; -+ } catch (Throwable e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ _isEnabled = isEnabled; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FileDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/FileDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/FileDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/FileDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,71 +1,71 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.File; -- --import com.caucho.hessian.HessianException; -- --/** -- * Deserializing a File -- */ --public class FileDeserializer extends AbstractStringValueDeserializer { -- @Override -- public Class getType() -- { -- return File.class; -- } -- -- @Override -- protected Object create(String value) -- { -- return new File(value); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.File; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Deserializing a File -+ */ -+public class FileDeserializer extends AbstractStringValueDeserializer { -+ @Override -+ public Class getType() -+ { -+ return File.class; -+ } -+ -+ @Override -+ protected Object create(String value) -+ { -+ return new File(value); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/FloatHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/FloatHandle.java ---- hessian-4.0.65-src/com/caucho/hessian/io/FloatHandle.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/FloatHandle.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,83 +1,83 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.net.URL; --import java.io.Serializable; -- --/** -- * Handle for Java Float objects. -- */ --public class FloatHandle implements Serializable { -- private float _value; -- -- private FloatHandle() -- { -- } -- -- public FloatHandle(float value) -- { -- _value = value; -- } -- -- public float getValue() -- { -- return _value; -- } -- -- public Object readResolve() -- { -- return new Float(_value); -- } -- -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _value + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.net.URL; -+import java.io.Serializable; -+ -+/** -+ * Handle for Java Float objects. -+ */ -+public class FloatHandle implements Serializable { -+ private float _value; -+ -+ private FloatHandle() -+ { -+ } -+ -+ public FloatHandle(float value) -+ { -+ _value = value; -+ } -+ -+ public float getValue() -+ { -+ return _value; -+ } -+ -+ public Object readResolve() -+ { -+ return new Float(_value); -+ } -+ -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _value + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Constants.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Constants.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Constants.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Constants.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,146 +1,146 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --public interface Hessian2Constants --{ -- public static final int BC_BINARY = 'B'; // final chunk -- public static final int BC_BINARY_CHUNK = 'A'; // non-final chunk -- public static final int BC_BINARY_DIRECT = 0x20; // 1-byte length binary -- public static final int BINARY_DIRECT_MAX = 0x0f; -- public static final int BC_BINARY_SHORT = 0x34; // 2-byte length binary -- public static final int BINARY_SHORT_MAX = 0x3ff; // 0-1023 binary -- -- public static final int BC_CLASS_DEF = 'C'; // object/class definition -- -- public static final int BC_DATE = 0x4a; // 64-bit millisecond UTC date -- public static final int BC_DATE_MINUTE = 0x4b; // 32-bit minute UTC date -- -- public static final int BC_DOUBLE = 'D'; // IEEE 64-bit double -- -- public static final int BC_DOUBLE_ZERO = 0x5b; -- public static final int BC_DOUBLE_ONE = 0x5c; -- public static final int BC_DOUBLE_BYTE = 0x5d; -- public static final int BC_DOUBLE_SHORT = 0x5e; -- public static final int BC_DOUBLE_MILL = 0x5f; -- -- public static final int BC_FALSE = 'F'; // boolean false -- -- public static final int BC_INT = 'I'; // 32-bit int -- -- public static final int INT_DIRECT_MIN = -0x10; -- public static final int INT_DIRECT_MAX = 0x2f; -- public static final int BC_INT_ZERO = 0x90; -- -- public static final int INT_BYTE_MIN = -0x800; -- public static final int INT_BYTE_MAX = 0x7ff; -- public static final int BC_INT_BYTE_ZERO = 0xc8; -- -- public static final int BC_END = 'Z'; -- -- public static final int INT_SHORT_MIN = -0x40000; -- public static final int INT_SHORT_MAX = 0x3ffff; -- public static final int BC_INT_SHORT_ZERO = 0xd4; -- -- public static final int BC_LIST_VARIABLE = 0x55; -- public static final int BC_LIST_FIXED = 'V'; -- public static final int BC_LIST_VARIABLE_UNTYPED = 0x57; -- public static final int BC_LIST_FIXED_UNTYPED = 0x58; -- -- public static final int BC_LIST_DIRECT = 0x70; -- public static final int BC_LIST_DIRECT_UNTYPED = 0x78; -- public static final int LIST_DIRECT_MAX = 0x7; -- -- public static final int BC_LONG = 'L'; // 64-bit signed integer -- public static final long LONG_DIRECT_MIN = -0x08; -- public static final long LONG_DIRECT_MAX = 0x0f; -- public static final int BC_LONG_ZERO = 0xe0; -- -- public static final long LONG_BYTE_MIN = -0x800; -- public static final long LONG_BYTE_MAX = 0x7ff; -- public static final int BC_LONG_BYTE_ZERO = 0xf8; -- -- public static final int LONG_SHORT_MIN = -0x40000; -- public static final int LONG_SHORT_MAX = 0x3ffff; -- public static final int BC_LONG_SHORT_ZERO = 0x3c; -- -- public static final int BC_LONG_INT = 0x59; -- -- public static final int BC_MAP = 'M'; -- public static final int BC_MAP_UNTYPED = 'H'; -- -- public static final int BC_NULL = 'N'; -- -- public static final int BC_OBJECT = 'O'; -- public static final int BC_OBJECT_DEF = 'C'; -- -- public static final int BC_OBJECT_DIRECT = 0x60; -- public static final int OBJECT_DIRECT_MAX = 0x0f; -- -- public static final int BC_REF = 0x51; -- -- public static final int BC_STRING = 'S'; // final string -- public static final int BC_STRING_CHUNK = 'R'; // non-final string -- -- public static final int BC_STRING_DIRECT = 0x00; -- public static final int STRING_DIRECT_MAX = 0x1f; -- public static final int BC_STRING_SHORT = 0x30; -- public static final int STRING_SHORT_MAX = 0x3ff; -- -- public static final int BC_TRUE = 'T'; -- -- public static final int P_PACKET_CHUNK = 0x4f; -- public static final int P_PACKET = 'P'; -- -- public static final int P_PACKET_DIRECT = 0x80; -- public static final int PACKET_DIRECT_MAX = 0x7f; -- -- public static final int P_PACKET_SHORT = 0x70; -- public static final int PACKET_SHORT_MAX = 0xfff; --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+public interface Hessian2Constants -+{ -+ public static final int BC_BINARY = 'B'; // final chunk -+ public static final int BC_BINARY_CHUNK = 'A'; // non-final chunk -+ public static final int BC_BINARY_DIRECT = 0x20; // 1-byte length binary -+ public static final int BINARY_DIRECT_MAX = 0x0f; -+ public static final int BC_BINARY_SHORT = 0x34; // 2-byte length binary -+ public static final int BINARY_SHORT_MAX = 0x3ff; // 0-1023 binary -+ -+ public static final int BC_CLASS_DEF = 'C'; // object/class definition -+ -+ public static final int BC_DATE = 0x4a; // 64-bit millisecond UTC date -+ public static final int BC_DATE_MINUTE = 0x4b; // 32-bit minute UTC date -+ -+ public static final int BC_DOUBLE = 'D'; // IEEE 64-bit double -+ -+ public static final int BC_DOUBLE_ZERO = 0x5b; -+ public static final int BC_DOUBLE_ONE = 0x5c; -+ public static final int BC_DOUBLE_BYTE = 0x5d; -+ public static final int BC_DOUBLE_SHORT = 0x5e; -+ public static final int BC_DOUBLE_MILL = 0x5f; -+ -+ public static final int BC_FALSE = 'F'; // boolean false -+ -+ public static final int BC_INT = 'I'; // 32-bit int -+ -+ public static final int INT_DIRECT_MIN = -0x10; -+ public static final int INT_DIRECT_MAX = 0x2f; -+ public static final int BC_INT_ZERO = 0x90; -+ -+ public static final int INT_BYTE_MIN = -0x800; -+ public static final int INT_BYTE_MAX = 0x7ff; -+ public static final int BC_INT_BYTE_ZERO = 0xc8; -+ -+ public static final int BC_END = 'Z'; -+ -+ public static final int INT_SHORT_MIN = -0x40000; -+ public static final int INT_SHORT_MAX = 0x3ffff; -+ public static final int BC_INT_SHORT_ZERO = 0xd4; -+ -+ public static final int BC_LIST_VARIABLE = 0x55; -+ public static final int BC_LIST_FIXED = 'V'; -+ public static final int BC_LIST_VARIABLE_UNTYPED = 0x57; -+ public static final int BC_LIST_FIXED_UNTYPED = 0x58; -+ -+ public static final int BC_LIST_DIRECT = 0x70; -+ public static final int BC_LIST_DIRECT_UNTYPED = 0x78; -+ public static final int LIST_DIRECT_MAX = 0x7; -+ -+ public static final int BC_LONG = 'L'; // 64-bit signed integer -+ public static final long LONG_DIRECT_MIN = -0x08; -+ public static final long LONG_DIRECT_MAX = 0x0f; -+ public static final int BC_LONG_ZERO = 0xe0; -+ -+ public static final long LONG_BYTE_MIN = -0x800; -+ public static final long LONG_BYTE_MAX = 0x7ff; -+ public static final int BC_LONG_BYTE_ZERO = 0xf8; -+ -+ public static final int LONG_SHORT_MIN = -0x40000; -+ public static final int LONG_SHORT_MAX = 0x3ffff; -+ public static final int BC_LONG_SHORT_ZERO = 0x3c; -+ -+ public static final int BC_LONG_INT = 0x59; -+ -+ public static final int BC_MAP = 'M'; -+ public static final int BC_MAP_UNTYPED = 'H'; -+ -+ public static final int BC_NULL = 'N'; -+ -+ public static final int BC_OBJECT = 'O'; -+ public static final int BC_OBJECT_DEF = 'C'; -+ -+ public static final int BC_OBJECT_DIRECT = 0x60; -+ public static final int OBJECT_DIRECT_MAX = 0x0f; -+ -+ public static final int BC_REF = 0x51; -+ -+ public static final int BC_STRING = 'S'; // final string -+ public static final int BC_STRING_CHUNK = 'R'; // non-final string -+ -+ public static final int BC_STRING_DIRECT = 0x00; -+ public static final int STRING_DIRECT_MAX = 0x1f; -+ public static final int BC_STRING_SHORT = 0x30; -+ public static final int STRING_SHORT_MAX = 0x3ff; -+ -+ public static final int BC_TRUE = 'T'; -+ -+ public static final int P_PACKET_CHUNK = 0x4f; -+ public static final int P_PACKET = 'P'; -+ -+ public static final int P_PACKET_DIRECT = 0x80; -+ public static final int PACKET_DIRECT_MAX = 0x7f; -+ -+ public static final int P_PACKET_SHORT = 0x70; -+ public static final int PACKET_SHORT_MAX = 0xfff; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Input.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Input.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Input.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Input.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,3032 +1,3032 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.*; --import java.lang.reflect.Field; --import java.util.ArrayList; --import java.util.Date; --import java.util.HashMap; --import java.util.logging.*; -- --/** -- * Input stream for Hessian requests. -- * -- *

HessianInput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * InputStream is = ...; // from http connection
-- * HessianInput in = new HessianInput(is);
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --public class Hessian2Input -- extends AbstractHessianInput -- implements Hessian2Constants --{ -- private static final Logger log -- = Logger.getLogger(Hessian2Input.class.getName()); -- -- private static final int END_OF_DATA = -2; -- -- private static Field _detailMessageField; -- -- private static final int SIZE = 1024; -- private static final int GAP = 16; -- -- // standard, unmodified factory for deserializing objects -- protected SerializerFactory _defaultSerializerFactory; -- // factory for deserializing objects in the input stream -- protected SerializerFactory _serializerFactory; -- -- private static boolean _isCloseStreamOnClose; -- -- protected ArrayList _refs -- = new ArrayList(); -- protected ArrayList _classDefs -- = new ArrayList(); -- protected ArrayList _types -- = new ArrayList(); -- -- // the underlying input stream -- private InputStream _is; -- private final byte []_buffer = new byte[SIZE]; -- -- // a peek character -- private int _offset; -- private int _length; -- -- // the method for a call -- private String _method; -- private Throwable _replyFault; -- -- private StringBuilder _sbuf = new StringBuilder(); -- -- // true if this is the last chunk -- private boolean _isLastChunk; -- // the chunk length -- private int _chunkLength; -- -- private HessianDebugInputStream _dIs; -- -- public Hessian2Input() -- { -- if (log.isLoggable(Level.FINEST)) { -- _dIs = new HessianDebugInputStream(log, Level.FINEST); -- } -- } -- -- /** -- * Creates a new Hessian input stream, initialized with an -- * underlying input stream. -- * -- * @param is the underlying input stream. -- */ -- public Hessian2Input(InputStream is) -- { -- this(); -- -- init(is); -- } -- -- /** -- * Sets the serializer factory. -- */ -- public void setSerializerFactory(SerializerFactory factory) -- { -- _serializerFactory = factory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- public SerializerFactory getSerializerFactory() -- { -- // the default serializer factory cannot be modified by external -- // callers -- if (_serializerFactory == _defaultSerializerFactory) { -- _serializerFactory = new SerializerFactory(); -- } -- -- return _serializerFactory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- protected final SerializerFactory findSerializerFactory() -- { -- SerializerFactory factory = _serializerFactory; -- -- if (factory == null) { -- factory = SerializerFactory.createDefault(); -- _defaultSerializerFactory = factory; -- _serializerFactory = factory; -- } -- -- return factory; -- } -- -- public void allow(String pattern) -- { -- ClassFactory factory = getSerializerFactory().getClassFactory(); -- -- factory.allow(pattern); -- } -- -- public void setCloseStreamOnClose(boolean isClose) -- { -- _isCloseStreamOnClose = isClose; -- } -- -- public boolean isCloseStreamOnClose() -- { -- return _isCloseStreamOnClose; -- } -- -- /** -- * Returns the calls method -- */ -- public String getMethod() -- { -- return _method; -- } -- -- /** -- * Returns any reply fault. -- */ -- public Throwable getReplyFault() -- { -- return _replyFault; -- } -- -- @Override -- public void init(InputStream is) -- { -- if (_dIs != null) { -- _dIs.initPacket(is); -- is = _dIs; -- } -- -- _is = is; -- -- reset(); -- } -- -- public void initPacket(InputStream is) -- { -- if (_dIs != null) { -- _dIs.initPacket(is); -- is = _dIs; -- } -- -- _is = is; -- -- resetReferences(); -- } -- -- /** -- * Starts reading the call -- * -- *
--   * c major minor
--   * 
-- */ -- public int readCall() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'C') -- throw error("expected hessian call ('C') at " + codeName(tag)); -- -- return 0; -- } -- -- /** -- * Starts reading the envelope -- * -- *
--   * E major minor
--   * 
-- */ -- public int readEnvelope() -- throws IOException -- { -- int tag = read(); -- int version = 0; -- -- if (tag == 'H') { -- int major = read(); -- int minor = read(); -- -- version = (major << 16) + minor; -- -- tag = read(); -- } -- -- if (tag != 'E') -- throw error("expected hessian Envelope ('E') at " + codeName(tag)); -- -- return version; -- } -- -- /** -- * Completes reading the envelope -- * -- *

A successful completion will have a single value: -- * -- *

--   * Z
--   * 
-- */ -- public void completeEnvelope() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'Z') -- error("expected end of envelope at " + codeName(tag)); -- } -- -- /** -- * Starts reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * string
--   * 
-- */ -- public String readMethod() -- throws IOException -- { -- _method = readString(); -- -- return _method; -- } -- -- /** -- * Returns the number of method arguments -- * -- *
--   * int
--   * 
-- */ -- @Override -- public int readMethodArgLength() -- throws IOException -- { -- return readInt(); -- } -- -- /** -- * Starts reading the call, including the headers. -- * -- *

The call expects the following protocol data -- * -- *

--   * c major minor
--   * m b16 b8 method
--   * 
-- */ -- public void startCall() -- throws IOException -- { -- readCall(); -- -- readMethod(); -- } -- -- public Object []readArguments() -- throws IOException -- { -- int len = readInt(); -- -- Object []args = new Object[len]; -- -- for (int i = 0; i < len; i++) -- args[i] = readObject(); -- -- return args; -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- } -- -- /** -- * Reads a reply as an object. -- * If the reply has a fault, throws the exception. -- */ -- @Override -- public Object readReply(Class expectedClass) -- throws Throwable -- { -- int tag = read(); -- -- if (tag == 'R') -- return readObject(expectedClass); -- else if (tag == 'F') { -- HashMap map = (HashMap) readObject(HashMap.class); -- -- throw prepareFault(map); -- } -- else { -- StringBuilder sb = new StringBuilder(); -- sb.append((char) tag); -- -- try { -- int ch; -- -- while ((ch = read()) >= 0) { -- sb.append((char) ch); -- } -- } catch (IOException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- throw error("expected hessian reply at " + codeName(tag) + "\n" -- + sb); -- } -- } -- -- /** -- * Starts reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * r
--   * 
-- */ -- public void startReply() -- throws Throwable -- { -- // XXX: for variable length (?) -- -- readReply(Object.class); -- } -- -- /** -- * Prepares the fault. -- */ -- private Throwable prepareFault(HashMap fault) -- throws IOException -- { -- Object detail = fault.get("detail"); -- String message = (String) fault.get("message"); -- -- if (detail instanceof Throwable) { -- _replyFault = (Throwable) detail; -- -- Field detailMessageField = getDetailMessageField(); -- -- if (message != null && detailMessageField != null) { -- try { -- detailMessageField.set(_replyFault, message); -- } catch (Throwable e) { -- } -- } -- -- return _replyFault; -- } -- -- else { -- String code = (String) fault.get("code"); -- -- _replyFault = new HessianServiceException(message, code, detail); -- -- return _replyFault; -- } -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeReply() -- throws IOException -- { -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeValueReply() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'Z') -- error("expected end of reply at " + codeName(tag)); -- } -- -- /** -- * Reads a header, returning null if there are no headers. -- * -- *
--   * H b16 b8 value
--   * 
-- */ -- public String readHeader() -- throws IOException -- { -- return null; -- } -- -- /** -- * Starts reading a packet -- * -- *
--   * p major minor
--   * 
-- */ -- public int startMessage() -- throws IOException -- { -- int tag = read(); -- -- if (tag == 'p') { -- } else if (tag == 'P') { -- } else -- throw error("expected Hessian message ('p') at " + codeName(tag)); -- -- int major = read(); -- int minor = read(); -- -- return (major << 16) + minor; -- } -- -- /** -- * Completes reading the message -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeMessage() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'Z') -- error("expected end of message at " + codeName(tag)); -- } -- -- /** -- * Reads a null -- * -- *
--   * N
--   * 
-- */ -- public void readNull() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': return; -- -- default: -- throw expect("null", tag); -- } -- } -- -- /** -- * Reads a boolean -- * -- *
--   * T
--   * F
--   * 
-- */ -- public boolean readBoolean() -- throws IOException -- { -- int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- switch (tag) { -- case 'T': return true; -- case 'F': return false; -- -- // direct integer -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- return tag != BC_INT_ZERO; -- -- // INT_BYTE = 0 -- case 0xc8: -- return read() != 0; -- -- // INT_BYTE != 0 -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- read(); -- return true; -- -- // INT_SHORT = 0 -- case 0xd4: -- return (256 * read() + read()) != 0; -- -- // INT_SHORT != 0 -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd5: case 0xd6: case 0xd7: -- read(); -- read(); -- return true; -- -- case 'I': return -- parseInt() != 0; -- -- case 0xd8: case 0xd9: case 0xda: case 0xdb: -- case 0xdc: case 0xdd: case 0xde: case 0xdf: -- -- case 0xe0: case 0xe1: case 0xe2: case 0xe3: -- case 0xe4: case 0xe5: case 0xe6: case 0xe7: -- case 0xe8: case 0xe9: case 0xea: case 0xeb: -- case 0xec: case 0xed: case 0xee: case 0xef: -- return tag != BC_LONG_ZERO; -- -- // LONG_BYTE = 0 -- case 0xf8: -- return read() != 0; -- -- // LONG_BYTE != 0 -- case 0xf0: case 0xf1: case 0xf2: case 0xf3: -- case 0xf4: case 0xf5: case 0xf6: case 0xf7: -- case 0xf9: case 0xfa: case 0xfb: -- case 0xfc: case 0xfd: case 0xfe: case 0xff: -- read(); -- return true; -- -- // INT_SHORT = 0 -- case 0x3c: -- return (256 * read() + read()) != 0; -- -- // INT_SHORT != 0 -- case 0x38: case 0x39: case 0x3a: case 0x3b: -- case 0x3d: case 0x3e: case 0x3f: -- read(); -- read(); -- return true; -- -- case BC_LONG_INT: -- return (0x1000000L * read() -- + 0x10000L * read() -- + 0x100 * read() -- + read()) != 0; -- -- case 'L': -- return parseLong() != 0; -- -- case BC_DOUBLE_ZERO: -- return false; -- -- case BC_DOUBLE_ONE: -- return true; -- -- case BC_DOUBLE_BYTE: -- return read() != 0; -- -- case BC_DOUBLE_SHORT: -- return (0x100 * read() + read()) != 0; -- -- case BC_DOUBLE_MILL: -- { -- int mills = parseInt(); -- -- return mills != 0; -- } -- -- case 'D': -- return parseDouble() != 0.0; -- -- case 'N': -- return false; -- -- default: -- throw expect("boolean", tag); -- } -- } -- -- /** -- * Reads a short -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- */ -- public short readShort() -- throws IOException -- { -- return (short) readInt(); -- } -- -- /** -- * Reads an integer -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- */ -- public final int readInt() -- throws IOException -- { -- //int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return 0; -- -- case 'F': -- return 0; -- -- case 'T': -- return 1; -- -- // direct integer -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- return tag - BC_INT_ZERO; -- -- /* byte int */ -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc8: case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); -- -- /* short int */ -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd4: case 0xd5: case 0xd6: case 0xd7: -- return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); -- -- case 'I': -- case BC_LONG_INT: -- return ((read() << 24) -- + (read() << 16) -- + (read() << 8) -- + read()); -- -- // direct long -- case 0xd8: case 0xd9: case 0xda: case 0xdb: -- case 0xdc: case 0xdd: case 0xde: case 0xdf: -- -- case 0xe0: case 0xe1: case 0xe2: case 0xe3: -- case 0xe4: case 0xe5: case 0xe6: case 0xe7: -- case 0xe8: case 0xe9: case 0xea: case 0xeb: -- case 0xec: case 0xed: case 0xee: case 0xef: -- return tag - BC_LONG_ZERO; -- -- /* byte long */ -- case 0xf0: case 0xf1: case 0xf2: case 0xf3: -- case 0xf4: case 0xf5: case 0xf6: case 0xf7: -- case 0xf8: case 0xf9: case 0xfa: case 0xfb: -- case 0xfc: case 0xfd: case 0xfe: case 0xff: -- return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); -- -- /* short long */ -- case 0x38: case 0x39: case 0x3a: case 0x3b: -- case 0x3c: case 0x3d: case 0x3e: case 0x3f: -- return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); -- -- case 'L': -- return (int) parseLong(); -- -- case BC_DOUBLE_ZERO: -- return 0; -- -- case BC_DOUBLE_ONE: -- return 1; -- -- //case LONG_BYTE: -- case BC_DOUBLE_BYTE: -- return (byte) (_offset < _length ? _buffer[_offset++] : read()); -- -- //case INT_SHORT: -- //case LONG_SHORT: -- case BC_DOUBLE_SHORT: -- return (short) (256 * read() + read()); -- -- case BC_DOUBLE_MILL: -- { -- int mills = parseInt(); -- -- return (int) (0.001 * mills); -- } -- -- case 'D': -- return (int) parseDouble(); -- -- default: -- throw expect("integer", tag); -- } -- } -- -- /** -- * Reads a long -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public long readLong() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return 0; -- -- case 'F': -- return 0; -- -- case 'T': -- return 1; -- -- // direct integer -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- return tag - BC_INT_ZERO; -- -- /* byte int */ -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc8: case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); -- -- /* short int */ -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd4: case 0xd5: case 0xd6: case 0xd7: -- return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); -- -- //case LONG_BYTE: -- case BC_DOUBLE_BYTE: -- return (byte) (_offset < _length ? _buffer[_offset++] : read()); -- -- //case INT_SHORT: -- //case LONG_SHORT: -- case BC_DOUBLE_SHORT: -- return (short) (256 * read() + read()); -- -- case 'I': -- case BC_LONG_INT: -- return parseInt(); -- -- // direct long -- case 0xd8: case 0xd9: case 0xda: case 0xdb: -- case 0xdc: case 0xdd: case 0xde: case 0xdf: -- -- case 0xe0: case 0xe1: case 0xe2: case 0xe3: -- case 0xe4: case 0xe5: case 0xe6: case 0xe7: -- case 0xe8: case 0xe9: case 0xea: case 0xeb: -- case 0xec: case 0xed: case 0xee: case 0xef: -- return tag - BC_LONG_ZERO; -- -- /* byte long */ -- case 0xf0: case 0xf1: case 0xf2: case 0xf3: -- case 0xf4: case 0xf5: case 0xf6: case 0xf7: -- case 0xf8: case 0xf9: case 0xfa: case 0xfb: -- case 0xfc: case 0xfd: case 0xfe: case 0xff: -- return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); -- -- /* short long */ -- case 0x38: case 0x39: case 0x3a: case 0x3b: -- case 0x3c: case 0x3d: case 0x3e: case 0x3f: -- return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); -- -- case 'L': -- return parseLong(); -- -- case BC_DOUBLE_ZERO: -- return 0; -- -- case BC_DOUBLE_ONE: -- return 1; -- -- case BC_DOUBLE_MILL: -- { -- int mills = parseInt(); -- -- return (long) (0.001 * mills); -- } -- -- case 'D': -- return (long) parseDouble(); -- -- default: -- throw expect("long", tag); -- } -- } -- -- /** -- * Reads a float -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public float readFloat() -- throws IOException -- { -- return (float) readDouble(); -- } -- -- /** -- * Reads a double -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public double readDouble() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return 0; -- -- case 'F': -- return 0; -- -- case 'T': -- return 1; -- -- // direct integer -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- return tag - 0x90; -- -- /* byte int */ -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc8: case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); -- -- /* short int */ -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd4: case 0xd5: case 0xd6: case 0xd7: -- return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); -- -- case 'I': -- case BC_LONG_INT: -- return parseInt(); -- -- // direct long -- case 0xd8: case 0xd9: case 0xda: case 0xdb: -- case 0xdc: case 0xdd: case 0xde: case 0xdf: -- -- case 0xe0: case 0xe1: case 0xe2: case 0xe3: -- case 0xe4: case 0xe5: case 0xe6: case 0xe7: -- case 0xe8: case 0xe9: case 0xea: case 0xeb: -- case 0xec: case 0xed: case 0xee: case 0xef: -- return tag - BC_LONG_ZERO; -- -- /* byte long */ -- case 0xf0: case 0xf1: case 0xf2: case 0xf3: -- case 0xf4: case 0xf5: case 0xf6: case 0xf7: -- case 0xf8: case 0xf9: case 0xfa: case 0xfb: -- case 0xfc: case 0xfd: case 0xfe: case 0xff: -- return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); -- -- /* short long */ -- case 0x38: case 0x39: case 0x3a: case 0x3b: -- case 0x3c: case 0x3d: case 0x3e: case 0x3f: -- return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); -- -- case 'L': -- return (double) parseLong(); -- -- case BC_DOUBLE_ZERO: -- return 0; -- -- case BC_DOUBLE_ONE: -- return 1; -- -- case BC_DOUBLE_BYTE: -- return (byte) (_offset < _length ? _buffer[_offset++] : read()); -- -- case BC_DOUBLE_SHORT: -- return (short) (256 * read() + read()); -- -- case BC_DOUBLE_MILL: -- { -- int mills = parseInt(); -- -- return 0.001 * mills; -- } -- -- case 'D': -- return parseDouble(); -- -- default: -- throw expect("double", tag); -- } -- } -- -- /** -- * Reads a date. -- * -- *
--   * T b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public long readUTCDate() -- throws IOException -- { -- int tag = read(); -- -- if (tag == BC_DATE) { -- return parseLong(); -- } -- else if (tag == BC_DATE_MINUTE) { -- return parseInt() * 60000L; -- } -- else -- throw expect("date", tag); -- } -- -- /** -- * Reads a byte from the stream. -- */ -- public int readChar() -- throws IOException -- { -- if (_chunkLength > 0) { -- _chunkLength--; -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- int ch = parseUTF8Char(); -- return ch; -- } -- else if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'S': -- case BC_STRING_CHUNK: -- _isLastChunk = tag == 'S'; -- _chunkLength = (read() << 8) + read(); -- -- _chunkLength--; -- int value = parseUTF8Char(); -- -- // special code so successive read byte won't -- // be read as a single object. -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- return value; -- -- default: -- throw expect("char", tag); -- } -- } -- -- /** -- * Reads a byte array from the stream. -- */ -- public int readString(char []buffer, int offset, int length) -- throws IOException -- { -- int readLength = 0; -- -- if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- else if (_chunkLength == 0) { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'S': -- case BC_STRING_CHUNK: -- _isLastChunk = tag == 'S'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 0x00: case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- _isLastChunk = true; -- _chunkLength = tag - 0x00; -- break; -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- _isLastChunk = true; -- _chunkLength = (tag - 0x30) * 256 + read(); -- break; -- -- default: -- throw expect("string", tag); -- } -- } -- -- while (length > 0) { -- if (_chunkLength > 0) { -- buffer[offset++] = (char) parseUTF8Char(); -- _chunkLength--; -- length--; -- readLength++; -- } -- else if (_isLastChunk) { -- if (readLength == 0) -- return -1; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- else { -- int tag = read(); -- -- switch (tag) { -- case 'S': -- case BC_STRING_CHUNK: -- _isLastChunk = tag == 'S'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 0x00: case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- _isLastChunk = true; -- _chunkLength = tag - 0x00; -- break; -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- _isLastChunk = true; -- _chunkLength = (tag - 0x30) * 256 + read(); -- break; -- -- default: -- throw expect("string", tag); -- } -- } -- } -- -- if (readLength == 0) -- return -1; -- else if (_chunkLength > 0 || ! _isLastChunk) -- return readLength; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- -- /** -- * Reads a string -- * -- *
--   * S b16 b8 string value
--   * 
-- */ -- public String readString() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- case 'T': -- return "true"; -- case 'F': -- return "false"; -- -- // direct integer -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- return String.valueOf((tag - 0x90)); -- -- /* byte int */ -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc8: case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- return String.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); -- -- /* short int */ -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd4: case 0xd5: case 0xd6: case 0xd7: -- return String.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) -- + 256 * read() + read()); -- -- case 'I': -- case BC_LONG_INT: -- return String.valueOf(parseInt()); -- -- // direct long -- case 0xd8: case 0xd9: case 0xda: case 0xdb: -- case 0xdc: case 0xdd: case 0xde: case 0xdf: -- -- case 0xe0: case 0xe1: case 0xe2: case 0xe3: -- case 0xe4: case 0xe5: case 0xe6: case 0xe7: -- case 0xe8: case 0xe9: case 0xea: case 0xeb: -- case 0xec: case 0xed: case 0xee: case 0xef: -- return String.valueOf(tag - BC_LONG_ZERO); -- -- /* byte long */ -- case 0xf0: case 0xf1: case 0xf2: case 0xf3: -- case 0xf4: case 0xf5: case 0xf6: case 0xf7: -- case 0xf8: case 0xf9: case 0xfa: case 0xfb: -- case 0xfc: case 0xfd: case 0xfe: case 0xff: -- return String.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); -- -- /* short long */ -- case 0x38: case 0x39: case 0x3a: case 0x3b: -- case 0x3c: case 0x3d: case 0x3e: case 0x3f: -- return String.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) -- + 256 * read() + read()); -- -- case 'L': -- return String.valueOf(parseLong()); -- -- case BC_DOUBLE_ZERO: -- return "0.0"; -- -- case BC_DOUBLE_ONE: -- return "1.0"; -- -- case BC_DOUBLE_BYTE: -- return String.valueOf((byte) (_offset < _length -- ? _buffer[_offset++] -- : read())); -- -- case BC_DOUBLE_SHORT: -- return String.valueOf(((short) (256 * read() + read()))); -- -- case BC_DOUBLE_MILL: -- { -- int mills = parseInt(); -- -- return String.valueOf(0.001 * mills); -- } -- -- case 'D': -- return String.valueOf(parseDouble()); -- -- case 'S': -- case BC_STRING_CHUNK: -- _isLastChunk = tag == 'S'; -- _chunkLength = (read() << 8) + read(); -- -- _sbuf.setLength(0); -- int ch; -- -- while ((ch = parseChar()) >= 0) -- _sbuf.append((char) ch); -- -- return _sbuf.toString(); -- -- // 0-byte string -- case 0x00: case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- _isLastChunk = true; -- _chunkLength = tag - 0x00; -- -- _sbuf.setLength(0); -- -- while ((ch = parseChar()) >= 0) { -- _sbuf.append((char) ch); -- } -- -- return _sbuf.toString(); -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- _isLastChunk = true; -- _chunkLength = (tag - 0x30) * 256 + read(); -- -- _sbuf.setLength(0); -- -- while ((ch = parseChar()) >= 0) -- _sbuf.append((char) ch); -- -- return _sbuf.toString(); -- -- default: -- throw expect("string", tag); -- } -- } -- -- /** -- * Reads a byte array -- * -- *
--   * B b16 b8 data value
--   * 
-- */ -- public byte []readBytes() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case BC_BINARY: -- case BC_BINARY_CHUNK: -- _isLastChunk = tag == BC_BINARY; -- _chunkLength = (read() << 8) + read(); -- -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- int data; -- while ((data = parseByte()) >= 0) -- bos.write(data); -- -- return bos.toByteArray(); -- -- case 0x20: case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- { -- _isLastChunk = true; -- _chunkLength = tag - 0x20; -- -- byte []buffer = new byte[_chunkLength]; -- -- int offset = 0; -- while (offset < _chunkLength) { -- int sublen = read(buffer, 0, _chunkLength - offset); -- -- if (sublen <= 0) -- break; -- -- offset += sublen; -- } -- -- return buffer; -- } -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- { -- _isLastChunk = true; -- _chunkLength = (tag - 0x34) * 256 + read(); -- -- byte []buffer = new byte[_chunkLength]; -- -- int offset = 0; -- while (offset < _chunkLength) { -- int sublen = read(buffer, 0, _chunkLength - offset); -- -- if (sublen <= 0) -- break; -- -- offset += sublen; -- } -- -- return buffer; -- } -- -- default: -- throw expect("bytes", tag); -- } -- } -- -- /** -- * Reads a byte from the stream. -- */ -- public int readByte() -- throws IOException -- { -- if (_chunkLength > 0) { -- _chunkLength--; -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- return read(); -- } -- else if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'B': -- case BC_BINARY_CHUNK: -- { -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- -- int value = parseByte(); -- -- // special code so successive read byte won't -- // be read as a single object. -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- return value; -- } -- -- case 0x20: case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- { -- _isLastChunk = true; -- _chunkLength = tag - 0x20; -- -- int value = parseByte(); -- -- // special code so successive read byte won't -- // be read as a single object. -- if (_chunkLength == 0) -- _chunkLength = END_OF_DATA; -- -- return value; -- } -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- { -- _isLastChunk = true; -- _chunkLength = (tag - 0x34) * 256 + read(); -- -- int value = parseByte(); -- -- // special code so successive read byte won't -- // be read as a single object. -- if (_chunkLength == 0) -- _chunkLength = END_OF_DATA; -- -- return value; -- } -- -- default: -- throw expect("binary", tag); -- } -- } -- -- /** -- * Reads a byte array from the stream. -- */ -- public int readBytes(byte []buffer, int offset, int length) -- throws IOException -- { -- int readLength = 0; -- -- if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- else if (_chunkLength == 0) { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'B': -- case BC_BINARY_CHUNK: -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 0x20: case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- { -- _isLastChunk = true; -- _chunkLength = tag - 0x20; -- break; -- } -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- { -- _isLastChunk = true; -- _chunkLength = (tag - 0x34) * 256 + read(); -- break; -- } -- -- default: -- throw expect("binary", tag); -- } -- } -- -- while (length > 0) { -- if (_chunkLength > 0) { -- buffer[offset++] = (byte) read(); -- _chunkLength--; -- length--; -- readLength++; -- } -- else if (_isLastChunk) { -- if (readLength == 0) -- return -1; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- else { -- int tag = read(); -- -- switch (tag) { -- case 'B': -- case BC_BINARY_CHUNK: -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw expect("binary", tag); -- } -- } -- } -- -- if (readLength == 0) -- return -1; -- else if (_chunkLength > 0 || ! _isLastChunk) -- return readLength; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- -- /** -- * Reads an object from the input stream with an expected type. -- */ -- public Object readObject(Class cl) -- throws IOException -- { -- if (cl == null || cl == Object.class) -- return readObject(); -- -- int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'H': -- { -- Deserializer reader = findSerializerFactory().getDeserializer(cl); -- -- return reader.readMap(this); -- } -- -- case 'M': -- { -- String type = readType(); -- -- // hessian/3bb3 -- if ("".equals(type)) { -- Deserializer reader; -- reader = findSerializerFactory().getDeserializer(cl); -- -- return reader.readMap(this); -- } -- else { -- Deserializer reader; -- reader = findSerializerFactory().getObjectDeserializer(type, cl); -- -- return reader.readMap(this); -- } -- } -- -- case 'C': -- { -- readObjectDefinition(cl); -- -- return readObject(cl); -- } -- -- case 0x60: case 0x61: case 0x62: case 0x63: -- case 0x64: case 0x65: case 0x66: case 0x67: -- case 0x68: case 0x69: case 0x6a: case 0x6b: -- case 0x6c: case 0x6d: case 0x6e: case 0x6f: -- { -- int ref = tag - 0x60; -- int size = _classDefs.size(); -- -- if (ref < 0 || size <= ref) -- throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); -- -- ObjectDefinition def = _classDefs.get(ref); -- -- return readObjectInstance(cl, def); -- } -- -- case 'O': -- { -- int ref = readInt(); -- int size = _classDefs.size(); -- -- if (ref < 0 || size <= ref) -- throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); -- -- ObjectDefinition def = _classDefs.get(ref); -- -- return readObjectInstance(cl, def); -- } -- -- case BC_LIST_VARIABLE: -- { -- String type = readType(); -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(type, cl); -- -- Object v = reader.readList(this, -1); -- -- return v; -- } -- -- case BC_LIST_FIXED: -- { -- String type = readType(); -- int length = readInt(); -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(type, cl); -- -- Object v = reader.readLengthList(this, length); -- -- return v; -- } -- -- case 0x70: case 0x71: case 0x72: case 0x73: -- case 0x74: case 0x75: case 0x76: case 0x77: -- { -- int length = tag - 0x70; -- -- String type = readType(); -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(type, cl); -- -- Object v = reader.readLengthList(this, length); -- -- return v; -- } -- -- case BC_LIST_VARIABLE_UNTYPED: -- { -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(null, cl); -- -- Object v = reader.readList(this, -1); -- -- return v; -- } -- -- case BC_LIST_FIXED_UNTYPED: -- { -- int length = readInt(); -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(null, cl); -- -- Object v = reader.readLengthList(this, length); -- -- return v; -- } -- -- case 0x78: case 0x79: case 0x7a: case 0x7b: -- case 0x7c: case 0x7d: case 0x7e: case 0x7f: -- { -- int length = tag - 0x78; -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(null, cl); -- -- Object v = reader.readLengthList(this, length); -- -- return v; -- } -- -- case BC_REF: -- { -- int ref = readInt(); -- -- return _refs.get(ref); -- } -- } -- -- if (tag >= 0) -- _offset--; -- -- // hessian/3b2i vs hessian/3406 -- // return readObject(); -- Object value = findSerializerFactory().getDeserializer(cl).readObject(this); -- return value; -- } -- -- /** -- * Reads an arbitrary object from the input stream when the type -- * is unknown. -- */ -- public Object readObject() -- throws IOException -- { -- int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'T': -- return Boolean.valueOf(true); -- -- case 'F': -- return Boolean.valueOf(false); -- -- // direct integer -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- return Integer.valueOf(tag - BC_INT_ZERO); -- -- /* byte int */ -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc8: case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- return Integer.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); -- -- /* short int */ -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd4: case 0xd5: case 0xd6: case 0xd7: -- return Integer.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) -- + 256 * read() + read()); -- -- case 'I': -- return Integer.valueOf(parseInt()); -- -- // direct long -- case 0xd8: case 0xd9: case 0xda: case 0xdb: -- case 0xdc: case 0xdd: case 0xde: case 0xdf: -- -- case 0xe0: case 0xe1: case 0xe2: case 0xe3: -- case 0xe4: case 0xe5: case 0xe6: case 0xe7: -- case 0xe8: case 0xe9: case 0xea: case 0xeb: -- case 0xec: case 0xed: case 0xee: case 0xef: -- return Long.valueOf(tag - BC_LONG_ZERO); -- -- /* byte long */ -- case 0xf0: case 0xf1: case 0xf2: case 0xf3: -- case 0xf4: case 0xf5: case 0xf6: case 0xf7: -- case 0xf8: case 0xf9: case 0xfa: case 0xfb: -- case 0xfc: case 0xfd: case 0xfe: case 0xff: -- return Long.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); -- -- /* short long */ -- case 0x38: case 0x39: case 0x3a: case 0x3b: -- case 0x3c: case 0x3d: case 0x3e: case 0x3f: -- return Long.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read()); -- -- case BC_LONG_INT: -- return Long.valueOf(parseInt()); -- -- case 'L': -- return Long.valueOf(parseLong()); -- -- case BC_DOUBLE_ZERO: -- return Double.valueOf(0); -- -- case BC_DOUBLE_ONE: -- return Double.valueOf(1); -- -- case BC_DOUBLE_BYTE: -- return Double.valueOf((byte) read()); -- -- case BC_DOUBLE_SHORT: -- return Double.valueOf((short) (256 * read() + read())); -- -- case BC_DOUBLE_MILL: -- { -- int mills = parseInt(); -- -- return Double.valueOf(0.001 * mills); -- } -- -- case 'D': -- return Double.valueOf(parseDouble()); -- -- case BC_DATE: -- return new Date(parseLong()); -- -- case BC_DATE_MINUTE: -- return new Date(parseInt() * 60000L); -- -- case BC_STRING_CHUNK: -- case 'S': -- { -- _isLastChunk = tag == 'S'; -- _chunkLength = (read() << 8) + read(); -- -- _sbuf.setLength(0); -- -- parseString(_sbuf); -- -- return _sbuf.toString(); -- } -- -- case 0x00: case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- { -- _isLastChunk = true; -- _chunkLength = tag - 0x00; -- -- _sbuf.setLength(0); -- -- parseString(_sbuf); -- -- return _sbuf.toString(); -- } -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- { -- _isLastChunk = true; -- _chunkLength = (tag - 0x30) * 256 + read(); -- -- _sbuf.setLength(0); -- -- parseString(_sbuf); -- -- return _sbuf.toString(); -- } -- -- case BC_BINARY_CHUNK: -- case 'B': -- { -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- -- int data; -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- while ((data = parseByte()) >= 0) -- bos.write(data); -- -- return bos.toByteArray(); -- } -- -- case 0x20: case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- { -- _isLastChunk = true; -- int len = tag - 0x20; -- _chunkLength = 0; -- -- byte []data = new byte[len]; -- -- for (int i = 0; i < len; i++) -- data[i] = (byte) read(); -- -- return data; -- } -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- { -- _isLastChunk = true; -- int len = (tag - 0x34) * 256 + read(); -- _chunkLength = 0; -- -- byte []buffer = new byte[len]; -- -- for (int i = 0; i < len; i++) { -- buffer[i] = (byte) read(); -- } -- -- return buffer; -- } -- -- case BC_LIST_VARIABLE: -- { -- // variable length list -- String type = readType(); -- -- return findSerializerFactory().readList(this, -1, type); -- } -- -- case BC_LIST_VARIABLE_UNTYPED: -- { -- return findSerializerFactory().readList(this, -1, null); -- } -- -- case BC_LIST_FIXED: -- { -- // fixed length lists -- String type = readType(); -- int length = readInt(); -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(type, null); -- -- return reader.readLengthList(this, length); -- } -- -- case BC_LIST_FIXED_UNTYPED: -- { -- // fixed length lists -- int length = readInt(); -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(null, null); -- -- return reader.readLengthList(this, length); -- } -- -- // compact fixed list -- case 0x70: case 0x71: case 0x72: case 0x73: -- case 0x74: case 0x75: case 0x76: case 0x77: -- { -- // fixed length lists -- String type = readType(); -- int length = tag - 0x70; -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(type, null); -- -- return reader.readLengthList(this, length); -- } -- -- // compact fixed untyped list -- case 0x78: case 0x79: case 0x7a: case 0x7b: -- case 0x7c: case 0x7d: case 0x7e: case 0x7f: -- { -- // fixed length lists -- int length = tag - 0x78; -- -- Deserializer reader; -- reader = findSerializerFactory().getListDeserializer(null, null); -- -- return reader.readLengthList(this, length); -- } -- -- case 'H': -- { -- return findSerializerFactory().readMap(this, null); -- } -- -- case 'M': -- { -- String type = readType(); -- -- return findSerializerFactory().readMap(this, type); -- } -- -- case 'C': -- { -- readObjectDefinition(null); -- -- return readObject(); -- } -- -- case 0x60: case 0x61: case 0x62: case 0x63: -- case 0x64: case 0x65: case 0x66: case 0x67: -- case 0x68: case 0x69: case 0x6a: case 0x6b: -- case 0x6c: case 0x6d: case 0x6e: case 0x6f: -- { -- int ref = tag - 0x60; -- -- if (_classDefs.size() <= ref) -- throw error("No classes defined at reference '" -- + Integer.toHexString(tag) + "'"); -- -- ObjectDefinition def = _classDefs.get(ref); -- -- return readObjectInstance(null, def); -- } -- -- case 'O': -- { -- int ref = readInt(); -- -- if (_classDefs.size() <= ref) -- throw error("Illegal object reference #" + ref); -- -- ObjectDefinition def = _classDefs.get(ref); -- -- return readObjectInstance(null, def); -- } -- -- case BC_REF: -- { -- int ref = readInt(); -- -- return _refs.get(ref); -- } -- -- default: -- if (tag < 0) -- throw new EOFException("readObject: unexpected end of file"); -- else -- throw error("readObject: unknown code " + codeName(tag)); -- } -- } -- -- /** -- * Reads an object definition: -- * -- *
--   * O string  (string)* *
--   * 
-- */ -- private void readObjectDefinition(Class cl) -- throws IOException -- { -- String type = readString(); -- int len = readInt(); -- -- SerializerFactory factory = findSerializerFactory(); -- -- Deserializer reader = factory.getObjectDeserializer(type, null); -- -- Object []fields = reader.createFields(len); -- String []fieldNames = new String[len]; -- -- for (int i = 0; i < len; i++) { -- String name = readString(); -- -- fields[i] = reader.createField(name); -- fieldNames[i] = name; -- } -- -- ObjectDefinition def -- = new ObjectDefinition(type, reader, fields, fieldNames); -- -- _classDefs.add(def); -- } -- -- private Object readObjectInstance(Class cl, -- ObjectDefinition def) -- throws IOException -- { -- String type = def.getType(); -- Deserializer reader = def.getReader(); -- Object []fields = def.getFields(); -- -- SerializerFactory factory = findSerializerFactory(); -- -- if (cl != reader.getType() && cl != null) { -- reader = factory.getObjectDeserializer(type, cl); -- -- return reader.readObject(this, def.getFieldNames()); -- } -- else { -- return reader.readObject(this, fields); -- } -- } -- -- /** -- * Reads a remote object. -- */ -- public Object readRemote() -- throws IOException -- { -- String type = readType(); -- String url = readString(); -- -- return resolveRemote(type, url); -- } -- -- /** -- * Reads a reference. -- */ -- public Object readRef() -- throws IOException -- { -- int value = parseInt(); -- -- return _refs.get(value); -- } -- -- /** -- * Reads the start of a list. -- */ -- public int readListStart() -- throws IOException -- { -- return read(); -- } -- -- /** -- * Reads the start of a list. -- */ -- public int readMapStart() -- throws IOException -- { -- return read(); -- } -- -- /** -- * Returns true if this is the end of a list or a map. -- */ -- public boolean isEnd() -- throws IOException -- { -- int code; -- -- if (_offset < _length) -- code = (_buffer[_offset] & 0xff); -- else { -- code = read(); -- -- if (code >= 0) -- _offset--; -- } -- -- return (code < 0 || code == 'Z'); -- } -- -- /** -- * Reads the end byte. -- */ -- public void readEnd() -- throws IOException -- { -- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- if (code == 'Z') -- return; -- else if (code < 0) -- throw error("unexpected end of file"); -- else -- throw error("unknown code:" + codeName(code)); -- } -- -- /** -- * Reads the end byte. -- */ -- public void readMapEnd() -- throws IOException -- { -- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- if (code != 'Z') -- throw error("expected end of map ('Z') at '" + codeName(code) + "'"); -- } -- -- /** -- * Reads the end byte. -- */ -- public void readListEnd() -- throws IOException -- { -- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- if (code != 'Z') -- throw error("expected end of list ('Z') at '" + codeName(code) + "'"); -- } -- -- /** -- * Adds a list/map reference. -- */ -- @Override -- public int addRef(Object ref) -- { -- if (_refs == null) -- _refs = new ArrayList(); -- -- _refs.add(ref); -- -- return _refs.size() - 1; -- } -- -- /** -- * Adds a list/map reference. -- */ -- public void setRef(int i, Object ref) -- { -- _refs.set(i, ref); -- } -- -- /** -- * Resets the references for streaming. -- */ -- @Override -- public void resetReferences() -- { -- _refs.clear(); -- } -- -- public void reset() -- { -- resetReferences(); -- -- _classDefs.clear(); -- _types.clear(); -- } -- -- public void resetBuffer() -- { -- int offset = _offset; -- _offset = 0; -- -- int length = _length; -- _length = 0; -- -- if (length > 0 && offset != length) -- throw new IllegalStateException("offset=" + offset + " length=" + length); -- } -- -- public Object readStreamingObject() -- throws IOException -- { -- if (_refs != null) -- _refs.clear(); -- -- return readObject(); -- } -- -- /** -- * Resolves a remote object. -- */ -- public Object resolveRemote(String type, String url) -- throws IOException -- { -- HessianRemoteResolver resolver = getRemoteResolver(); -- -- if (resolver != null) -- return resolver.lookup(type, url); -- else -- return new HessianRemote(type, url); -- } -- -- /** -- * Parses a type from the stream. -- * -- *
--   * type ::= string
--   * type ::= int
--   * 
-- */ -- public String readType() -- throws IOException -- { -- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- _offset--; -- -- switch (code) { -- case 0x00: case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- case BC_STRING_CHUNK: case 'S': -- { -- String type = readString(); -- -- if (_types == null) -- _types = new ArrayList(); -- -- _types.add(type); -- -- return type; -- } -- -- default: -- { -- int ref = readInt(); -- -- if (_types.size() <= ref) -- throw new IndexOutOfBoundsException("type ref #" + ref + " is greater than the number of valid types (" + _types.size() + ")"); -- -- return (String) _types.get(ref); -- } -- } -- } -- -- /** -- * Parses the length for an array -- * -- *
--   * l b32 b24 b16 b8
--   * 
-- */ -- public int readLength() -- throws IOException -- { -- throw new UnsupportedOperationException(); -- } -- -- /** -- * Parses a 32-bit integer value from the stream. -- * -- *
--   * b32 b24 b16 b8
--   * 
-- */ -- private int parseInt() -- throws IOException -- { -- int offset = _offset; -- -- if (offset + 3 < _length) { -- byte []buffer = _buffer; -- -- int b32 = buffer[offset + 0] & 0xff; -- int b24 = buffer[offset + 1] & 0xff; -- int b16 = buffer[offset + 2] & 0xff; -- int b8 = buffer[offset + 3] & 0xff; -- -- _offset = offset + 4; -- -- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -- } -- else { -- int b32 = read(); -- int b24 = read(); -- int b16 = read(); -- int b8 = read(); -- -- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -- } -- } -- -- /** -- * Parses a 64-bit long value from the stream. -- * -- *
--   * b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- private long parseLong() -- throws IOException -- { -- long b64 = read(); -- long b56 = read(); -- long b48 = read(); -- long b40 = read(); -- long b32 = read(); -- long b24 = read(); -- long b16 = read(); -- long b8 = read(); -- -- return ((b64 << 56) -- + (b56 << 48) -- + (b48 << 40) -- + (b40 << 32) -- + (b32 << 24) -- + (b24 << 16) -- + (b16 << 8) -- + b8); -- } -- -- /** -- * Parses a 64-bit double value from the stream. -- * -- *
--   * b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- private double parseDouble() -- throws IOException -- { -- long bits = parseLong(); -- -- return Double.longBitsToDouble(bits); -- } -- -- org.w3c.dom.Node parseXML() -- throws IOException -- { -- throw new UnsupportedOperationException(); -- } -- -- private void parseString(StringBuilder sbuf) -- throws IOException -- { -- while (true) { -- if (_chunkLength <= 0) { -- if (! parseChunkLength()) -- return; -- } -- -- int length = _chunkLength; -- _chunkLength = 0; -- -- while (length-- > 0) { -- sbuf.append((char) parseUTF8Char()); -- } -- } -- } -- -- /** -- * Reads a character from the underlying stream. -- */ -- private int parseChar() -- throws IOException -- { -- while (_chunkLength <= 0) { -- if (! parseChunkLength()) -- return -1; -- } -- -- _chunkLength--; -- -- return parseUTF8Char(); -- } -- -- private boolean parseChunkLength() -- throws IOException -- { -- if (_isLastChunk) -- return false; -- -- int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- switch (code) { -- case BC_STRING_CHUNK: -- _isLastChunk = false; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 'S': -- _isLastChunk = true; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 0x00: case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- _isLastChunk = true; -- _chunkLength = code - 0x00; -- break; -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- _isLastChunk = true; -- _chunkLength = (code - 0x30) * 256 + read(); -- break; -- -- default: -- throw expect("string", code); -- } -- -- return true; -- } -- -- /** -- * Parses a single UTF8 character. -- */ -- private int parseUTF8Char() -- throws IOException -- { -- int ch = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -- -- if (ch < 0x80) -- return ch; -- else if ((ch & 0xe0) == 0xc0) { -- int ch1 = read(); -- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -- -- return v; -- } -- else if ((ch & 0xf0) == 0xe0) { -- int ch1 = read(); -- int ch2 = read(); -- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -- -- return v; -- } -- else -- throw error("bad utf-8 encoding at " + codeName(ch)); -- } -- -- /** -- * Reads a byte from the underlying stream. -- */ -- private int parseByte() -- throws IOException -- { -- while (_chunkLength <= 0) { -- if (_isLastChunk) { -- return -1; -- } -- -- int code = read(); -- -- switch (code) { -- case BC_BINARY_CHUNK: -- _isLastChunk = false; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 'B': -- _isLastChunk = true; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 0x20: case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- _isLastChunk = true; -- -- _chunkLength = code - 0x20; -- break; -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- _isLastChunk = true; -- _chunkLength = (code - 0x34) * 256 + read(); -- break; -- -- default: -- throw expect("byte[]", code); -- } -- } -- -- _chunkLength--; -- -- return read(); -- } -- -- /** -- * Reads bytes based on an input stream. -- */ -- public InputStream readInputStream() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case BC_BINARY: -- case BC_BINARY_CHUNK: -- _isLastChunk = tag == BC_BINARY; -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 0x20: case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- _isLastChunk = true; -- _chunkLength = tag - 0x20; -- break; -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- _isLastChunk = true; -- _chunkLength = (tag - 0x34) * 256 + read(); -- break; -- -- default: -- throw expect("binary", tag); -- } -- -- return new ReadInputStream(); -- } -- -- /** -- * Reads bytes from the underlying stream. -- */ -- int read(byte []buffer, int offset, int length) -- throws IOException -- { -- int readLength = 0; -- -- while (length > 0) { -- while (_chunkLength <= 0) { -- if (_isLastChunk) -- return readLength == 0 ? -1 : readLength; -- -- int code = read(); -- -- switch (code) { -- case BC_BINARY_CHUNK: -- _isLastChunk = false; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case BC_BINARY: -- _isLastChunk = true; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 0x20: case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- _isLastChunk = true; -- _chunkLength = code - 0x20; -- break; -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- _isLastChunk = true; -- _chunkLength = (code - 0x34) * 256 + read(); -- break; -- -- default: -- throw expect("byte[]", code); -- } -- } -- -- int sublen = _chunkLength; -- if (length < sublen) -- sublen = length; -- -- if (_length <= _offset && ! readBuffer()) -- return -1; -- -- if (_length - _offset < sublen) -- sublen = _length - _offset; -- -- System.arraycopy(_buffer, _offset, buffer, offset, sublen); -- -- _offset += sublen; -- -- offset += sublen; -- readLength += sublen; -- length -= sublen; -- _chunkLength -= sublen; -- } -- -- return readLength; -- } -- -- /** -- * Normally, shouldn't be called externally, but needed for QA, e.g. -- * ejb/3b01. -- */ -- public final int read() -- throws IOException -- { -- if (_length <= _offset && ! readBuffer()) -- return -1; -- -- return _buffer[_offset++] & 0xff; -- } -- -- protected void unread() -- { -- if (_offset <= 0) -- throw new IllegalStateException(); -- -- _offset--; -- } -- -- private final boolean readBuffer() -- throws IOException -- { -- byte []buffer = _buffer; -- int offset = _offset; -- int length = _length; -- -- if (offset < length) { -- System.arraycopy(buffer, offset, buffer, 0, length - offset); -- offset = length - offset; -- } -- else -- offset = 0; -- -- int len = _is.read(buffer, offset, SIZE - offset); -- -- if (len <= 0) { -- _length = offset; -- _offset = 0; -- -- return offset > 0; -- } -- -- _length = offset + len; -- _offset = 0; -- -- return true; -- } -- -- public Reader getReader() -- { -- return null; -- } -- -- protected IOException expect(String expect, int ch) -- throws IOException -- { -- if (ch < 0) -- return error("expected " + expect + " at end of file"); -- else { -- _offset--; -- -- try { -- int offset = _offset; -- String context -- = buildDebugContext(_buffer, 0, _length, offset); -- -- Object obj = readObject(); -- -- if (obj != null) { -- return error("expected " + expect -- + " at 0x" + Integer.toHexString(ch & 0xff) -- + " " + obj.getClass().getName() + " (" + obj + ")" -- + "\n " + context + ""); -- } -- else -- return error("expected " + expect -- + " at 0x" + Integer.toHexString(ch & 0xff) + " null"); -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- -- return error("expected " + expect -- + " at 0x" + Integer.toHexString(ch & 0xff)); -- } -- } -- } -- -- private String buildDebugContext(byte []buffer, int offset, int length, -- int errorOffset) -- { -- StringBuilder sb = new StringBuilder(); -- -- sb.append("["); -- for (int i = 0; i < errorOffset; i++) { -- int ch = buffer[offset + i]; -- addDebugChar(sb, ch); -- } -- sb.append("] "); -- addDebugChar(sb, buffer[offset + errorOffset]); -- sb.append(" ["); -- for (int i = errorOffset + 1; i < length; i++) { -- int ch = buffer[offset + i]; -- addDebugChar(sb, ch); -- } -- sb.append("]"); -- -- return sb.toString(); -- } -- -- private void addDebugChar(StringBuilder sb, int ch) -- { -- if (ch >= 0x20 && ch < 0x7f) { -- sb.append((char) ch); -- } -- else if (ch == '\n') -- sb.append((char) ch); -- else -- sb.append(String.format("\\x%02x", ch & 0xff)); -- } -- -- protected String codeName(int ch) -- { -- if (ch < 0) -- return "end of file"; -- else -- return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; -- } -- -- protected IOException error(String message) -- { -- if (_method != null) -- return new HessianProtocolException(_method + ": " + message); -- else -- return new HessianProtocolException(message); -- } -- -- public void free() -- { -- reset(); -- } -- -- @Override -- public void close() -- throws IOException -- { -- InputStream is = _is; -- _is = null; -- -- if (_isCloseStreamOnClose && is != null) -- is.close(); -- } -- -- class ReadInputStream extends InputStream { -- boolean _isClosed = false; -- -- public int read() -- throws IOException -- { -- if (_isClosed) -- return -1; -- -- int ch = parseByte(); -- if (ch < 0) -- _isClosed = true; -- -- return ch; -- } -- -- public int read(byte []buffer, int offset, int length) -- throws IOException -- { -- if (_isClosed) -- return -1; -- -- int len = Hessian2Input.this.read(buffer, offset, length); -- if (len < 0) -- _isClosed = true; -- -- return len; -- } -- -- public void close() -- throws IOException -- { -- while (read() >= 0) { -- } -- } -- }; -- -- final static class ObjectDefinition { -- private final String _type; -- private final Deserializer _reader; -- private final Object []_fields; -- private final String []_fieldNames; -- -- ObjectDefinition(String type, -- Deserializer reader, -- Object []fields, -- String []fieldNames) -- { -- _type = type; -- _reader = reader; -- _fields = fields; -- _fieldNames = fieldNames; -- } -- -- String getType() -- { -- return _type; -- } -- -- Deserializer getReader() -- { -- return _reader; -- } -- -- Object []getFields() -- { -- return _fields; -- } -- -- String []getFieldNames() -- { -- return _fieldNames; -- } -- } -- -- private static Field getDetailMessageField() -- { -- if (_detailMessageField == null) { -- try { -- _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); -- _detailMessageField.setAccessible(true); -- } catch (Throwable e) { -- } -- } -- -- return _detailMessageField; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.*; -+import java.lang.reflect.Field; -+import java.util.ArrayList; -+import java.util.Date; -+import java.util.HashMap; -+import java.util.logging.*; -+ -+/** -+ * Input stream for Hessian requests. -+ * -+ *

HessianInput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * InputStream is = ...; // from http connection
-+ * HessianInput in = new HessianInput(is);
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+public class Hessian2Input -+ extends AbstractHessianInput -+ implements Hessian2Constants -+{ -+ private static final Logger log -+ = Logger.getLogger(Hessian2Input.class.getName()); -+ -+ private static final int END_OF_DATA = -2; -+ -+ private static Field _detailMessageField; -+ -+ private static final int SIZE = 1024; -+ private static final int GAP = 16; -+ -+ // standard, unmodified factory for deserializing objects -+ protected SerializerFactory _defaultSerializerFactory; -+ // factory for deserializing objects in the input stream -+ protected SerializerFactory _serializerFactory; -+ -+ private static boolean _isCloseStreamOnClose; -+ -+ protected ArrayList _refs -+ = new ArrayList(); -+ protected ArrayList _classDefs -+ = new ArrayList(); -+ protected ArrayList _types -+ = new ArrayList(); -+ -+ // the underlying input stream -+ private InputStream _is; -+ private final byte []_buffer = new byte[SIZE]; -+ -+ // a peek character -+ private int _offset; -+ private int _length; -+ -+ // the method for a call -+ private String _method; -+ private Throwable _replyFault; -+ -+ private StringBuilder _sbuf = new StringBuilder(); -+ -+ // true if this is the last chunk -+ private boolean _isLastChunk; -+ // the chunk length -+ private int _chunkLength; -+ -+ private HessianDebugInputStream _dIs; -+ -+ public Hessian2Input() -+ { -+ if (log.isLoggable(Level.FINEST)) { -+ _dIs = new HessianDebugInputStream(log, Level.FINEST); -+ } -+ } -+ -+ /** -+ * Creates a new Hessian input stream, initialized with an -+ * underlying input stream. -+ * -+ * @param is the underlying input stream. -+ */ -+ public Hessian2Input(InputStream is) -+ { -+ this(); -+ -+ init(is); -+ } -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ public SerializerFactory getSerializerFactory() -+ { -+ // the default serializer factory cannot be modified by external -+ // callers -+ if (_serializerFactory == _defaultSerializerFactory) { -+ _serializerFactory = new SerializerFactory(); -+ } -+ -+ return _serializerFactory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ protected final SerializerFactory findSerializerFactory() -+ { -+ SerializerFactory factory = _serializerFactory; -+ -+ if (factory == null) { -+ factory = SerializerFactory.createDefault(); -+ _defaultSerializerFactory = factory; -+ _serializerFactory = factory; -+ } -+ -+ return factory; -+ } -+ -+ public void allow(String pattern) -+ { -+ ClassFactory factory = getSerializerFactory().getClassFactory(); -+ -+ factory.allow(pattern); -+ } -+ -+ public void setCloseStreamOnClose(boolean isClose) -+ { -+ _isCloseStreamOnClose = isClose; -+ } -+ -+ public boolean isCloseStreamOnClose() -+ { -+ return _isCloseStreamOnClose; -+ } -+ -+ /** -+ * Returns the calls method -+ */ -+ public String getMethod() -+ { -+ return _method; -+ } -+ -+ /** -+ * Returns any reply fault. -+ */ -+ public Throwable getReplyFault() -+ { -+ return _replyFault; -+ } -+ -+ @Override -+ public void init(InputStream is) -+ { -+ if (_dIs != null) { -+ _dIs.initPacket(is); -+ is = _dIs; -+ } -+ -+ _is = is; -+ -+ reset(); -+ } -+ -+ public void initPacket(InputStream is) -+ { -+ if (_dIs != null) { -+ _dIs.initPacket(is); -+ is = _dIs; -+ } -+ -+ _is = is; -+ -+ resetReferences(); -+ } -+ -+ /** -+ * Starts reading the call -+ * -+ *
-+   * c major minor
-+   * 
-+ */ -+ public int readCall() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'C') -+ throw error("expected hessian call ('C') at " + codeName(tag)); -+ -+ return 0; -+ } -+ -+ /** -+ * Starts reading the envelope -+ * -+ *
-+   * E major minor
-+   * 
-+ */ -+ public int readEnvelope() -+ throws IOException -+ { -+ int tag = read(); -+ int version = 0; -+ -+ if (tag == 'H') { -+ int major = read(); -+ int minor = read(); -+ -+ version = (major << 16) + minor; -+ -+ tag = read(); -+ } -+ -+ if (tag != 'E') -+ throw error("expected hessian Envelope ('E') at " + codeName(tag)); -+ -+ return version; -+ } -+ -+ /** -+ * Completes reading the envelope -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * Z
-+   * 
-+ */ -+ public void completeEnvelope() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'Z') -+ error("expected end of envelope at " + codeName(tag)); -+ } -+ -+ /** -+ * Starts reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * string
-+   * 
-+ */ -+ public String readMethod() -+ throws IOException -+ { -+ _method = readString(); -+ -+ return _method; -+ } -+ -+ /** -+ * Returns the number of method arguments -+ * -+ *
-+   * int
-+   * 
-+ */ -+ @Override -+ public int readMethodArgLength() -+ throws IOException -+ { -+ return readInt(); -+ } -+ -+ /** -+ * Starts reading the call, including the headers. -+ * -+ *

The call expects the following protocol data -+ * -+ *

-+   * c major minor
-+   * m b16 b8 method
-+   * 
-+ */ -+ public void startCall() -+ throws IOException -+ { -+ readCall(); -+ -+ readMethod(); -+ } -+ -+ public Object []readArguments() -+ throws IOException -+ { -+ int len = readInt(); -+ -+ Object []args = new Object[len]; -+ -+ for (int i = 0; i < len; i++) -+ args[i] = readObject(); -+ -+ return args; -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ } -+ -+ /** -+ * Reads a reply as an object. -+ * If the reply has a fault, throws the exception. -+ */ -+ @Override -+ public Object readReply(Class expectedClass) -+ throws Throwable -+ { -+ int tag = read(); -+ -+ if (tag == 'R') -+ return readObject(expectedClass); -+ else if (tag == 'F') { -+ HashMap map = (HashMap) readObject(HashMap.class); -+ -+ throw prepareFault(map); -+ } -+ else { -+ StringBuilder sb = new StringBuilder(); -+ sb.append((char) tag); -+ -+ try { -+ int ch; -+ -+ while ((ch = read()) >= 0) { -+ sb.append((char) ch); -+ } -+ } catch (IOException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ throw error("expected hessian reply at " + codeName(tag) + "\n" -+ + sb); -+ } -+ } -+ -+ /** -+ * Starts reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * r
-+   * 
-+ */ -+ public void startReply() -+ throws Throwable -+ { -+ // XXX: for variable length (?) -+ -+ readReply(Object.class); -+ } -+ -+ /** -+ * Prepares the fault. -+ */ -+ private Throwable prepareFault(HashMap fault) -+ throws IOException -+ { -+ Object detail = fault.get("detail"); -+ String message = (String) fault.get("message"); -+ -+ if (detail instanceof Throwable) { -+ _replyFault = (Throwable) detail; -+ -+ Field detailMessageField = getDetailMessageField(); -+ -+ if (message != null && detailMessageField != null) { -+ try { -+ detailMessageField.set(_replyFault, message); -+ } catch (Throwable e) { -+ } -+ } -+ -+ return _replyFault; -+ } -+ -+ else { -+ String code = (String) fault.get("code"); -+ -+ _replyFault = new HessianServiceException(message, code, detail); -+ -+ return _replyFault; -+ } -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeReply() -+ throws IOException -+ { -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeValueReply() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'Z') -+ error("expected end of reply at " + codeName(tag)); -+ } -+ -+ /** -+ * Reads a header, returning null if there are no headers. -+ * -+ *
-+   * H b16 b8 value
-+   * 
-+ */ -+ public String readHeader() -+ throws IOException -+ { -+ return null; -+ } -+ -+ /** -+ * Starts reading a packet -+ * -+ *
-+   * p major minor
-+   * 
-+ */ -+ public int startMessage() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag == 'p') { -+ } else if (tag == 'P') { -+ } else -+ throw error("expected Hessian message ('p') at " + codeName(tag)); -+ -+ int major = read(); -+ int minor = read(); -+ -+ return (major << 16) + minor; -+ } -+ -+ /** -+ * Completes reading the message -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeMessage() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'Z') -+ error("expected end of message at " + codeName(tag)); -+ } -+ -+ /** -+ * Reads a null -+ * -+ *
-+   * N
-+   * 
-+ */ -+ public void readNull() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': return; -+ -+ default: -+ throw expect("null", tag); -+ } -+ } -+ -+ /** -+ * Reads a boolean -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ */ -+ public boolean readBoolean() -+ throws IOException -+ { -+ int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ switch (tag) { -+ case 'T': return true; -+ case 'F': return false; -+ -+ // direct integer -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ return tag != BC_INT_ZERO; -+ -+ // INT_BYTE = 0 -+ case 0xc8: -+ return read() != 0; -+ -+ // INT_BYTE != 0 -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ read(); -+ return true; -+ -+ // INT_SHORT = 0 -+ case 0xd4: -+ return (256 * read() + read()) != 0; -+ -+ // INT_SHORT != 0 -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd5: case 0xd6: case 0xd7: -+ read(); -+ read(); -+ return true; -+ -+ case 'I': return -+ parseInt() != 0; -+ -+ case 0xd8: case 0xd9: case 0xda: case 0xdb: -+ case 0xdc: case 0xdd: case 0xde: case 0xdf: -+ -+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: -+ case 0xe4: case 0xe5: case 0xe6: case 0xe7: -+ case 0xe8: case 0xe9: case 0xea: case 0xeb: -+ case 0xec: case 0xed: case 0xee: case 0xef: -+ return tag != BC_LONG_ZERO; -+ -+ // LONG_BYTE = 0 -+ case 0xf8: -+ return read() != 0; -+ -+ // LONG_BYTE != 0 -+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: -+ case 0xf4: case 0xf5: case 0xf6: case 0xf7: -+ case 0xf9: case 0xfa: case 0xfb: -+ case 0xfc: case 0xfd: case 0xfe: case 0xff: -+ read(); -+ return true; -+ -+ // INT_SHORT = 0 -+ case 0x3c: -+ return (256 * read() + read()) != 0; -+ -+ // INT_SHORT != 0 -+ case 0x38: case 0x39: case 0x3a: case 0x3b: -+ case 0x3d: case 0x3e: case 0x3f: -+ read(); -+ read(); -+ return true; -+ -+ case BC_LONG_INT: -+ return (0x1000000L * read() -+ + 0x10000L * read() -+ + 0x100 * read() -+ + read()) != 0; -+ -+ case 'L': -+ return parseLong() != 0; -+ -+ case BC_DOUBLE_ZERO: -+ return false; -+ -+ case BC_DOUBLE_ONE: -+ return true; -+ -+ case BC_DOUBLE_BYTE: -+ return read() != 0; -+ -+ case BC_DOUBLE_SHORT: -+ return (0x100 * read() + read()) != 0; -+ -+ case BC_DOUBLE_MILL: -+ { -+ int mills = parseInt(); -+ -+ return mills != 0; -+ } -+ -+ case 'D': -+ return parseDouble() != 0.0; -+ -+ case 'N': -+ return false; -+ -+ default: -+ throw expect("boolean", tag); -+ } -+ } -+ -+ /** -+ * Reads a short -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ */ -+ public short readShort() -+ throws IOException -+ { -+ return (short) readInt(); -+ } -+ -+ /** -+ * Reads an integer -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ */ -+ public final int readInt() -+ throws IOException -+ { -+ //int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return 0; -+ -+ case 'F': -+ return 0; -+ -+ case 'T': -+ return 1; -+ -+ // direct integer -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ return tag - BC_INT_ZERO; -+ -+ /* byte int */ -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc8: case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); -+ -+ /* short int */ -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd4: case 0xd5: case 0xd6: case 0xd7: -+ return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); -+ -+ case 'I': -+ case BC_LONG_INT: -+ return ((read() << 24) -+ + (read() << 16) -+ + (read() << 8) -+ + read()); -+ -+ // direct long -+ case 0xd8: case 0xd9: case 0xda: case 0xdb: -+ case 0xdc: case 0xdd: case 0xde: case 0xdf: -+ -+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: -+ case 0xe4: case 0xe5: case 0xe6: case 0xe7: -+ case 0xe8: case 0xe9: case 0xea: case 0xeb: -+ case 0xec: case 0xed: case 0xee: case 0xef: -+ return tag - BC_LONG_ZERO; -+ -+ /* byte long */ -+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: -+ case 0xf4: case 0xf5: case 0xf6: case 0xf7: -+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: -+ case 0xfc: case 0xfd: case 0xfe: case 0xff: -+ return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); -+ -+ /* short long */ -+ case 0x38: case 0x39: case 0x3a: case 0x3b: -+ case 0x3c: case 0x3d: case 0x3e: case 0x3f: -+ return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); -+ -+ case 'L': -+ return (int) parseLong(); -+ -+ case BC_DOUBLE_ZERO: -+ return 0; -+ -+ case BC_DOUBLE_ONE: -+ return 1; -+ -+ //case LONG_BYTE: -+ case BC_DOUBLE_BYTE: -+ return (byte) (_offset < _length ? _buffer[_offset++] : read()); -+ -+ //case INT_SHORT: -+ //case LONG_SHORT: -+ case BC_DOUBLE_SHORT: -+ return (short) (256 * read() + read()); -+ -+ case BC_DOUBLE_MILL: -+ { -+ int mills = parseInt(); -+ -+ return (int) (0.001 * mills); -+ } -+ -+ case 'D': -+ return (int) parseDouble(); -+ -+ default: -+ throw expect("integer", tag); -+ } -+ } -+ -+ /** -+ * Reads a long -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public long readLong() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return 0; -+ -+ case 'F': -+ return 0; -+ -+ case 'T': -+ return 1; -+ -+ // direct integer -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ return tag - BC_INT_ZERO; -+ -+ /* byte int */ -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc8: case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); -+ -+ /* short int */ -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd4: case 0xd5: case 0xd6: case 0xd7: -+ return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); -+ -+ //case LONG_BYTE: -+ case BC_DOUBLE_BYTE: -+ return (byte) (_offset < _length ? _buffer[_offset++] : read()); -+ -+ //case INT_SHORT: -+ //case LONG_SHORT: -+ case BC_DOUBLE_SHORT: -+ return (short) (256 * read() + read()); -+ -+ case 'I': -+ case BC_LONG_INT: -+ return parseInt(); -+ -+ // direct long -+ case 0xd8: case 0xd9: case 0xda: case 0xdb: -+ case 0xdc: case 0xdd: case 0xde: case 0xdf: -+ -+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: -+ case 0xe4: case 0xe5: case 0xe6: case 0xe7: -+ case 0xe8: case 0xe9: case 0xea: case 0xeb: -+ case 0xec: case 0xed: case 0xee: case 0xef: -+ return tag - BC_LONG_ZERO; -+ -+ /* byte long */ -+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: -+ case 0xf4: case 0xf5: case 0xf6: case 0xf7: -+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: -+ case 0xfc: case 0xfd: case 0xfe: case 0xff: -+ return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); -+ -+ /* short long */ -+ case 0x38: case 0x39: case 0x3a: case 0x3b: -+ case 0x3c: case 0x3d: case 0x3e: case 0x3f: -+ return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); -+ -+ case 'L': -+ return parseLong(); -+ -+ case BC_DOUBLE_ZERO: -+ return 0; -+ -+ case BC_DOUBLE_ONE: -+ return 1; -+ -+ case BC_DOUBLE_MILL: -+ { -+ int mills = parseInt(); -+ -+ return (long) (0.001 * mills); -+ } -+ -+ case 'D': -+ return (long) parseDouble(); -+ -+ default: -+ throw expect("long", tag); -+ } -+ } -+ -+ /** -+ * Reads a float -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public float readFloat() -+ throws IOException -+ { -+ return (float) readDouble(); -+ } -+ -+ /** -+ * Reads a double -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public double readDouble() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return 0; -+ -+ case 'F': -+ return 0; -+ -+ case 'T': -+ return 1; -+ -+ // direct integer -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ return tag - 0x90; -+ -+ /* byte int */ -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc8: case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ return ((tag - BC_INT_BYTE_ZERO) << 8) + read(); -+ -+ /* short int */ -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd4: case 0xd5: case 0xd6: case 0xd7: -+ return ((tag - BC_INT_SHORT_ZERO) << 16) + 256 * read() + read(); -+ -+ case 'I': -+ case BC_LONG_INT: -+ return parseInt(); -+ -+ // direct long -+ case 0xd8: case 0xd9: case 0xda: case 0xdb: -+ case 0xdc: case 0xdd: case 0xde: case 0xdf: -+ -+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: -+ case 0xe4: case 0xe5: case 0xe6: case 0xe7: -+ case 0xe8: case 0xe9: case 0xea: case 0xeb: -+ case 0xec: case 0xed: case 0xee: case 0xef: -+ return tag - BC_LONG_ZERO; -+ -+ /* byte long */ -+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: -+ case 0xf4: case 0xf5: case 0xf6: case 0xf7: -+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: -+ case 0xfc: case 0xfd: case 0xfe: case 0xff: -+ return ((tag - BC_LONG_BYTE_ZERO) << 8) + read(); -+ -+ /* short long */ -+ case 0x38: case 0x39: case 0x3a: case 0x3b: -+ case 0x3c: case 0x3d: case 0x3e: case 0x3f: -+ return ((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read(); -+ -+ case 'L': -+ return (double) parseLong(); -+ -+ case BC_DOUBLE_ZERO: -+ return 0; -+ -+ case BC_DOUBLE_ONE: -+ return 1; -+ -+ case BC_DOUBLE_BYTE: -+ return (byte) (_offset < _length ? _buffer[_offset++] : read()); -+ -+ case BC_DOUBLE_SHORT: -+ return (short) (256 * read() + read()); -+ -+ case BC_DOUBLE_MILL: -+ { -+ int mills = parseInt(); -+ -+ return 0.001 * mills; -+ } -+ -+ case 'D': -+ return parseDouble(); -+ -+ default: -+ throw expect("double", tag); -+ } -+ } -+ -+ /** -+ * Reads a date. -+ * -+ *
-+   * T b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public long readUTCDate() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag == BC_DATE) { -+ return parseLong(); -+ } -+ else if (tag == BC_DATE_MINUTE) { -+ return parseInt() * 60000L; -+ } -+ else -+ throw expect("date", tag); -+ } -+ -+ /** -+ * Reads a byte from the stream. -+ */ -+ public int readChar() -+ throws IOException -+ { -+ if (_chunkLength > 0) { -+ _chunkLength--; -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ int ch = parseUTF8Char(); -+ return ch; -+ } -+ else if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'S': -+ case BC_STRING_CHUNK: -+ _isLastChunk = tag == 'S'; -+ _chunkLength = (read() << 8) + read(); -+ -+ _chunkLength--; -+ int value = parseUTF8Char(); -+ -+ // special code so successive read byte won't -+ // be read as a single object. -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ return value; -+ -+ default: -+ throw expect("char", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte array from the stream. -+ */ -+ public int readString(char []buffer, int offset, int length) -+ throws IOException -+ { -+ int readLength = 0; -+ -+ if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ else if (_chunkLength == 0) { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'S': -+ case BC_STRING_CHUNK: -+ _isLastChunk = tag == 'S'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 0x00: case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ _isLastChunk = true; -+ _chunkLength = tag - 0x00; -+ break; -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x30) * 256 + read(); -+ break; -+ -+ default: -+ throw expect("string", tag); -+ } -+ } -+ -+ while (length > 0) { -+ if (_chunkLength > 0) { -+ buffer[offset++] = (char) parseUTF8Char(); -+ _chunkLength--; -+ length--; -+ readLength++; -+ } -+ else if (_isLastChunk) { -+ if (readLength == 0) -+ return -1; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ else { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'S': -+ case BC_STRING_CHUNK: -+ _isLastChunk = tag == 'S'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 0x00: case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ _isLastChunk = true; -+ _chunkLength = tag - 0x00; -+ break; -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x30) * 256 + read(); -+ break; -+ -+ default: -+ throw expect("string", tag); -+ } -+ } -+ } -+ -+ if (readLength == 0) -+ return -1; -+ else if (_chunkLength > 0 || ! _isLastChunk) -+ return readLength; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ -+ /** -+ * Reads a string -+ * -+ *
-+   * S b16 b8 string value
-+   * 
-+ */ -+ public String readString() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ case 'T': -+ return "true"; -+ case 'F': -+ return "false"; -+ -+ // direct integer -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ return String.valueOf((tag - 0x90)); -+ -+ /* byte int */ -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc8: case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ return String.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); -+ -+ /* short int */ -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd4: case 0xd5: case 0xd6: case 0xd7: -+ return String.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) -+ + 256 * read() + read()); -+ -+ case 'I': -+ case BC_LONG_INT: -+ return String.valueOf(parseInt()); -+ -+ // direct long -+ case 0xd8: case 0xd9: case 0xda: case 0xdb: -+ case 0xdc: case 0xdd: case 0xde: case 0xdf: -+ -+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: -+ case 0xe4: case 0xe5: case 0xe6: case 0xe7: -+ case 0xe8: case 0xe9: case 0xea: case 0xeb: -+ case 0xec: case 0xed: case 0xee: case 0xef: -+ return String.valueOf(tag - BC_LONG_ZERO); -+ -+ /* byte long */ -+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: -+ case 0xf4: case 0xf5: case 0xf6: case 0xf7: -+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: -+ case 0xfc: case 0xfd: case 0xfe: case 0xff: -+ return String.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); -+ -+ /* short long */ -+ case 0x38: case 0x39: case 0x3a: case 0x3b: -+ case 0x3c: case 0x3d: case 0x3e: case 0x3f: -+ return String.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) -+ + 256 * read() + read()); -+ -+ case 'L': -+ return String.valueOf(parseLong()); -+ -+ case BC_DOUBLE_ZERO: -+ return "0.0"; -+ -+ case BC_DOUBLE_ONE: -+ return "1.0"; -+ -+ case BC_DOUBLE_BYTE: -+ return String.valueOf((byte) (_offset < _length -+ ? _buffer[_offset++] -+ : read())); -+ -+ case BC_DOUBLE_SHORT: -+ return String.valueOf(((short) (256 * read() + read()))); -+ -+ case BC_DOUBLE_MILL: -+ { -+ int mills = parseInt(); -+ -+ return String.valueOf(0.001 * mills); -+ } -+ -+ case 'D': -+ return String.valueOf(parseDouble()); -+ -+ case 'S': -+ case BC_STRING_CHUNK: -+ _isLastChunk = tag == 'S'; -+ _chunkLength = (read() << 8) + read(); -+ -+ _sbuf.setLength(0); -+ int ch; -+ -+ while ((ch = parseChar()) >= 0) -+ _sbuf.append((char) ch); -+ -+ return _sbuf.toString(); -+ -+ // 0-byte string -+ case 0x00: case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ _isLastChunk = true; -+ _chunkLength = tag - 0x00; -+ -+ _sbuf.setLength(0); -+ -+ while ((ch = parseChar()) >= 0) { -+ _sbuf.append((char) ch); -+ } -+ -+ return _sbuf.toString(); -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x30) * 256 + read(); -+ -+ _sbuf.setLength(0); -+ -+ while ((ch = parseChar()) >= 0) -+ _sbuf.append((char) ch); -+ -+ return _sbuf.toString(); -+ -+ default: -+ throw expect("string", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte array -+ * -+ *
-+   * B b16 b8 data value
-+   * 
-+ */ -+ public byte []readBytes() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case BC_BINARY: -+ case BC_BINARY_CHUNK: -+ _isLastChunk = tag == BC_BINARY; -+ _chunkLength = (read() << 8) + read(); -+ -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ int data; -+ while ((data = parseByte()) >= 0) -+ bos.write(data); -+ -+ return bos.toByteArray(); -+ -+ case 0x20: case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ { -+ _isLastChunk = true; -+ _chunkLength = tag - 0x20; -+ -+ byte []buffer = new byte[_chunkLength]; -+ -+ int offset = 0; -+ while (offset < _chunkLength) { -+ int sublen = read(buffer, 0, _chunkLength - offset); -+ -+ if (sublen <= 0) -+ break; -+ -+ offset += sublen; -+ } -+ -+ return buffer; -+ } -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ { -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x34) * 256 + read(); -+ -+ byte []buffer = new byte[_chunkLength]; -+ -+ int offset = 0; -+ while (offset < _chunkLength) { -+ int sublen = read(buffer, 0, _chunkLength - offset); -+ -+ if (sublen <= 0) -+ break; -+ -+ offset += sublen; -+ } -+ -+ return buffer; -+ } -+ -+ default: -+ throw expect("bytes", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte from the stream. -+ */ -+ public int readByte() -+ throws IOException -+ { -+ if (_chunkLength > 0) { -+ _chunkLength--; -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ return read(); -+ } -+ else if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'B': -+ case BC_BINARY_CHUNK: -+ { -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ -+ int value = parseByte(); -+ -+ // special code so successive read byte won't -+ // be read as a single object. -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ return value; -+ } -+ -+ case 0x20: case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ { -+ _isLastChunk = true; -+ _chunkLength = tag - 0x20; -+ -+ int value = parseByte(); -+ -+ // special code so successive read byte won't -+ // be read as a single object. -+ if (_chunkLength == 0) -+ _chunkLength = END_OF_DATA; -+ -+ return value; -+ } -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ { -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x34) * 256 + read(); -+ -+ int value = parseByte(); -+ -+ // special code so successive read byte won't -+ // be read as a single object. -+ if (_chunkLength == 0) -+ _chunkLength = END_OF_DATA; -+ -+ return value; -+ } -+ -+ default: -+ throw expect("binary", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte array from the stream. -+ */ -+ public int readBytes(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ int readLength = 0; -+ -+ if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ else if (_chunkLength == 0) { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'B': -+ case BC_BINARY_CHUNK: -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 0x20: case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ { -+ _isLastChunk = true; -+ _chunkLength = tag - 0x20; -+ break; -+ } -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ { -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x34) * 256 + read(); -+ break; -+ } -+ -+ default: -+ throw expect("binary", tag); -+ } -+ } -+ -+ while (length > 0) { -+ if (_chunkLength > 0) { -+ buffer[offset++] = (byte) read(); -+ _chunkLength--; -+ length--; -+ readLength++; -+ } -+ else if (_isLastChunk) { -+ if (readLength == 0) -+ return -1; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ else { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'B': -+ case BC_BINARY_CHUNK: -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw expect("binary", tag); -+ } -+ } -+ } -+ -+ if (readLength == 0) -+ return -1; -+ else if (_chunkLength > 0 || ! _isLastChunk) -+ return readLength; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ -+ /** -+ * Reads an object from the input stream with an expected type. -+ */ -+ public Object readObject(Class cl) -+ throws IOException -+ { -+ if (cl == null || cl == Object.class) -+ return readObject(); -+ -+ int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'H': -+ { -+ Deserializer reader = findSerializerFactory().getDeserializer(cl); -+ -+ return reader.readMap(this); -+ } -+ -+ case 'M': -+ { -+ String type = readType(); -+ -+ // hessian/3bb3 -+ if ("".equals(type)) { -+ Deserializer reader; -+ reader = findSerializerFactory().getDeserializer(cl); -+ -+ return reader.readMap(this); -+ } -+ else { -+ Deserializer reader; -+ reader = findSerializerFactory().getObjectDeserializer(type, cl); -+ -+ return reader.readMap(this); -+ } -+ } -+ -+ case 'C': -+ { -+ readObjectDefinition(cl); -+ -+ return readObject(cl); -+ } -+ -+ case 0x60: case 0x61: case 0x62: case 0x63: -+ case 0x64: case 0x65: case 0x66: case 0x67: -+ case 0x68: case 0x69: case 0x6a: case 0x6b: -+ case 0x6c: case 0x6d: case 0x6e: case 0x6f: -+ { -+ int ref = tag - 0x60; -+ int size = _classDefs.size(); -+ -+ if (ref < 0 || size <= ref) -+ throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); -+ -+ ObjectDefinition def = _classDefs.get(ref); -+ -+ return readObjectInstance(cl, def); -+ } -+ -+ case 'O': -+ { -+ int ref = readInt(); -+ int size = _classDefs.size(); -+ -+ if (ref < 0 || size <= ref) -+ throw new HessianProtocolException("'" + ref + "' is an unknown class definition"); -+ -+ ObjectDefinition def = _classDefs.get(ref); -+ -+ return readObjectInstance(cl, def); -+ } -+ -+ case BC_LIST_VARIABLE: -+ { -+ String type = readType(); -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(type, cl); -+ -+ Object v = reader.readList(this, -1); -+ -+ return v; -+ } -+ -+ case BC_LIST_FIXED: -+ { -+ String type = readType(); -+ int length = readInt(); -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(type, cl); -+ -+ Object v = reader.readLengthList(this, length); -+ -+ return v; -+ } -+ -+ case 0x70: case 0x71: case 0x72: case 0x73: -+ case 0x74: case 0x75: case 0x76: case 0x77: -+ { -+ int length = tag - 0x70; -+ -+ String type = readType(); -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(type, cl); -+ -+ Object v = reader.readLengthList(this, length); -+ -+ return v; -+ } -+ -+ case BC_LIST_VARIABLE_UNTYPED: -+ { -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(null, cl); -+ -+ Object v = reader.readList(this, -1); -+ -+ return v; -+ } -+ -+ case BC_LIST_FIXED_UNTYPED: -+ { -+ int length = readInt(); -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(null, cl); -+ -+ Object v = reader.readLengthList(this, length); -+ -+ return v; -+ } -+ -+ case 0x78: case 0x79: case 0x7a: case 0x7b: -+ case 0x7c: case 0x7d: case 0x7e: case 0x7f: -+ { -+ int length = tag - 0x78; -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(null, cl); -+ -+ Object v = reader.readLengthList(this, length); -+ -+ return v; -+ } -+ -+ case BC_REF: -+ { -+ int ref = readInt(); -+ -+ return _refs.get(ref); -+ } -+ } -+ -+ if (tag >= 0) -+ _offset--; -+ -+ // hessian/3b2i vs hessian/3406 -+ // return readObject(); -+ Object value = findSerializerFactory().getDeserializer(cl).readObject(this); -+ return value; -+ } -+ -+ /** -+ * Reads an arbitrary object from the input stream when the type -+ * is unknown. -+ */ -+ public Object readObject() -+ throws IOException -+ { -+ int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'T': -+ return Boolean.valueOf(true); -+ -+ case 'F': -+ return Boolean.valueOf(false); -+ -+ // direct integer -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ return Integer.valueOf(tag - BC_INT_ZERO); -+ -+ /* byte int */ -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc8: case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ return Integer.valueOf(((tag - BC_INT_BYTE_ZERO) << 8) + read()); -+ -+ /* short int */ -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd4: case 0xd5: case 0xd6: case 0xd7: -+ return Integer.valueOf(((tag - BC_INT_SHORT_ZERO) << 16) -+ + 256 * read() + read()); -+ -+ case 'I': -+ return Integer.valueOf(parseInt()); -+ -+ // direct long -+ case 0xd8: case 0xd9: case 0xda: case 0xdb: -+ case 0xdc: case 0xdd: case 0xde: case 0xdf: -+ -+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: -+ case 0xe4: case 0xe5: case 0xe6: case 0xe7: -+ case 0xe8: case 0xe9: case 0xea: case 0xeb: -+ case 0xec: case 0xed: case 0xee: case 0xef: -+ return Long.valueOf(tag - BC_LONG_ZERO); -+ -+ /* byte long */ -+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: -+ case 0xf4: case 0xf5: case 0xf6: case 0xf7: -+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: -+ case 0xfc: case 0xfd: case 0xfe: case 0xff: -+ return Long.valueOf(((tag - BC_LONG_BYTE_ZERO) << 8) + read()); -+ -+ /* short long */ -+ case 0x38: case 0x39: case 0x3a: case 0x3b: -+ case 0x3c: case 0x3d: case 0x3e: case 0x3f: -+ return Long.valueOf(((tag - BC_LONG_SHORT_ZERO) << 16) + 256 * read() + read()); -+ -+ case BC_LONG_INT: -+ return Long.valueOf(parseInt()); -+ -+ case 'L': -+ return Long.valueOf(parseLong()); -+ -+ case BC_DOUBLE_ZERO: -+ return Double.valueOf(0); -+ -+ case BC_DOUBLE_ONE: -+ return Double.valueOf(1); -+ -+ case BC_DOUBLE_BYTE: -+ return Double.valueOf((byte) read()); -+ -+ case BC_DOUBLE_SHORT: -+ return Double.valueOf((short) (256 * read() + read())); -+ -+ case BC_DOUBLE_MILL: -+ { -+ int mills = parseInt(); -+ -+ return Double.valueOf(0.001 * mills); -+ } -+ -+ case 'D': -+ return Double.valueOf(parseDouble()); -+ -+ case BC_DATE: -+ return new Date(parseLong()); -+ -+ case BC_DATE_MINUTE: -+ return new Date(parseInt() * 60000L); -+ -+ case BC_STRING_CHUNK: -+ case 'S': -+ { -+ _isLastChunk = tag == 'S'; -+ _chunkLength = (read() << 8) + read(); -+ -+ _sbuf.setLength(0); -+ -+ parseString(_sbuf); -+ -+ return _sbuf.toString(); -+ } -+ -+ case 0x00: case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ { -+ _isLastChunk = true; -+ _chunkLength = tag - 0x00; -+ -+ _sbuf.setLength(0); -+ -+ parseString(_sbuf); -+ -+ return _sbuf.toString(); -+ } -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ { -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x30) * 256 + read(); -+ -+ _sbuf.setLength(0); -+ -+ parseString(_sbuf); -+ -+ return _sbuf.toString(); -+ } -+ -+ case BC_BINARY_CHUNK: -+ case 'B': -+ { -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ -+ int data; -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ while ((data = parseByte()) >= 0) -+ bos.write(data); -+ -+ return bos.toByteArray(); -+ } -+ -+ case 0x20: case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ { -+ _isLastChunk = true; -+ int len = tag - 0x20; -+ _chunkLength = 0; -+ -+ byte []data = new byte[len]; -+ -+ for (int i = 0; i < len; i++) -+ data[i] = (byte) read(); -+ -+ return data; -+ } -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ { -+ _isLastChunk = true; -+ int len = (tag - 0x34) * 256 + read(); -+ _chunkLength = 0; -+ -+ byte []buffer = new byte[len]; -+ -+ for (int i = 0; i < len; i++) { -+ buffer[i] = (byte) read(); -+ } -+ -+ return buffer; -+ } -+ -+ case BC_LIST_VARIABLE: -+ { -+ // variable length list -+ String type = readType(); -+ -+ return findSerializerFactory().readList(this, -1, type); -+ } -+ -+ case BC_LIST_VARIABLE_UNTYPED: -+ { -+ return findSerializerFactory().readList(this, -1, null); -+ } -+ -+ case BC_LIST_FIXED: -+ { -+ // fixed length lists -+ String type = readType(); -+ int length = readInt(); -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(type, null); -+ -+ return reader.readLengthList(this, length); -+ } -+ -+ case BC_LIST_FIXED_UNTYPED: -+ { -+ // fixed length lists -+ int length = readInt(); -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(null, null); -+ -+ return reader.readLengthList(this, length); -+ } -+ -+ // compact fixed list -+ case 0x70: case 0x71: case 0x72: case 0x73: -+ case 0x74: case 0x75: case 0x76: case 0x77: -+ { -+ // fixed length lists -+ String type = readType(); -+ int length = tag - 0x70; -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(type, null); -+ -+ return reader.readLengthList(this, length); -+ } -+ -+ // compact fixed untyped list -+ case 0x78: case 0x79: case 0x7a: case 0x7b: -+ case 0x7c: case 0x7d: case 0x7e: case 0x7f: -+ { -+ // fixed length lists -+ int length = tag - 0x78; -+ -+ Deserializer reader; -+ reader = findSerializerFactory().getListDeserializer(null, null); -+ -+ return reader.readLengthList(this, length); -+ } -+ -+ case 'H': -+ { -+ return findSerializerFactory().readMap(this, null); -+ } -+ -+ case 'M': -+ { -+ String type = readType(); -+ -+ return findSerializerFactory().readMap(this, type); -+ } -+ -+ case 'C': -+ { -+ readObjectDefinition(null); -+ -+ return readObject(); -+ } -+ -+ case 0x60: case 0x61: case 0x62: case 0x63: -+ case 0x64: case 0x65: case 0x66: case 0x67: -+ case 0x68: case 0x69: case 0x6a: case 0x6b: -+ case 0x6c: case 0x6d: case 0x6e: case 0x6f: -+ { -+ int ref = tag - 0x60; -+ -+ if (_classDefs.size() <= ref) -+ throw error("No classes defined at reference '" -+ + Integer.toHexString(tag) + "'"); -+ -+ ObjectDefinition def = _classDefs.get(ref); -+ -+ return readObjectInstance(null, def); -+ } -+ -+ case 'O': -+ { -+ int ref = readInt(); -+ -+ if (_classDefs.size() <= ref) -+ throw error("Illegal object reference #" + ref); -+ -+ ObjectDefinition def = _classDefs.get(ref); -+ -+ return readObjectInstance(null, def); -+ } -+ -+ case BC_REF: -+ { -+ int ref = readInt(); -+ -+ return _refs.get(ref); -+ } -+ -+ default: -+ if (tag < 0) -+ throw new EOFException("readObject: unexpected end of file"); -+ else -+ throw error("readObject: unknown code " + codeName(tag)); -+ } -+ } -+ -+ /** -+ * Reads an object definition: -+ * -+ *
-+   * O string  (string)* *
-+   * 
-+ */ -+ private void readObjectDefinition(Class cl) -+ throws IOException -+ { -+ String type = readString(); -+ int len = readInt(); -+ -+ SerializerFactory factory = findSerializerFactory(); -+ -+ Deserializer reader = factory.getObjectDeserializer(type, null); -+ -+ Object []fields = reader.createFields(len); -+ String []fieldNames = new String[len]; -+ -+ for (int i = 0; i < len; i++) { -+ String name = readString(); -+ -+ fields[i] = reader.createField(name); -+ fieldNames[i] = name; -+ } -+ -+ ObjectDefinition def -+ = new ObjectDefinition(type, reader, fields, fieldNames); -+ -+ _classDefs.add(def); -+ } -+ -+ private Object readObjectInstance(Class cl, -+ ObjectDefinition def) -+ throws IOException -+ { -+ String type = def.getType(); -+ Deserializer reader = def.getReader(); -+ Object []fields = def.getFields(); -+ -+ SerializerFactory factory = findSerializerFactory(); -+ -+ if (cl != reader.getType() && cl != null) { -+ reader = factory.getObjectDeserializer(type, cl); -+ -+ return reader.readObject(this, def.getFieldNames()); -+ } -+ else { -+ return reader.readObject(this, fields); -+ } -+ } -+ -+ /** -+ * Reads a remote object. -+ */ -+ public Object readRemote() -+ throws IOException -+ { -+ String type = readType(); -+ String url = readString(); -+ -+ return resolveRemote(type, url); -+ } -+ -+ /** -+ * Reads a reference. -+ */ -+ public Object readRef() -+ throws IOException -+ { -+ int value = parseInt(); -+ -+ return _refs.get(value); -+ } -+ -+ /** -+ * Reads the start of a list. -+ */ -+ public int readListStart() -+ throws IOException -+ { -+ return read(); -+ } -+ -+ /** -+ * Reads the start of a list. -+ */ -+ public int readMapStart() -+ throws IOException -+ { -+ return read(); -+ } -+ -+ /** -+ * Returns true if this is the end of a list or a map. -+ */ -+ public boolean isEnd() -+ throws IOException -+ { -+ int code; -+ -+ if (_offset < _length) -+ code = (_buffer[_offset] & 0xff); -+ else { -+ code = read(); -+ -+ if (code >= 0) -+ _offset--; -+ } -+ -+ return (code < 0 || code == 'Z'); -+ } -+ -+ /** -+ * Reads the end byte. -+ */ -+ public void readEnd() -+ throws IOException -+ { -+ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ if (code == 'Z') -+ return; -+ else if (code < 0) -+ throw error("unexpected end of file"); -+ else -+ throw error("unknown code:" + codeName(code)); -+ } -+ -+ /** -+ * Reads the end byte. -+ */ -+ public void readMapEnd() -+ throws IOException -+ { -+ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ if (code != 'Z') -+ throw error("expected end of map ('Z') at '" + codeName(code) + "'"); -+ } -+ -+ /** -+ * Reads the end byte. -+ */ -+ public void readListEnd() -+ throws IOException -+ { -+ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ if (code != 'Z') -+ throw error("expected end of list ('Z') at '" + codeName(code) + "'"); -+ } -+ -+ /** -+ * Adds a list/map reference. -+ */ -+ @Override -+ public int addRef(Object ref) -+ { -+ if (_refs == null) -+ _refs = new ArrayList(); -+ -+ _refs.add(ref); -+ -+ return _refs.size() - 1; -+ } -+ -+ /** -+ * Adds a list/map reference. -+ */ -+ public void setRef(int i, Object ref) -+ { -+ _refs.set(i, ref); -+ } -+ -+ /** -+ * Resets the references for streaming. -+ */ -+ @Override -+ public void resetReferences() -+ { -+ _refs.clear(); -+ } -+ -+ public void reset() -+ { -+ resetReferences(); -+ -+ _classDefs.clear(); -+ _types.clear(); -+ } -+ -+ public void resetBuffer() -+ { -+ int offset = _offset; -+ _offset = 0; -+ -+ int length = _length; -+ _length = 0; -+ -+ if (length > 0 && offset != length) -+ throw new IllegalStateException("offset=" + offset + " length=" + length); -+ } -+ -+ public Object readStreamingObject() -+ throws IOException -+ { -+ if (_refs != null) -+ _refs.clear(); -+ -+ return readObject(); -+ } -+ -+ /** -+ * Resolves a remote object. -+ */ -+ public Object resolveRemote(String type, String url) -+ throws IOException -+ { -+ HessianRemoteResolver resolver = getRemoteResolver(); -+ -+ if (resolver != null) -+ return resolver.lookup(type, url); -+ else -+ return new HessianRemote(type, url); -+ } -+ -+ /** -+ * Parses a type from the stream. -+ * -+ *
-+   * type ::= string
-+   * type ::= int
-+   * 
-+ */ -+ public String readType() -+ throws IOException -+ { -+ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ _offset--; -+ -+ switch (code) { -+ case 0x00: case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ case BC_STRING_CHUNK: case 'S': -+ { -+ String type = readString(); -+ -+ if (_types == null) -+ _types = new ArrayList(); -+ -+ _types.add(type); -+ -+ return type; -+ } -+ -+ default: -+ { -+ int ref = readInt(); -+ -+ if (_types.size() <= ref) -+ throw new IndexOutOfBoundsException("type ref #" + ref + " is greater than the number of valid types (" + _types.size() + ")"); -+ -+ return (String) _types.get(ref); -+ } -+ } -+ } -+ -+ /** -+ * Parses the length for an array -+ * -+ *
-+   * l b32 b24 b16 b8
-+   * 
-+ */ -+ public int readLength() -+ throws IOException -+ { -+ throw new UnsupportedOperationException(); -+ } -+ -+ /** -+ * Parses a 32-bit integer value from the stream. -+ * -+ *
-+   * b32 b24 b16 b8
-+   * 
-+ */ -+ private int parseInt() -+ throws IOException -+ { -+ int offset = _offset; -+ -+ if (offset + 3 < _length) { -+ byte []buffer = _buffer; -+ -+ int b32 = buffer[offset + 0] & 0xff; -+ int b24 = buffer[offset + 1] & 0xff; -+ int b16 = buffer[offset + 2] & 0xff; -+ int b8 = buffer[offset + 3] & 0xff; -+ -+ _offset = offset + 4; -+ -+ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -+ } -+ else { -+ int b32 = read(); -+ int b24 = read(); -+ int b16 = read(); -+ int b8 = read(); -+ -+ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -+ } -+ } -+ -+ /** -+ * Parses a 64-bit long value from the stream. -+ * -+ *
-+   * b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ private long parseLong() -+ throws IOException -+ { -+ long b64 = read(); -+ long b56 = read(); -+ long b48 = read(); -+ long b40 = read(); -+ long b32 = read(); -+ long b24 = read(); -+ long b16 = read(); -+ long b8 = read(); -+ -+ return ((b64 << 56) -+ + (b56 << 48) -+ + (b48 << 40) -+ + (b40 << 32) -+ + (b32 << 24) -+ + (b24 << 16) -+ + (b16 << 8) -+ + b8); -+ } -+ -+ /** -+ * Parses a 64-bit double value from the stream. -+ * -+ *
-+   * b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ private double parseDouble() -+ throws IOException -+ { -+ long bits = parseLong(); -+ -+ return Double.longBitsToDouble(bits); -+ } -+ -+ org.w3c.dom.Node parseXML() -+ throws IOException -+ { -+ throw new UnsupportedOperationException(); -+ } -+ -+ private void parseString(StringBuilder sbuf) -+ throws IOException -+ { -+ while (true) { -+ if (_chunkLength <= 0) { -+ if (! parseChunkLength()) -+ return; -+ } -+ -+ int length = _chunkLength; -+ _chunkLength = 0; -+ -+ while (length-- > 0) { -+ sbuf.append((char) parseUTF8Char()); -+ } -+ } -+ } -+ -+ /** -+ * Reads a character from the underlying stream. -+ */ -+ private int parseChar() -+ throws IOException -+ { -+ while (_chunkLength <= 0) { -+ if (! parseChunkLength()) -+ return -1; -+ } -+ -+ _chunkLength--; -+ -+ return parseUTF8Char(); -+ } -+ -+ private boolean parseChunkLength() -+ throws IOException -+ { -+ if (_isLastChunk) -+ return false; -+ -+ int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ switch (code) { -+ case BC_STRING_CHUNK: -+ _isLastChunk = false; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 'S': -+ _isLastChunk = true; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 0x00: case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ _isLastChunk = true; -+ _chunkLength = code - 0x00; -+ break; -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ _isLastChunk = true; -+ _chunkLength = (code - 0x30) * 256 + read(); -+ break; -+ -+ default: -+ throw expect("string", code); -+ } -+ -+ return true; -+ } -+ -+ /** -+ * Parses a single UTF8 character. -+ */ -+ private int parseUTF8Char() -+ throws IOException -+ { -+ int ch = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); -+ -+ if (ch < 0x80) -+ return ch; -+ else if ((ch & 0xe0) == 0xc0) { -+ int ch1 = read(); -+ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -+ -+ return v; -+ } -+ else if ((ch & 0xf0) == 0xe0) { -+ int ch1 = read(); -+ int ch2 = read(); -+ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -+ -+ return v; -+ } -+ else -+ throw error("bad utf-8 encoding at " + codeName(ch)); -+ } -+ -+ /** -+ * Reads a byte from the underlying stream. -+ */ -+ private int parseByte() -+ throws IOException -+ { -+ while (_chunkLength <= 0) { -+ if (_isLastChunk) { -+ return -1; -+ } -+ -+ int code = read(); -+ -+ switch (code) { -+ case BC_BINARY_CHUNK: -+ _isLastChunk = false; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 'B': -+ _isLastChunk = true; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 0x20: case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ _isLastChunk = true; -+ -+ _chunkLength = code - 0x20; -+ break; -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ _isLastChunk = true; -+ _chunkLength = (code - 0x34) * 256 + read(); -+ break; -+ -+ default: -+ throw expect("byte[]", code); -+ } -+ } -+ -+ _chunkLength--; -+ -+ return read(); -+ } -+ -+ /** -+ * Reads bytes based on an input stream. -+ */ -+ public InputStream readInputStream() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case BC_BINARY: -+ case BC_BINARY_CHUNK: -+ _isLastChunk = tag == BC_BINARY; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 0x20: case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ _isLastChunk = true; -+ _chunkLength = tag - 0x20; -+ break; -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ _isLastChunk = true; -+ _chunkLength = (tag - 0x34) * 256 + read(); -+ break; -+ -+ default: -+ throw expect("binary", tag); -+ } -+ -+ return new ReadInputStream(); -+ } -+ -+ /** -+ * Reads bytes from the underlying stream. -+ */ -+ int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ int readLength = 0; -+ -+ while (length > 0) { -+ while (_chunkLength <= 0) { -+ if (_isLastChunk) -+ return readLength == 0 ? -1 : readLength; -+ -+ int code = read(); -+ -+ switch (code) { -+ case BC_BINARY_CHUNK: -+ _isLastChunk = false; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case BC_BINARY: -+ _isLastChunk = true; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 0x20: case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ _isLastChunk = true; -+ _chunkLength = code - 0x20; -+ break; -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ _isLastChunk = true; -+ _chunkLength = (code - 0x34) * 256 + read(); -+ break; -+ -+ default: -+ throw expect("byte[]", code); -+ } -+ } -+ -+ int sublen = _chunkLength; -+ if (length < sublen) -+ sublen = length; -+ -+ if (_length <= _offset && ! readBuffer()) -+ return -1; -+ -+ if (_length - _offset < sublen) -+ sublen = _length - _offset; -+ -+ System.arraycopy(_buffer, _offset, buffer, offset, sublen); -+ -+ _offset += sublen; -+ -+ offset += sublen; -+ readLength += sublen; -+ length -= sublen; -+ _chunkLength -= sublen; -+ } -+ -+ return readLength; -+ } -+ -+ /** -+ * Normally, shouldn't be called externally, but needed for QA, e.g. -+ * ejb/3b01. -+ */ -+ public final int read() -+ throws IOException -+ { -+ if (_length <= _offset && ! readBuffer()) -+ return -1; -+ -+ return _buffer[_offset++] & 0xff; -+ } -+ -+ protected void unread() -+ { -+ if (_offset <= 0) -+ throw new IllegalStateException(); -+ -+ _offset--; -+ } -+ -+ private final boolean readBuffer() -+ throws IOException -+ { -+ byte []buffer = _buffer; -+ int offset = _offset; -+ int length = _length; -+ -+ if (offset < length) { -+ System.arraycopy(buffer, offset, buffer, 0, length - offset); -+ offset = length - offset; -+ } -+ else -+ offset = 0; -+ -+ int len = _is.read(buffer, offset, SIZE - offset); -+ -+ if (len <= 0) { -+ _length = offset; -+ _offset = 0; -+ -+ return offset > 0; -+ } -+ -+ _length = offset + len; -+ _offset = 0; -+ -+ return true; -+ } -+ -+ public Reader getReader() -+ { -+ return null; -+ } -+ -+ protected IOException expect(String expect, int ch) -+ throws IOException -+ { -+ if (ch < 0) -+ return error("expected " + expect + " at end of file"); -+ else { -+ _offset--; -+ -+ try { -+ int offset = _offset; -+ String context -+ = buildDebugContext(_buffer, 0, _length, offset); -+ -+ Object obj = readObject(); -+ -+ if (obj != null) { -+ return error("expected " + expect -+ + " at 0x" + Integer.toHexString(ch & 0xff) -+ + " " + obj.getClass().getName() + " (" + obj + ")" -+ + "\n " + context + ""); -+ } -+ else -+ return error("expected " + expect -+ + " at 0x" + Integer.toHexString(ch & 0xff) + " null"); -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ -+ return error("expected " + expect -+ + " at 0x" + Integer.toHexString(ch & 0xff)); -+ } -+ } -+ } -+ -+ private String buildDebugContext(byte []buffer, int offset, int length, -+ int errorOffset) -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ sb.append("["); -+ for (int i = 0; i < errorOffset; i++) { -+ int ch = buffer[offset + i]; -+ addDebugChar(sb, ch); -+ } -+ sb.append("] "); -+ addDebugChar(sb, buffer[offset + errorOffset]); -+ sb.append(" ["); -+ for (int i = errorOffset + 1; i < length; i++) { -+ int ch = buffer[offset + i]; -+ addDebugChar(sb, ch); -+ } -+ sb.append("]"); -+ -+ return sb.toString(); -+ } -+ -+ private void addDebugChar(StringBuilder sb, int ch) -+ { -+ if (ch >= 0x20 && ch < 0x7f) { -+ sb.append((char) ch); -+ } -+ else if (ch == '\n') -+ sb.append((char) ch); -+ else -+ sb.append(String.format("\\x%02x", ch & 0xff)); -+ } -+ -+ protected String codeName(int ch) -+ { -+ if (ch < 0) -+ return "end of file"; -+ else -+ return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; -+ } -+ -+ protected IOException error(String message) -+ { -+ if (_method != null) -+ return new HessianProtocolException(_method + ": " + message); -+ else -+ return new HessianProtocolException(message); -+ } -+ -+ public void free() -+ { -+ reset(); -+ } -+ -+ @Override -+ public void close() -+ throws IOException -+ { -+ InputStream is = _is; -+ _is = null; -+ -+ if (_isCloseStreamOnClose && is != null) -+ is.close(); -+ } -+ -+ class ReadInputStream extends InputStream { -+ boolean _isClosed = false; -+ -+ public int read() -+ throws IOException -+ { -+ if (_isClosed) -+ return -1; -+ -+ int ch = parseByte(); -+ if (ch < 0) -+ _isClosed = true; -+ -+ return ch; -+ } -+ -+ public int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (_isClosed) -+ return -1; -+ -+ int len = Hessian2Input.this.read(buffer, offset, length); -+ if (len < 0) -+ _isClosed = true; -+ -+ return len; -+ } -+ -+ public void close() -+ throws IOException -+ { -+ while (read() >= 0) { -+ } -+ } -+ }; -+ -+ final static class ObjectDefinition { -+ private final String _type; -+ private final Deserializer _reader; -+ private final Object []_fields; -+ private final String []_fieldNames; -+ -+ ObjectDefinition(String type, -+ Deserializer reader, -+ Object []fields, -+ String []fieldNames) -+ { -+ _type = type; -+ _reader = reader; -+ _fields = fields; -+ _fieldNames = fieldNames; -+ } -+ -+ String getType() -+ { -+ return _type; -+ } -+ -+ Deserializer getReader() -+ { -+ return _reader; -+ } -+ -+ Object []getFields() -+ { -+ return _fields; -+ } -+ -+ String []getFieldNames() -+ { -+ return _fieldNames; -+ } -+ } -+ -+ private static Field getDetailMessageField() -+ { -+ if (_detailMessageField == null) { -+ try { -+ _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); -+ _detailMessageField.setAccessible(true); -+ } catch (Throwable e) { -+ } -+ } -+ -+ return _detailMessageField; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Output.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Output.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2Output.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2Output.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,1788 +1,1788 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import com.caucho.hessian.util.IdentityIntMap; -- --import java.io.InputStream; --import java.io.IOException; --import java.io.OutputStream; --import java.util.HashMap; -- --/** -- * Output stream for Hessian 2 requests. -- * -- *

Since HessianOutput does not depend on any classes other than -- * in the JDK, it can be extracted independently into a smaller package. -- * -- *

HessianOutput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * OutputStream os = ...; // from http connection
-- * Hessian2Output out = new Hessian2Output(os);
-- * String value;
-- *
-- * out.startCall("hello", 1); // start hello call
-- * out.writeString("arg1");   // write a string argument
-- * out.completeCall();        // complete the call
-- * 
-- */ --public class Hessian2Output -- extends AbstractHessianOutput -- implements Hessian2Constants --{ -- // should match Resin buffer size for perf -- public final static int SIZE = 8 * 1024; -- -- // the output stream/ -- protected OutputStream _os; -- -- // map of references -- private final IdentityIntMap _refs -- = new IdentityIntMap(256); -- -- private int _refCount = 0; -- -- private boolean _isCloseStreamOnClose; -- -- // map of classes -- private final IdentityIntMap _classRefs -- = new IdentityIntMap(256); -- -- // map of types -- private HashMap _typeRefs; -- -- private final byte []_buffer = new byte[SIZE]; -- private int _offset; -- -- private boolean _isPacket; -- -- private boolean _isUnshared; -- -- /** -- * Creates a new Hessian output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public Hessian2Output() -- { -- } -- -- /** -- * Creates a new Hessian output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public Hessian2Output(OutputStream os) -- { -- init(os); -- } -- -- @Override -- public void init(OutputStream os) -- { -- reset(); -- -- _os = os; -- } -- -- public void initPacket(OutputStream os) -- { -- resetReferences(); -- -- _os = os; -- } -- -- public void setCloseStreamOnClose(boolean isClose) -- { -- _isCloseStreamOnClose = isClose; -- } -- -- public boolean isCloseStreamOnClose() -- { -- return _isCloseStreamOnClose; -- } -- -- /** -- * Sets hessian to be "unshared", meaning it will not detect -- * duplicate or circular references. -- */ -- @Override -- public boolean setUnshared(boolean isUnshared) -- { -- boolean oldIsUnshared = _isUnshared; -- -- _isUnshared = isUnshared; -- -- return oldIsUnshared; -- } -- -- /** -- * Writes a complete method call. -- */ -- @Override -- public void call(String method, Object []args) -- throws IOException -- { -- writeVersion(); -- -- int length = args != null ? args.length : 0; -- -- startCall(method, length); -- -- for (int i = 0; i < length; i++) { -- writeObject(args[i]); -- } -- -- completeCall(); -- -- flush(); -- } -- -- /** -- * Starts the method call. Clients would use startCall -- * instead of call if they wanted finer control over -- * writing the arguments, or needed to write headers. -- * -- *
--   * C
--   * string # method name
--   * int    # arg count
--   * 
-- * -- * @param method the method name to call. -- */ -- @Override -- public void startCall(String method, int length) -- throws IOException -- { -- int offset = _offset; -- -- if (SIZE < offset + 32) { -- flushBuffer(); -- offset = _offset; -- } -- -- byte []buffer = _buffer; -- -- buffer[_offset++] = (byte) 'C'; -- -- writeString(method); -- writeInt(length); -- } -- -- /** -- * Writes the call tag. This would be followed by the -- * method and the arguments -- * -- *
--   * C
--   * 
-- * -- * @param method the method name to call. -- */ -- @Override -- public void startCall() -- throws IOException -- { -- flushIfFull(); -- -- _buffer[_offset++] = (byte) 'C'; -- } -- -- /** -- * Starts an envelope. -- * -- *
--   * E major minor
--   * m b16 b8 method-name
--   * 
-- * -- * @param method the method name to call. -- */ -- public void startEnvelope(String method) -- throws IOException -- { -- int offset = _offset; -- -- if (SIZE < offset + 32) { -- flushBuffer(); -- offset = _offset; -- } -- -- _buffer[_offset++] = (byte) 'E'; -- -- writeString(method); -- } -- -- /** -- * Completes an envelope. -- * -- *

A successful completion will have a single value: -- * -- *

--   * Z
--   * 
-- */ -- public void completeEnvelope() -- throws IOException -- { -- flushIfFull(); -- -- _buffer[_offset++] = (byte) 'Z'; -- } -- -- /** -- * Writes the method tag. -- * -- *
--   * string
--   * 
-- * -- * @param method the method name to call. -- */ -- public void writeMethod(String method) -- throws IOException -- { -- writeString(method); -- } -- -- /** -- * Completes. -- * -- *
--   * z
--   * 
-- */ -- @Override -- public void completeCall() -- throws IOException -- { -- /* -- flushIfFull(); -- -- _buffer[_offset++] = (byte) 'Z'; -- */ -- } -- -- /** -- * Starts the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * R
--   * 
-- */ -- @Override -- public void startReply() -- throws IOException -- { -- writeVersion(); -- -- flushIfFull(); -- -- _buffer[_offset++] = (byte) 'R'; -- } -- -- public void writeVersion() -- throws IOException -- { -- flushIfFull(); -- -- _buffer[_offset++] = (byte) 'H'; -- _buffer[_offset++] = (byte) 2; -- _buffer[_offset++] = (byte) 0; -- } -- -- /** -- * Completes reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- @Override -- public void completeReply() -- throws IOException -- { -- } -- -- /** -- * Starts a packet -- * -- *

A message contains several objects encapsulated by a length

-- * -- *
--   * p x02 x00
--   * 
-- */ -- public void startMessage() -- throws IOException -- { -- flushIfFull(); -- -- _buffer[_offset++] = (byte) 'p'; -- _buffer[_offset++] = (byte) 2; -- _buffer[_offset++] = (byte) 0; -- } -- -- /** -- * Completes reading the message -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeMessage() -- throws IOException -- { -- flushIfFull(); -- -- _buffer[_offset++] = (byte) 'z'; -- } -- -- /** -- * Writes a fault. The fault will be written -- * as a descriptive string followed by an object: -- * -- *
--   * F map
--   * 
-- * -- *
--   * F H
--   * \x04code
--   * \x10the fault code
--   *
--   * \x07message
--   * \x11the fault message
--   *
--   * \x06detail
--   * M\xnnjavax.ejb.FinderException
--   *     ...
--   * Z
--   * Z
--   * 
-- * -- * @param code the fault code, a three digit -- */ -- public void writeFault(String code, String message, Object detail) -- throws IOException -- { -- flushIfFull(); -- -- writeVersion(); -- -- _buffer[_offset++] = (byte) 'F'; -- _buffer[_offset++] = (byte) 'H'; -- -- addRef(new Object(), _refCount++, false); -- -- writeString("code"); -- writeString(code); -- -- writeString("message"); -- writeString(message); -- -- if (detail != null) { -- writeString("detail"); -- writeObject(detail); -- } -- -- flushIfFull(); -- _buffer[_offset++] = (byte) 'Z'; -- } -- -- /** -- * Writes any object to the output stream. -- */ -- @Override -- public void writeObject(Object object) -- throws IOException -- { -- if (object == null) { -- writeNull(); -- return; -- } -- -- Serializer serializer -- = findSerializerFactory().getObjectSerializer(object.getClass()); -- -- serializer.writeObject(object, this); -- } -- -- /** -- * Writes the list header to the stream. List writers will call -- * writeListBegin followed by the list contents and then -- * call writeListEnd. -- * -- *
--   * list ::= V type value* Z
--   *      ::= v type int value*
--   * 
-- * -- * @return true for variable lists, false for fixed lists -- */ -- public boolean writeListBegin(int length, String type) -- throws IOException -- { -- flushIfFull(); -- -- if (length < 0) { -- if (type != null) { -- _buffer[_offset++] = (byte) BC_LIST_VARIABLE; -- writeType(type); -- } -- else -- _buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED; -- -- return true; -- } -- else if (length <= LIST_DIRECT_MAX) { -- if (type != null) { -- _buffer[_offset++] = (byte) (BC_LIST_DIRECT + length); -- writeType(type); -- } -- else { -- _buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length); -- } -- -- return false; -- } -- else { -- if (type != null) { -- _buffer[_offset++] = (byte) BC_LIST_FIXED; -- writeType(type); -- } -- else { -- _buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED; -- } -- -- writeInt(length); -- -- return false; -- } -- } -- -- /** -- * Writes the tail of the list to the stream for a variable-length list. -- */ -- public void writeListEnd() -- throws IOException -- { -- flushIfFull(); -- -- _buffer[_offset++] = (byte) BC_END; -- } -- -- /** -- * Writes the map header to the stream. Map writers will call -- * writeMapBegin followed by the map contents and then -- * call writeMapEnd. -- * -- *
--   * map ::= M type ( )* Z
--   *     ::= H ( )* Z
--   * 
-- */ -- public void writeMapBegin(String type) -- throws IOException -- { -- if (SIZE < _offset + 32) -- flushBuffer(); -- -- if (type != null) { -- _buffer[_offset++] = BC_MAP; -- -- writeType(type); -- } -- else -- _buffer[_offset++] = BC_MAP_UNTYPED; -- } -- -- /** -- * Writes the tail of the map to the stream. -- */ -- public void writeMapEnd() -- throws IOException -- { -- if (SIZE < _offset + 32) -- flushBuffer(); -- -- _buffer[_offset++] = (byte) BC_END; -- } -- -- /** -- * Writes the object definition -- * -- *
--   * C <string> <int> <string>*
--   * 
-- */ -- @Override -- public int writeObjectBegin(String type) -- throws IOException -- { -- int newRef = _classRefs.size(); -- int ref = _classRefs.put(type, newRef, false); -- -- if (newRef != ref) { -- if (SIZE < _offset + 32) -- flushBuffer(); -- -- if (ref <= OBJECT_DIRECT_MAX) { -- _buffer[_offset++] = (byte) (BC_OBJECT_DIRECT + ref); -- } -- else { -- _buffer[_offset++] = (byte) 'O'; -- writeInt(ref); -- } -- -- return ref; -- } -- else { -- if (SIZE < _offset + 32) -- flushBuffer(); -- -- _buffer[_offset++] = (byte) 'C'; -- -- writeString(type); -- -- return -1; -- } -- } -- -- /** -- * Writes the tail of the class definition to the stream. -- */ -- @Override -- public void writeClassFieldLength(int len) -- throws IOException -- { -- writeInt(len); -- } -- -- /** -- * Writes the tail of the object definition to the stream. -- */ -- @Override -- public void writeObjectEnd() -- throws IOException -- { -- } -- -- /** -- *
--   * type ::= string
--   *      ::= int
--   * 
-- */ -- private void writeType(String type) -- throws IOException -- { -- flushIfFull(); -- -- int len = type.length(); -- if (len == 0) { -- throw new IllegalArgumentException("empty type is not allowed"); -- } -- -- if (_typeRefs == null) -- _typeRefs = new HashMap(); -- -- Integer typeRefV = (Integer) _typeRefs.get(type); -- -- if (typeRefV != null) { -- int typeRef = typeRefV.intValue(); -- -- writeInt(typeRef); -- } -- else { -- _typeRefs.put(type, Integer.valueOf(_typeRefs.size())); -- -- writeString(type); -- } -- } -- -- /** -- * Writes a boolean value to the stream. The boolean will be written -- * with the following syntax: -- * -- *
--   * T
--   * F
--   * 
-- * -- * @param value the boolean value to write. -- */ -- @Override -- public void writeBoolean(boolean value) -- throws IOException -- { -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- if (value) -- _buffer[_offset++] = (byte) 'T'; -- else -- _buffer[_offset++] = (byte) 'F'; -- } -- -- /** -- * Writes an integer value to the stream. The integer will be written -- * with the following syntax: -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- * -- * @param value the integer value to write. -- */ -- @Override -- public void writeInt(int value) -- throws IOException -- { -- int offset = _offset; -- byte []buffer = _buffer; -- -- if (SIZE <= offset + 16) { -- flushBuffer(); -- offset = _offset; -- } -- -- if (INT_DIRECT_MIN <= value && value <= INT_DIRECT_MAX) -- buffer[offset++] = (byte) (value + BC_INT_ZERO); -- else if (INT_BYTE_MIN <= value && value <= INT_BYTE_MAX) { -- buffer[offset++] = (byte) (BC_INT_BYTE_ZERO + (value >> 8)); -- buffer[offset++] = (byte) (value); -- } -- else if (INT_SHORT_MIN <= value && value <= INT_SHORT_MAX) { -- buffer[offset++] = (byte) (BC_INT_SHORT_ZERO + (value >> 16)); -- buffer[offset++] = (byte) (value >> 8); -- buffer[offset++] = (byte) (value); -- } -- else { -- buffer[offset++] = (byte) ('I'); -- buffer[offset++] = (byte) (value >> 24); -- buffer[offset++] = (byte) (value >> 16); -- buffer[offset++] = (byte) (value >> 8); -- buffer[offset++] = (byte) (value); -- } -- -- _offset = offset; -- } -- -- /** -- * Writes a long value to the stream. The long will be written -- * with the following syntax: -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param value the long value to write. -- */ -- public void writeLong(long value) -- throws IOException -- { -- int offset = _offset; -- byte []buffer = _buffer; -- -- if (SIZE <= offset + 16) { -- flushBuffer(); -- offset = _offset; -- } -- -- if (LONG_DIRECT_MIN <= value && value <= LONG_DIRECT_MAX) { -- buffer[offset++] = (byte) (value + BC_LONG_ZERO); -- } -- else if (LONG_BYTE_MIN <= value && value <= LONG_BYTE_MAX) { -- buffer[offset++] = (byte) (BC_LONG_BYTE_ZERO + (value >> 8)); -- buffer[offset++] = (byte) (value); -- } -- else if (LONG_SHORT_MIN <= value && value <= LONG_SHORT_MAX) { -- buffer[offset++] = (byte) (BC_LONG_SHORT_ZERO + (value >> 16)); -- buffer[offset++] = (byte) (value >> 8); -- buffer[offset++] = (byte) (value); -- } -- else if (-0x80000000L <= value && value <= 0x7fffffffL) { -- buffer[offset + 0] = (byte) BC_LONG_INT; -- buffer[offset + 1] = (byte) (value >> 24); -- buffer[offset + 2] = (byte) (value >> 16); -- buffer[offset + 3] = (byte) (value >> 8); -- buffer[offset + 4] = (byte) (value); -- -- offset += 5; -- } -- else { -- buffer[offset + 0] = (byte) 'L'; -- buffer[offset + 1] = (byte) (value >> 56); -- buffer[offset + 2] = (byte) (value >> 48); -- buffer[offset + 3] = (byte) (value >> 40); -- buffer[offset + 4] = (byte) (value >> 32); -- buffer[offset + 5] = (byte) (value >> 24); -- buffer[offset + 6] = (byte) (value >> 16); -- buffer[offset + 7] = (byte) (value >> 8); -- buffer[offset + 8] = (byte) (value); -- -- offset += 9; -- } -- -- _offset = offset; -- } -- -- /** -- * Writes a double value to the stream. The double will be written -- * with the following syntax: -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param value the double value to write. -- */ -- public void writeDouble(double value) -- throws IOException -- { -- int offset = _offset; -- byte []buffer = _buffer; -- -- if (SIZE <= offset + 16) { -- flushBuffer(); -- offset = _offset; -- } -- -- int intValue = (int) value; -- -- if (intValue == value) { -- if (intValue == 0) { -- buffer[offset++] = (byte) BC_DOUBLE_ZERO; -- -- _offset = offset; -- -- return; -- } -- else if (intValue == 1) { -- buffer[offset++] = (byte) BC_DOUBLE_ONE; -- -- _offset = offset; -- -- return; -- } -- else if (-0x80 <= intValue && intValue < 0x80) { -- buffer[offset++] = (byte) BC_DOUBLE_BYTE; -- buffer[offset++] = (byte) intValue; -- -- _offset = offset; -- -- return; -- } -- else if (-0x8000 <= intValue && intValue < 0x8000) { -- buffer[offset + 0] = (byte) BC_DOUBLE_SHORT; -- buffer[offset + 1] = (byte) (intValue >> 8); -- buffer[offset + 2] = (byte) intValue; -- -- _offset = offset + 3; -- -- return; -- } -- } -- -- int mills = (int) (value * 1000); -- -- if (0.001 * mills == value) { -- buffer[offset + 0] = (byte) (BC_DOUBLE_MILL); -- buffer[offset + 1] = (byte) (mills >> 24); -- buffer[offset + 2] = (byte) (mills >> 16); -- buffer[offset + 3] = (byte) (mills >> 8); -- buffer[offset + 4] = (byte) (mills); -- -- _offset = offset + 5; -- -- return; -- } -- -- long bits = Double.doubleToLongBits(value); -- -- buffer[offset + 0] = (byte) 'D'; -- buffer[offset + 1] = (byte) (bits >> 56); -- buffer[offset + 2] = (byte) (bits >> 48); -- buffer[offset + 3] = (byte) (bits >> 40); -- buffer[offset + 4] = (byte) (bits >> 32); -- buffer[offset + 5] = (byte) (bits >> 24); -- buffer[offset + 6] = (byte) (bits >> 16); -- buffer[offset + 7] = (byte) (bits >> 8); -- buffer[offset + 8] = (byte) (bits); -- -- _offset = offset + 9; -- } -- -- /** -- * Writes a date to the stream. -- * -- *
--   * date ::= d   b7 b6 b5 b4 b3 b2 b1 b0
--   *      ::= x65 b3 b2 b1 b0
--   * 
-- * -- * @param time the date in milliseconds from the epoch in UTC -- */ -- public void writeUTCDate(long time) -- throws IOException -- { -- if (SIZE < _offset + 32) -- flushBuffer(); -- -- int offset = _offset; -- byte []buffer = _buffer; -- -- if (time % 60000L == 0) { -- // compact date ::= x65 b3 b2 b1 b0 -- -- long minutes = time / 60000L; -- -- if ((minutes >> 31) == 0 || (minutes >> 31) == -1) { -- buffer[offset++] = (byte) BC_DATE_MINUTE; -- buffer[offset++] = ((byte) (minutes >> 24)); -- buffer[offset++] = ((byte) (minutes >> 16)); -- buffer[offset++] = ((byte) (minutes >> 8)); -- buffer[offset++] = ((byte) (minutes >> 0)); -- -- _offset = offset; -- return; -- } -- } -- -- buffer[offset++] = (byte) BC_DATE; -- buffer[offset++] = ((byte) (time >> 56)); -- buffer[offset++] = ((byte) (time >> 48)); -- buffer[offset++] = ((byte) (time >> 40)); -- buffer[offset++] = ((byte) (time >> 32)); -- buffer[offset++] = ((byte) (time >> 24)); -- buffer[offset++] = ((byte) (time >> 16)); -- buffer[offset++] = ((byte) (time >> 8)); -- buffer[offset++] = ((byte) (time)); -- -- _offset = offset; -- } -- -- /** -- * Writes a null value to the stream. -- * The null will be written with the following syntax -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeNull() -- throws IOException -- { -- int offset = _offset; -- byte []buffer = _buffer; -- -- if (SIZE <= offset + 16) { -- flushBuffer(); -- offset = _offset; -- } -- -- buffer[offset++] = 'N'; -- -- _offset = offset; -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(String value) -- throws IOException -- { -- int offset = _offset; -- byte []buffer = _buffer; -- -- if (SIZE <= offset + 16) { -- flushBuffer(); -- offset = _offset; -- } -- -- if (value == null) { -- buffer[offset++] = (byte) 'N'; -- -- _offset = offset; -- } -- else { -- int length = value.length(); -- int strOffset = 0; -- -- while (length > 0x8000) { -- int sublen = 0x8000; -- -- offset = _offset; -- -- if (SIZE <= offset + 16) { -- flushBuffer(); -- offset = _offset; -- } -- -- // chunk can't end in high surrogate -- char tail = value.charAt(strOffset + sublen - 1); -- -- if (0xd800 <= tail && tail <= 0xdbff) -- sublen--; -- -- buffer[offset + 0] = (byte) BC_STRING_CHUNK; -- buffer[offset + 1] = (byte) (sublen >> 8); -- buffer[offset + 2] = (byte) (sublen); -- -- _offset = offset + 3; -- -- printString(value, strOffset, sublen); -- -- length -= sublen; -- strOffset += sublen; -- } -- -- offset = _offset; -- -- if (SIZE <= offset + 16) { -- flushBuffer(); -- offset = _offset; -- } -- -- if (length <= STRING_DIRECT_MAX) { -- buffer[offset++] = (byte) (BC_STRING_DIRECT + length); -- } -- else if (length <= STRING_SHORT_MAX) { -- buffer[offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); -- buffer[offset++] = (byte) (length); -- } -- else { -- buffer[offset++] = (byte) ('S'); -- buffer[offset++] = (byte) (length >> 8); -- buffer[offset++] = (byte) (length); -- } -- -- _offset = offset; -- -- printString(value, strOffset, length); -- } -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(char []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- _buffer[_offset++] = (byte) ('N'); -- } -- else { -- while (length > 0x8000) { -- int sublen = 0x8000; -- -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- // chunk can't end in high surrogate -- char tail = buffer[offset + sublen - 1]; -- -- if (0xd800 <= tail && tail <= 0xdbff) -- sublen--; -- -- _buffer[_offset++] = (byte) BC_STRING_CHUNK; -- _buffer[_offset++] = (byte) (sublen >> 8); -- _buffer[_offset++] = (byte) (sublen); -- -- printString(buffer, offset, sublen); -- -- length -= sublen; -- offset += sublen; -- } -- -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- if (length <= STRING_DIRECT_MAX) { -- _buffer[_offset++] = (byte) (BC_STRING_DIRECT + length); -- } -- else if (length <= STRING_SHORT_MAX) { -- _buffer[_offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); -- _buffer[_offset++] = (byte) length; -- } -- else { -- _buffer[_offset++] = (byte) ('S'); -- _buffer[_offset++] = (byte) (length >> 8); -- _buffer[_offset++] = (byte) (length); -- } -- -- printString(buffer, offset, length); -- } -- } -- -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer) -- throws IOException -- { -- if (buffer == null) { -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- _buffer[_offset++] = 'N'; -- } -- else -- writeBytes(buffer, 0, buffer.length); -- } -- -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- _buffer[_offset++] = (byte) 'N'; -- } -- else { -- while (SIZE - _offset - 3 < length) { -- int sublen = SIZE - _offset - 3; -- -- if (sublen < 16) { -- flushBuffer(); -- -- sublen = SIZE - _offset - 3; -- -- if (length < sublen) -- sublen = length; -- } -- -- _buffer[_offset++] = (byte) BC_BINARY_CHUNK; -- _buffer[_offset++] = (byte) (sublen >> 8); -- _buffer[_offset++] = (byte) sublen; -- -- System.arraycopy(buffer, offset, _buffer, _offset, sublen); -- _offset += sublen; -- -- length -= sublen; -- offset += sublen; -- -- flushBuffer(); -- } -- -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- if (length <= BINARY_DIRECT_MAX) { -- _buffer[_offset++] = (byte) (BC_BINARY_DIRECT + length); -- } -- else if (length <= BINARY_SHORT_MAX) { -- _buffer[_offset++] = (byte) (BC_BINARY_SHORT + (length >> 8)); -- _buffer[_offset++] = (byte) (length); -- } -- else { -- _buffer[_offset++] = (byte) 'B'; -- _buffer[_offset++] = (byte) (length >> 8); -- _buffer[_offset++] = (byte) (length); -- } -- -- System.arraycopy(buffer, offset, _buffer, _offset, length); -- -- _offset += length; -- } -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * 
-- */ -- public void writeByteBufferStart() -- throws IOException -- { -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- */ -- public void writeByteBufferPart(byte []buffer, int offset, int length) -- throws IOException -- { -- while (length > 0) { -- flushIfFull(); -- -- int sublen = _buffer.length - _offset; -- -- if (length < sublen) -- sublen = length; -- -- _buffer[_offset++] = BC_BINARY_CHUNK; -- _buffer[_offset++] = (byte) (sublen >> 8); -- _buffer[_offset++] = (byte) sublen; -- -- System.arraycopy(buffer, offset, _buffer, _offset, sublen); -- -- _offset += sublen; -- length -= sublen; -- offset += sublen; -- } -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- */ -- public void writeByteBufferEnd(byte []buffer, int offset, int length) -- throws IOException -- { -- writeBytes(buffer, offset, length); -- } -- -- /** -- * Returns an output stream to write binary data. -- */ -- public OutputStream getBytesOutputStream() -- throws IOException -- { -- return new BytesOutputStream(); -- } -- -- /** -- * Writes a full output stream. -- */ -- @Override -- public void writeByteStream(InputStream is) -- throws IOException -- { -- while (true) { -- int len = SIZE - _offset - 3; -- -- if (len < 16) { -- flushBuffer(); -- len = SIZE - _offset - 3; -- } -- -- len = is.read(_buffer, _offset + 3, len); -- -- if (len <= 0) { -- _buffer[_offset++] = BC_BINARY_DIRECT; -- return; -- } -- -- _buffer[_offset + 0] = (byte) BC_BINARY_CHUNK; -- _buffer[_offset + 1] = (byte) (len >> 8); -- _buffer[_offset + 2] = (byte) (len); -- -- _offset += len + 3; -- } -- } -- -- /** -- * Writes a reference. -- * -- *
--   * x51 <int>
--   * 
-- * -- * @param value the integer value to write. -- */ -- @Override -- protected void writeRef(int value) -- throws IOException -- { -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- _buffer[_offset++] = (byte) BC_REF; -- -- writeInt(value); -- } -- -- /** -- * If the object has already been written, just write its ref. -- * -- * @return true if we're writing a ref. -- */ -- @Override -- public boolean addRef(Object object) -- throws IOException -- { -- if (_isUnshared) { -- _refCount++; -- return false; -- } -- -- int newRef = _refCount; -- -- int ref = addRef(object, newRef, false); -- -- if (ref != newRef) { -- writeRef(ref); -- -- return true; -- } -- else { -- _refCount++; -- -- return false; -- } -- } -- -- @Override -- public int getRef(Object obj) -- { -- if (_isUnshared) -- return -1; -- -- return _refs.get(obj); -- } -- -- /** -- * Removes a reference. -- */ -- @Override -- public boolean removeRef(Object obj) -- throws IOException -- { -- if (_isUnshared) { -- return false; -- } -- else if (_refs != null) { -- _refs.remove(obj); -- -- return true; -- } -- else -- return false; -- } -- -- /** -- * Replaces a reference from one object to another. -- */ -- @Override -- public boolean replaceRef(Object oldRef, Object newRef) -- throws IOException -- { -- if (_isUnshared) { -- return false; -- } -- -- int value = _refs.get(oldRef); -- -- if (value >= 0) { -- addRef(newRef, value, true); -- -- _refs.remove(oldRef); -- -- return true; -- } -- else -- return false; -- } -- -- private int addRef(Object value, int newRef, boolean isReplace) -- { -- int prevRef = _refs.put(value, newRef, isReplace); -- -- return prevRef; -- } -- -- /** -- * Starts the streaming message -- * -- *

A streaming message starts with 'P'

-- * -- *
--   * P x02 x00
--   * 
-- */ -- public void writeStreamingObject(Object obj) -- throws IOException -- { -- startPacket(); -- -- writeObject(obj); -- -- endPacket(); -- } -- -- /** -- * Starts a streaming packet -- * -- *

A streaming contains a set of chunks, ending with a zero chunk. -- * Each chunk is a length followed by data where the length is -- * encoded by (b1xxxxxxxx)* b0xxxxxxxx

-- */ -- public void startPacket() -- throws IOException -- { -- if (_refs != null) { -- _refs.clear(); -- _refCount = 0; -- } -- -- flushBuffer(); -- -- _isPacket = true; -- _offset = 4; -- _buffer[0] = (byte) 0x05; // 0x05 = binary -- _buffer[1] = (byte) 0x55; -- _buffer[2] = (byte) 0x55; -- _buffer[3] = (byte) 0x55; -- } -- -- public void endPacket() -- throws IOException -- { -- int offset = _offset; -- -- OutputStream os = _os; -- -- if (os == null) { -- _offset = 0; -- return; -- } -- -- int len = offset - 4; -- -- if (len < 0x7e) { -- _buffer[2] = _buffer[0]; -- _buffer[3] = (byte) (len); -- } else { -- _buffer[1] = (byte) (0x7e); -- _buffer[2] = (byte) (len >> 8); -- _buffer[3] = (byte) (len); -- } -- -- _isPacket = false; -- _offset = 0; -- -- if (os == null) { -- } -- else if (len < 0x7e) { -- os.write(_buffer, 2, offset - 2); -- } -- else { -- os.write(_buffer, 0, offset); -- } -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 with preceeding length -- * -- * @param v the string to print. -- */ -- public void printLenString(String v) -- throws IOException -- { -- if (SIZE < _offset + 16) -- flushBuffer(); -- -- if (v == null) { -- _buffer[_offset++] = (byte) (0); -- _buffer[_offset++] = (byte) (0); -- } -- else { -- int len = v.length(); -- _buffer[_offset++] = (byte) (len >> 8); -- _buffer[_offset++] = (byte) (len); -- -- printString(v, 0, len); -- } -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v) -- throws IOException -- { -- printString(v, 0, v.length()); -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v, int strOffset, int length) -- throws IOException -- { -- int offset = _offset; -- byte []buffer = _buffer; -- -- for (int i = 0; i < length; i++) { -- if (SIZE <= offset + 16) { -- _offset = offset; -- flushBuffer(); -- offset = _offset; -- } -- -- char ch = v.charAt(i + strOffset); -- -- if (ch < 0x80) -- buffer[offset++] = (byte) (ch); -- else if (ch < 0x800) { -- buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); -- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -- } -- else { -- buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); -- buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); -- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -- } -- } -- -- _offset = offset; -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(char []v, int strOffset, int length) -- throws IOException -- { -- int offset = _offset; -- byte []buffer = _buffer; -- -- for (int i = 0; i < length; i++) { -- if (SIZE <= offset + 16) { -- _offset = offset; -- flushBuffer(); -- offset = _offset; -- } -- -- char ch = v[i + strOffset]; -- -- if (ch < 0x80) -- buffer[offset++] = (byte) (ch); -- else if (ch < 0x800) { -- buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); -- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -- } -- else { -- buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); -- buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); -- buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -- } -- } -- -- _offset = offset; -- } -- -- private final void flushIfFull() -- throws IOException -- { -- int offset = _offset; -- -- if (SIZE < offset + 32) { -- flushBuffer(); -- } -- } -- -- public final void flush() -- throws IOException -- { -- flushBuffer(); -- -- if (_os != null) -- _os.flush(); -- } -- -- public final void flushBuffer() -- throws IOException -- { -- int offset = _offset; -- -- OutputStream os = _os; -- -- if (! _isPacket && offset > 0) { -- _offset = 0; -- if (os != null) -- os.write(_buffer, 0, offset); -- } -- else if (_isPacket && offset > 4) { -- int len = offset - 4; -- -- _buffer[0] |= (byte) 0x80; -- _buffer[1] = (byte) (0x7e); -- _buffer[2] = (byte) (len >> 8); -- _buffer[3] = (byte) (len); -- _offset = 4; -- -- if (os != null) -- os.write(_buffer, 0, offset); -- -- _buffer[0] = (byte) 0x00; -- _buffer[1] = (byte) 0x56; -- _buffer[2] = (byte) 0x56; -- _buffer[3] = (byte) 0x56; -- } -- } -- -- @Override -- public void close() -- throws IOException -- { -- // hessian/3a8c -- flush(); -- -- OutputStream os = _os; -- _os = null; -- -- if (os != null) { -- if (_isCloseStreamOnClose) -- os.close(); -- } -- } -- -- public void free() -- { -- reset(); -- -- _os = null; -- _isCloseStreamOnClose = false; -- } -- -- /** -- * Resets the references for streaming. -- */ -- @Override -- public void resetReferences() -- { -- if (_refs != null) { -- _refs.clear(); -- _refCount = 0; -- } -- } -- -- /** -- * Resets all counters and references -- */ -- public void reset() -- { -- if (_refs != null) { -- _refs.clear(); -- _refCount = 0; -- } -- -- _classRefs.clear(); -- _typeRefs = null; -- _offset = 0; -- _isPacket = false; -- _isUnshared = false; -- } -- -- class BytesOutputStream extends OutputStream { -- private int _startOffset; -- -- BytesOutputStream() -- throws IOException -- { -- if (SIZE < _offset + 16) { -- Hessian2Output.this.flushBuffer(); -- } -- -- _startOffset = _offset; -- _offset += 3; // skip 'b' xNN xNN -- } -- -- @Override -- public void write(int ch) -- throws IOException -- { -- if (SIZE <= _offset) { -- int length = (_offset - _startOffset) - 3; -- -- _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; -- _buffer[_startOffset + 1] = (byte) (length >> 8); -- _buffer[_startOffset + 2] = (byte) (length); -- -- Hessian2Output.this.flushBuffer(); -- -- _startOffset = _offset; -- _offset += 3; -- } -- -- _buffer[_offset++] = (byte) ch; -- } -- -- @Override -- public void write(byte []buffer, int offset, int length) -- throws IOException -- { -- while (length > 0) { -- int sublen = SIZE - _offset; -- -- if (length < sublen) -- sublen = length; -- -- if (sublen > 0) { -- System.arraycopy(buffer, offset, _buffer, _offset, sublen); -- _offset += sublen; -- } -- -- length -= sublen; -- offset += sublen; -- -- if (SIZE <= _offset) { -- int chunkLength = (_offset - _startOffset) - 3; -- -- _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; -- _buffer[_startOffset + 1] = (byte) (chunkLength >> 8); -- _buffer[_startOffset + 2] = (byte) (chunkLength); -- -- Hessian2Output.this.flushBuffer(); -- -- _startOffset = _offset; -- _offset += 3; -- } -- } -- } -- -- @Override -- public void close() -- throws IOException -- { -- int startOffset = _startOffset; -- _startOffset = -1; -- -- if (startOffset < 0) -- return; -- -- int length = (_offset - startOffset) - 3; -- -- _buffer[startOffset] = (byte) 'B'; -- _buffer[startOffset + 1] = (byte) (length >> 8); -- _buffer[startOffset + 2] = (byte) (length); -- -- Hessian2Output.this.flushBuffer(); -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import com.caucho.hessian.util.IdentityIntMap; -+ -+import java.io.InputStream; -+import java.io.IOException; -+import java.io.OutputStream; -+import java.util.HashMap; -+ -+/** -+ * Output stream for Hessian 2 requests. -+ * -+ *

Since HessianOutput does not depend on any classes other than -+ * in the JDK, it can be extracted independently into a smaller package. -+ * -+ *

HessianOutput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * OutputStream os = ...; // from http connection
-+ * Hessian2Output out = new Hessian2Output(os);
-+ * String value;
-+ *
-+ * out.startCall("hello", 1); // start hello call
-+ * out.writeString("arg1");   // write a string argument
-+ * out.completeCall();        // complete the call
-+ * 
-+ */ -+public class Hessian2Output -+ extends AbstractHessianOutput -+ implements Hessian2Constants -+{ -+ // should match Resin buffer size for perf -+ public final static int SIZE = 8 * 1024; -+ -+ // the output stream/ -+ protected OutputStream _os; -+ -+ // map of references -+ private final IdentityIntMap _refs -+ = new IdentityIntMap(256); -+ -+ private int _refCount = 0; -+ -+ private boolean _isCloseStreamOnClose; -+ -+ // map of classes -+ private final IdentityIntMap _classRefs -+ = new IdentityIntMap(256); -+ -+ // map of types -+ private HashMap _typeRefs; -+ -+ private final byte []_buffer = new byte[SIZE]; -+ private int _offset; -+ -+ private boolean _isPacket; -+ -+ private boolean _isUnshared; -+ -+ /** -+ * Creates a new Hessian output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public Hessian2Output() -+ { -+ } -+ -+ /** -+ * Creates a new Hessian output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public Hessian2Output(OutputStream os) -+ { -+ init(os); -+ } -+ -+ @Override -+ public void init(OutputStream os) -+ { -+ reset(); -+ -+ _os = os; -+ } -+ -+ public void initPacket(OutputStream os) -+ { -+ resetReferences(); -+ -+ _os = os; -+ } -+ -+ public void setCloseStreamOnClose(boolean isClose) -+ { -+ _isCloseStreamOnClose = isClose; -+ } -+ -+ public boolean isCloseStreamOnClose() -+ { -+ return _isCloseStreamOnClose; -+ } -+ -+ /** -+ * Sets hessian to be "unshared", meaning it will not detect -+ * duplicate or circular references. -+ */ -+ @Override -+ public boolean setUnshared(boolean isUnshared) -+ { -+ boolean oldIsUnshared = _isUnshared; -+ -+ _isUnshared = isUnshared; -+ -+ return oldIsUnshared; -+ } -+ -+ /** -+ * Writes a complete method call. -+ */ -+ @Override -+ public void call(String method, Object []args) -+ throws IOException -+ { -+ writeVersion(); -+ -+ int length = args != null ? args.length : 0; -+ -+ startCall(method, length); -+ -+ for (int i = 0; i < length; i++) { -+ writeObject(args[i]); -+ } -+ -+ completeCall(); -+ -+ flush(); -+ } -+ -+ /** -+ * Starts the method call. Clients would use startCall -+ * instead of call if they wanted finer control over -+ * writing the arguments, or needed to write headers. -+ * -+ *
-+   * C
-+   * string # method name
-+   * int    # arg count
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ @Override -+ public void startCall(String method, int length) -+ throws IOException -+ { -+ int offset = _offset; -+ -+ if (SIZE < offset + 32) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ byte []buffer = _buffer; -+ -+ buffer[_offset++] = (byte) 'C'; -+ -+ writeString(method); -+ writeInt(length); -+ } -+ -+ /** -+ * Writes the call tag. This would be followed by the -+ * method and the arguments -+ * -+ *
-+   * C
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ @Override -+ public void startCall() -+ throws IOException -+ { -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) 'C'; -+ } -+ -+ /** -+ * Starts an envelope. -+ * -+ *
-+   * E major minor
-+   * m b16 b8 method-name
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void startEnvelope(String method) -+ throws IOException -+ { -+ int offset = _offset; -+ -+ if (SIZE < offset + 32) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ _buffer[_offset++] = (byte) 'E'; -+ -+ writeString(method); -+ } -+ -+ /** -+ * Completes an envelope. -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * Z
-+   * 
-+ */ -+ public void completeEnvelope() -+ throws IOException -+ { -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) 'Z'; -+ } -+ -+ /** -+ * Writes the method tag. -+ * -+ *
-+   * string
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void writeMethod(String method) -+ throws IOException -+ { -+ writeString(method); -+ } -+ -+ /** -+ * Completes. -+ * -+ *
-+   * z
-+   * 
-+ */ -+ @Override -+ public void completeCall() -+ throws IOException -+ { -+ /* -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) 'Z'; -+ */ -+ } -+ -+ /** -+ * Starts the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * R
-+   * 
-+ */ -+ @Override -+ public void startReply() -+ throws IOException -+ { -+ writeVersion(); -+ -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) 'R'; -+ } -+ -+ public void writeVersion() -+ throws IOException -+ { -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) 'H'; -+ _buffer[_offset++] = (byte) 2; -+ _buffer[_offset++] = (byte) 0; -+ } -+ -+ /** -+ * Completes reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ @Override -+ public void completeReply() -+ throws IOException -+ { -+ } -+ -+ /** -+ * Starts a packet -+ * -+ *

A message contains several objects encapsulated by a length

-+ * -+ *
-+   * p x02 x00
-+   * 
-+ */ -+ public void startMessage() -+ throws IOException -+ { -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) 'p'; -+ _buffer[_offset++] = (byte) 2; -+ _buffer[_offset++] = (byte) 0; -+ } -+ -+ /** -+ * Completes reading the message -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeMessage() -+ throws IOException -+ { -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) 'z'; -+ } -+ -+ /** -+ * Writes a fault. The fault will be written -+ * as a descriptive string followed by an object: -+ * -+ *
-+   * F map
-+   * 
-+ * -+ *
-+   * F H
-+   * \x04code
-+   * \x10the fault code
-+   *
-+   * \x07message
-+   * \x11the fault message
-+   *
-+   * \x06detail
-+   * M\xnnjavax.ejb.FinderException
-+   *     ...
-+   * Z
-+   * Z
-+   * 
-+ * -+ * @param code the fault code, a three digit -+ */ -+ public void writeFault(String code, String message, Object detail) -+ throws IOException -+ { -+ flushIfFull(); -+ -+ writeVersion(); -+ -+ _buffer[_offset++] = (byte) 'F'; -+ _buffer[_offset++] = (byte) 'H'; -+ -+ addRef(new Object(), _refCount++, false); -+ -+ writeString("code"); -+ writeString(code); -+ -+ writeString("message"); -+ writeString(message); -+ -+ if (detail != null) { -+ writeString("detail"); -+ writeObject(detail); -+ } -+ -+ flushIfFull(); -+ _buffer[_offset++] = (byte) 'Z'; -+ } -+ -+ /** -+ * Writes any object to the output stream. -+ */ -+ @Override -+ public void writeObject(Object object) -+ throws IOException -+ { -+ if (object == null) { -+ writeNull(); -+ return; -+ } -+ -+ Serializer serializer -+ = findSerializerFactory().getObjectSerializer(object.getClass()); -+ -+ serializer.writeObject(object, this); -+ } -+ -+ /** -+ * Writes the list header to the stream. List writers will call -+ * writeListBegin followed by the list contents and then -+ * call writeListEnd. -+ * -+ *
-+   * list ::= V type value* Z
-+   *      ::= v type int value*
-+   * 
-+ * -+ * @return true for variable lists, false for fixed lists -+ */ -+ public boolean writeListBegin(int length, String type) -+ throws IOException -+ { -+ flushIfFull(); -+ -+ if (length < 0) { -+ if (type != null) { -+ _buffer[_offset++] = (byte) BC_LIST_VARIABLE; -+ writeType(type); -+ } -+ else -+ _buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED; -+ -+ return true; -+ } -+ else if (length <= LIST_DIRECT_MAX) { -+ if (type != null) { -+ _buffer[_offset++] = (byte) (BC_LIST_DIRECT + length); -+ writeType(type); -+ } -+ else { -+ _buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length); -+ } -+ -+ return false; -+ } -+ else { -+ if (type != null) { -+ _buffer[_offset++] = (byte) BC_LIST_FIXED; -+ writeType(type); -+ } -+ else { -+ _buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED; -+ } -+ -+ writeInt(length); -+ -+ return false; -+ } -+ } -+ -+ /** -+ * Writes the tail of the list to the stream for a variable-length list. -+ */ -+ public void writeListEnd() -+ throws IOException -+ { -+ flushIfFull(); -+ -+ _buffer[_offset++] = (byte) BC_END; -+ } -+ -+ /** -+ * Writes the map header to the stream. Map writers will call -+ * writeMapBegin followed by the map contents and then -+ * call writeMapEnd. -+ * -+ *
-+   * map ::= M type ( )* Z
-+   *     ::= H ( )* Z
-+   * 
-+ */ -+ public void writeMapBegin(String type) -+ throws IOException -+ { -+ if (SIZE < _offset + 32) -+ flushBuffer(); -+ -+ if (type != null) { -+ _buffer[_offset++] = BC_MAP; -+ -+ writeType(type); -+ } -+ else -+ _buffer[_offset++] = BC_MAP_UNTYPED; -+ } -+ -+ /** -+ * Writes the tail of the map to the stream. -+ */ -+ public void writeMapEnd() -+ throws IOException -+ { -+ if (SIZE < _offset + 32) -+ flushBuffer(); -+ -+ _buffer[_offset++] = (byte) BC_END; -+ } -+ -+ /** -+ * Writes the object definition -+ * -+ *
-+   * C <string> <int> <string>*
-+   * 
-+ */ -+ @Override -+ public int writeObjectBegin(String type) -+ throws IOException -+ { -+ int newRef = _classRefs.size(); -+ int ref = _classRefs.put(type, newRef, false); -+ -+ if (newRef != ref) { -+ if (SIZE < _offset + 32) -+ flushBuffer(); -+ -+ if (ref <= OBJECT_DIRECT_MAX) { -+ _buffer[_offset++] = (byte) (BC_OBJECT_DIRECT + ref); -+ } -+ else { -+ _buffer[_offset++] = (byte) 'O'; -+ writeInt(ref); -+ } -+ -+ return ref; -+ } -+ else { -+ if (SIZE < _offset + 32) -+ flushBuffer(); -+ -+ _buffer[_offset++] = (byte) 'C'; -+ -+ writeString(type); -+ -+ return -1; -+ } -+ } -+ -+ /** -+ * Writes the tail of the class definition to the stream. -+ */ -+ @Override -+ public void writeClassFieldLength(int len) -+ throws IOException -+ { -+ writeInt(len); -+ } -+ -+ /** -+ * Writes the tail of the object definition to the stream. -+ */ -+ @Override -+ public void writeObjectEnd() -+ throws IOException -+ { -+ } -+ -+ /** -+ *
-+   * type ::= string
-+   *      ::= int
-+   * 
-+ */ -+ private void writeType(String type) -+ throws IOException -+ { -+ flushIfFull(); -+ -+ int len = type.length(); -+ if (len == 0) { -+ throw new IllegalArgumentException("empty type is not allowed"); -+ } -+ -+ if (_typeRefs == null) -+ _typeRefs = new HashMap(); -+ -+ Integer typeRefV = (Integer) _typeRefs.get(type); -+ -+ if (typeRefV != null) { -+ int typeRef = typeRefV.intValue(); -+ -+ writeInt(typeRef); -+ } -+ else { -+ _typeRefs.put(type, Integer.valueOf(_typeRefs.size())); -+ -+ writeString(type); -+ } -+ } -+ -+ /** -+ * Writes a boolean value to the stream. The boolean will be written -+ * with the following syntax: -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ * -+ * @param value the boolean value to write. -+ */ -+ @Override -+ public void writeBoolean(boolean value) -+ throws IOException -+ { -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ if (value) -+ _buffer[_offset++] = (byte) 'T'; -+ else -+ _buffer[_offset++] = (byte) 'F'; -+ } -+ -+ /** -+ * Writes an integer value to the stream. The integer will be written -+ * with the following syntax: -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ @Override -+ public void writeInt(int value) -+ throws IOException -+ { -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ if (SIZE <= offset + 16) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ if (INT_DIRECT_MIN <= value && value <= INT_DIRECT_MAX) -+ buffer[offset++] = (byte) (value + BC_INT_ZERO); -+ else if (INT_BYTE_MIN <= value && value <= INT_BYTE_MAX) { -+ buffer[offset++] = (byte) (BC_INT_BYTE_ZERO + (value >> 8)); -+ buffer[offset++] = (byte) (value); -+ } -+ else if (INT_SHORT_MIN <= value && value <= INT_SHORT_MAX) { -+ buffer[offset++] = (byte) (BC_INT_SHORT_ZERO + (value >> 16)); -+ buffer[offset++] = (byte) (value >> 8); -+ buffer[offset++] = (byte) (value); -+ } -+ else { -+ buffer[offset++] = (byte) ('I'); -+ buffer[offset++] = (byte) (value >> 24); -+ buffer[offset++] = (byte) (value >> 16); -+ buffer[offset++] = (byte) (value >> 8); -+ buffer[offset++] = (byte) (value); -+ } -+ -+ _offset = offset; -+ } -+ -+ /** -+ * Writes a long value to the stream. The long will be written -+ * with the following syntax: -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the long value to write. -+ */ -+ public void writeLong(long value) -+ throws IOException -+ { -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ if (SIZE <= offset + 16) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ if (LONG_DIRECT_MIN <= value && value <= LONG_DIRECT_MAX) { -+ buffer[offset++] = (byte) (value + BC_LONG_ZERO); -+ } -+ else if (LONG_BYTE_MIN <= value && value <= LONG_BYTE_MAX) { -+ buffer[offset++] = (byte) (BC_LONG_BYTE_ZERO + (value >> 8)); -+ buffer[offset++] = (byte) (value); -+ } -+ else if (LONG_SHORT_MIN <= value && value <= LONG_SHORT_MAX) { -+ buffer[offset++] = (byte) (BC_LONG_SHORT_ZERO + (value >> 16)); -+ buffer[offset++] = (byte) (value >> 8); -+ buffer[offset++] = (byte) (value); -+ } -+ else if (-0x80000000L <= value && value <= 0x7fffffffL) { -+ buffer[offset + 0] = (byte) BC_LONG_INT; -+ buffer[offset + 1] = (byte) (value >> 24); -+ buffer[offset + 2] = (byte) (value >> 16); -+ buffer[offset + 3] = (byte) (value >> 8); -+ buffer[offset + 4] = (byte) (value); -+ -+ offset += 5; -+ } -+ else { -+ buffer[offset + 0] = (byte) 'L'; -+ buffer[offset + 1] = (byte) (value >> 56); -+ buffer[offset + 2] = (byte) (value >> 48); -+ buffer[offset + 3] = (byte) (value >> 40); -+ buffer[offset + 4] = (byte) (value >> 32); -+ buffer[offset + 5] = (byte) (value >> 24); -+ buffer[offset + 6] = (byte) (value >> 16); -+ buffer[offset + 7] = (byte) (value >> 8); -+ buffer[offset + 8] = (byte) (value); -+ -+ offset += 9; -+ } -+ -+ _offset = offset; -+ } -+ -+ /** -+ * Writes a double value to the stream. The double will be written -+ * with the following syntax: -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the double value to write. -+ */ -+ public void writeDouble(double value) -+ throws IOException -+ { -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ if (SIZE <= offset + 16) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ int intValue = (int) value; -+ -+ if (intValue == value) { -+ if (intValue == 0) { -+ buffer[offset++] = (byte) BC_DOUBLE_ZERO; -+ -+ _offset = offset; -+ -+ return; -+ } -+ else if (intValue == 1) { -+ buffer[offset++] = (byte) BC_DOUBLE_ONE; -+ -+ _offset = offset; -+ -+ return; -+ } -+ else if (-0x80 <= intValue && intValue < 0x80) { -+ buffer[offset++] = (byte) BC_DOUBLE_BYTE; -+ buffer[offset++] = (byte) intValue; -+ -+ _offset = offset; -+ -+ return; -+ } -+ else if (-0x8000 <= intValue && intValue < 0x8000) { -+ buffer[offset + 0] = (byte) BC_DOUBLE_SHORT; -+ buffer[offset + 1] = (byte) (intValue >> 8); -+ buffer[offset + 2] = (byte) intValue; -+ -+ _offset = offset + 3; -+ -+ return; -+ } -+ } -+ -+ int mills = (int) (value * 1000); -+ -+ if (0.001 * mills == value) { -+ buffer[offset + 0] = (byte) (BC_DOUBLE_MILL); -+ buffer[offset + 1] = (byte) (mills >> 24); -+ buffer[offset + 2] = (byte) (mills >> 16); -+ buffer[offset + 3] = (byte) (mills >> 8); -+ buffer[offset + 4] = (byte) (mills); -+ -+ _offset = offset + 5; -+ -+ return; -+ } -+ -+ long bits = Double.doubleToLongBits(value); -+ -+ buffer[offset + 0] = (byte) 'D'; -+ buffer[offset + 1] = (byte) (bits >> 56); -+ buffer[offset + 2] = (byte) (bits >> 48); -+ buffer[offset + 3] = (byte) (bits >> 40); -+ buffer[offset + 4] = (byte) (bits >> 32); -+ buffer[offset + 5] = (byte) (bits >> 24); -+ buffer[offset + 6] = (byte) (bits >> 16); -+ buffer[offset + 7] = (byte) (bits >> 8); -+ buffer[offset + 8] = (byte) (bits); -+ -+ _offset = offset + 9; -+ } -+ -+ /** -+ * Writes a date to the stream. -+ * -+ *
-+   * date ::= d   b7 b6 b5 b4 b3 b2 b1 b0
-+   *      ::= x65 b3 b2 b1 b0
-+   * 
-+ * -+ * @param time the date in milliseconds from the epoch in UTC -+ */ -+ public void writeUTCDate(long time) -+ throws IOException -+ { -+ if (SIZE < _offset + 32) -+ flushBuffer(); -+ -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ if (time % 60000L == 0) { -+ // compact date ::= x65 b3 b2 b1 b0 -+ -+ long minutes = time / 60000L; -+ -+ if ((minutes >> 31) == 0 || (minutes >> 31) == -1) { -+ buffer[offset++] = (byte) BC_DATE_MINUTE; -+ buffer[offset++] = ((byte) (minutes >> 24)); -+ buffer[offset++] = ((byte) (minutes >> 16)); -+ buffer[offset++] = ((byte) (minutes >> 8)); -+ buffer[offset++] = ((byte) (minutes >> 0)); -+ -+ _offset = offset; -+ return; -+ } -+ } -+ -+ buffer[offset++] = (byte) BC_DATE; -+ buffer[offset++] = ((byte) (time >> 56)); -+ buffer[offset++] = ((byte) (time >> 48)); -+ buffer[offset++] = ((byte) (time >> 40)); -+ buffer[offset++] = ((byte) (time >> 32)); -+ buffer[offset++] = ((byte) (time >> 24)); -+ buffer[offset++] = ((byte) (time >> 16)); -+ buffer[offset++] = ((byte) (time >> 8)); -+ buffer[offset++] = ((byte) (time)); -+ -+ _offset = offset; -+ } -+ -+ /** -+ * Writes a null value to the stream. -+ * The null will be written with the following syntax -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeNull() -+ throws IOException -+ { -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ if (SIZE <= offset + 16) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ buffer[offset++] = 'N'; -+ -+ _offset = offset; -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(String value) -+ throws IOException -+ { -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ if (SIZE <= offset + 16) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ if (value == null) { -+ buffer[offset++] = (byte) 'N'; -+ -+ _offset = offset; -+ } -+ else { -+ int length = value.length(); -+ int strOffset = 0; -+ -+ while (length > 0x8000) { -+ int sublen = 0x8000; -+ -+ offset = _offset; -+ -+ if (SIZE <= offset + 16) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ // chunk can't end in high surrogate -+ char tail = value.charAt(strOffset + sublen - 1); -+ -+ if (0xd800 <= tail && tail <= 0xdbff) -+ sublen--; -+ -+ buffer[offset + 0] = (byte) BC_STRING_CHUNK; -+ buffer[offset + 1] = (byte) (sublen >> 8); -+ buffer[offset + 2] = (byte) (sublen); -+ -+ _offset = offset + 3; -+ -+ printString(value, strOffset, sublen); -+ -+ length -= sublen; -+ strOffset += sublen; -+ } -+ -+ offset = _offset; -+ -+ if (SIZE <= offset + 16) { -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ if (length <= STRING_DIRECT_MAX) { -+ buffer[offset++] = (byte) (BC_STRING_DIRECT + length); -+ } -+ else if (length <= STRING_SHORT_MAX) { -+ buffer[offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); -+ buffer[offset++] = (byte) (length); -+ } -+ else { -+ buffer[offset++] = (byte) ('S'); -+ buffer[offset++] = (byte) (length >> 8); -+ buffer[offset++] = (byte) (length); -+ } -+ -+ _offset = offset; -+ -+ printString(value, strOffset, length); -+ } -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(char []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ _buffer[_offset++] = (byte) ('N'); -+ } -+ else { -+ while (length > 0x8000) { -+ int sublen = 0x8000; -+ -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ // chunk can't end in high surrogate -+ char tail = buffer[offset + sublen - 1]; -+ -+ if (0xd800 <= tail && tail <= 0xdbff) -+ sublen--; -+ -+ _buffer[_offset++] = (byte) BC_STRING_CHUNK; -+ _buffer[_offset++] = (byte) (sublen >> 8); -+ _buffer[_offset++] = (byte) (sublen); -+ -+ printString(buffer, offset, sublen); -+ -+ length -= sublen; -+ offset += sublen; -+ } -+ -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ if (length <= STRING_DIRECT_MAX) { -+ _buffer[_offset++] = (byte) (BC_STRING_DIRECT + length); -+ } -+ else if (length <= STRING_SHORT_MAX) { -+ _buffer[_offset++] = (byte) (BC_STRING_SHORT + (length >> 8)); -+ _buffer[_offset++] = (byte) length; -+ } -+ else { -+ _buffer[_offset++] = (byte) ('S'); -+ _buffer[_offset++] = (byte) (length >> 8); -+ _buffer[_offset++] = (byte) (length); -+ } -+ -+ printString(buffer, offset, length); -+ } -+ } -+ -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer) -+ throws IOException -+ { -+ if (buffer == null) { -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ _buffer[_offset++] = 'N'; -+ } -+ else -+ writeBytes(buffer, 0, buffer.length); -+ } -+ -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ _buffer[_offset++] = (byte) 'N'; -+ } -+ else { -+ while (SIZE - _offset - 3 < length) { -+ int sublen = SIZE - _offset - 3; -+ -+ if (sublen < 16) { -+ flushBuffer(); -+ -+ sublen = SIZE - _offset - 3; -+ -+ if (length < sublen) -+ sublen = length; -+ } -+ -+ _buffer[_offset++] = (byte) BC_BINARY_CHUNK; -+ _buffer[_offset++] = (byte) (sublen >> 8); -+ _buffer[_offset++] = (byte) sublen; -+ -+ System.arraycopy(buffer, offset, _buffer, _offset, sublen); -+ _offset += sublen; -+ -+ length -= sublen; -+ offset += sublen; -+ -+ flushBuffer(); -+ } -+ -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ if (length <= BINARY_DIRECT_MAX) { -+ _buffer[_offset++] = (byte) (BC_BINARY_DIRECT + length); -+ } -+ else if (length <= BINARY_SHORT_MAX) { -+ _buffer[_offset++] = (byte) (BC_BINARY_SHORT + (length >> 8)); -+ _buffer[_offset++] = (byte) (length); -+ } -+ else { -+ _buffer[_offset++] = (byte) 'B'; -+ _buffer[_offset++] = (byte) (length >> 8); -+ _buffer[_offset++] = (byte) (length); -+ } -+ -+ System.arraycopy(buffer, offset, _buffer, _offset, length); -+ -+ _offset += length; -+ } -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * 
-+ */ -+ public void writeByteBufferStart() -+ throws IOException -+ { -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ */ -+ public void writeByteBufferPart(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ while (length > 0) { -+ flushIfFull(); -+ -+ int sublen = _buffer.length - _offset; -+ -+ if (length < sublen) -+ sublen = length; -+ -+ _buffer[_offset++] = BC_BINARY_CHUNK; -+ _buffer[_offset++] = (byte) (sublen >> 8); -+ _buffer[_offset++] = (byte) sublen; -+ -+ System.arraycopy(buffer, offset, _buffer, _offset, sublen); -+ -+ _offset += sublen; -+ length -= sublen; -+ offset += sublen; -+ } -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ */ -+ public void writeByteBufferEnd(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ writeBytes(buffer, offset, length); -+ } -+ -+ /** -+ * Returns an output stream to write binary data. -+ */ -+ public OutputStream getBytesOutputStream() -+ throws IOException -+ { -+ return new BytesOutputStream(); -+ } -+ -+ /** -+ * Writes a full output stream. -+ */ -+ @Override -+ public void writeByteStream(InputStream is) -+ throws IOException -+ { -+ while (true) { -+ int len = SIZE - _offset - 3; -+ -+ if (len < 16) { -+ flushBuffer(); -+ len = SIZE - _offset - 3; -+ } -+ -+ len = is.read(_buffer, _offset + 3, len); -+ -+ if (len <= 0) { -+ _buffer[_offset++] = BC_BINARY_DIRECT; -+ return; -+ } -+ -+ _buffer[_offset + 0] = (byte) BC_BINARY_CHUNK; -+ _buffer[_offset + 1] = (byte) (len >> 8); -+ _buffer[_offset + 2] = (byte) (len); -+ -+ _offset += len + 3; -+ } -+ } -+ -+ /** -+ * Writes a reference. -+ * -+ *
-+   * x51 <int>
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ @Override -+ protected void writeRef(int value) -+ throws IOException -+ { -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ _buffer[_offset++] = (byte) BC_REF; -+ -+ writeInt(value); -+ } -+ -+ /** -+ * If the object has already been written, just write its ref. -+ * -+ * @return true if we're writing a ref. -+ */ -+ @Override -+ public boolean addRef(Object object) -+ throws IOException -+ { -+ if (_isUnshared) { -+ _refCount++; -+ return false; -+ } -+ -+ int newRef = _refCount; -+ -+ int ref = addRef(object, newRef, false); -+ -+ if (ref != newRef) { -+ writeRef(ref); -+ -+ return true; -+ } -+ else { -+ _refCount++; -+ -+ return false; -+ } -+ } -+ -+ @Override -+ public int getRef(Object obj) -+ { -+ if (_isUnshared) -+ return -1; -+ -+ return _refs.get(obj); -+ } -+ -+ /** -+ * Removes a reference. -+ */ -+ @Override -+ public boolean removeRef(Object obj) -+ throws IOException -+ { -+ if (_isUnshared) { -+ return false; -+ } -+ else if (_refs != null) { -+ _refs.remove(obj); -+ -+ return true; -+ } -+ else -+ return false; -+ } -+ -+ /** -+ * Replaces a reference from one object to another. -+ */ -+ @Override -+ public boolean replaceRef(Object oldRef, Object newRef) -+ throws IOException -+ { -+ if (_isUnshared) { -+ return false; -+ } -+ -+ int value = _refs.get(oldRef); -+ -+ if (value >= 0) { -+ addRef(newRef, value, true); -+ -+ _refs.remove(oldRef); -+ -+ return true; -+ } -+ else -+ return false; -+ } -+ -+ private int addRef(Object value, int newRef, boolean isReplace) -+ { -+ int prevRef = _refs.put(value, newRef, isReplace); -+ -+ return prevRef; -+ } -+ -+ /** -+ * Starts the streaming message -+ * -+ *

A streaming message starts with 'P'

-+ * -+ *
-+   * P x02 x00
-+   * 
-+ */ -+ public void writeStreamingObject(Object obj) -+ throws IOException -+ { -+ startPacket(); -+ -+ writeObject(obj); -+ -+ endPacket(); -+ } -+ -+ /** -+ * Starts a streaming packet -+ * -+ *

A streaming contains a set of chunks, ending with a zero chunk. -+ * Each chunk is a length followed by data where the length is -+ * encoded by (b1xxxxxxxx)* b0xxxxxxxx

-+ */ -+ public void startPacket() -+ throws IOException -+ { -+ if (_refs != null) { -+ _refs.clear(); -+ _refCount = 0; -+ } -+ -+ flushBuffer(); -+ -+ _isPacket = true; -+ _offset = 4; -+ _buffer[0] = (byte) 0x05; // 0x05 = binary -+ _buffer[1] = (byte) 0x55; -+ _buffer[2] = (byte) 0x55; -+ _buffer[3] = (byte) 0x55; -+ } -+ -+ public void endPacket() -+ throws IOException -+ { -+ int offset = _offset; -+ -+ OutputStream os = _os; -+ -+ if (os == null) { -+ _offset = 0; -+ return; -+ } -+ -+ int len = offset - 4; -+ -+ if (len < 0x7e) { -+ _buffer[2] = _buffer[0]; -+ _buffer[3] = (byte) (len); -+ } else { -+ _buffer[1] = (byte) (0x7e); -+ _buffer[2] = (byte) (len >> 8); -+ _buffer[3] = (byte) (len); -+ } -+ -+ _isPacket = false; -+ _offset = 0; -+ -+ if (os == null) { -+ } -+ else if (len < 0x7e) { -+ os.write(_buffer, 2, offset - 2); -+ } -+ else { -+ os.write(_buffer, 0, offset); -+ } -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 with preceeding length -+ * -+ * @param v the string to print. -+ */ -+ public void printLenString(String v) -+ throws IOException -+ { -+ if (SIZE < _offset + 16) -+ flushBuffer(); -+ -+ if (v == null) { -+ _buffer[_offset++] = (byte) (0); -+ _buffer[_offset++] = (byte) (0); -+ } -+ else { -+ int len = v.length(); -+ _buffer[_offset++] = (byte) (len >> 8); -+ _buffer[_offset++] = (byte) (len); -+ -+ printString(v, 0, len); -+ } -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v) -+ throws IOException -+ { -+ printString(v, 0, v.length()); -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v, int strOffset, int length) -+ throws IOException -+ { -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ for (int i = 0; i < length; i++) { -+ if (SIZE <= offset + 16) { -+ _offset = offset; -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ char ch = v.charAt(i + strOffset); -+ -+ if (ch < 0x80) -+ buffer[offset++] = (byte) (ch); -+ else if (ch < 0x800) { -+ buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); -+ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -+ } -+ else { -+ buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); -+ buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); -+ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -+ } -+ } -+ -+ _offset = offset; -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(char []v, int strOffset, int length) -+ throws IOException -+ { -+ int offset = _offset; -+ byte []buffer = _buffer; -+ -+ for (int i = 0; i < length; i++) { -+ if (SIZE <= offset + 16) { -+ _offset = offset; -+ flushBuffer(); -+ offset = _offset; -+ } -+ -+ char ch = v[i + strOffset]; -+ -+ if (ch < 0x80) -+ buffer[offset++] = (byte) (ch); -+ else if (ch < 0x800) { -+ buffer[offset++] = (byte) (0xc0 + ((ch >> 6) & 0x1f)); -+ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -+ } -+ else { -+ buffer[offset++] = (byte) (0xe0 + ((ch >> 12) & 0xf)); -+ buffer[offset++] = (byte) (0x80 + ((ch >> 6) & 0x3f)); -+ buffer[offset++] = (byte) (0x80 + (ch & 0x3f)); -+ } -+ } -+ -+ _offset = offset; -+ } -+ -+ private final void flushIfFull() -+ throws IOException -+ { -+ int offset = _offset; -+ -+ if (SIZE < offset + 32) { -+ flushBuffer(); -+ } -+ } -+ -+ public final void flush() -+ throws IOException -+ { -+ flushBuffer(); -+ -+ if (_os != null) -+ _os.flush(); -+ } -+ -+ public final void flushBuffer() -+ throws IOException -+ { -+ int offset = _offset; -+ -+ OutputStream os = _os; -+ -+ if (! _isPacket && offset > 0) { -+ _offset = 0; -+ if (os != null) -+ os.write(_buffer, 0, offset); -+ } -+ else if (_isPacket && offset > 4) { -+ int len = offset - 4; -+ -+ _buffer[0] |= (byte) 0x80; -+ _buffer[1] = (byte) (0x7e); -+ _buffer[2] = (byte) (len >> 8); -+ _buffer[3] = (byte) (len); -+ _offset = 4; -+ -+ if (os != null) -+ os.write(_buffer, 0, offset); -+ -+ _buffer[0] = (byte) 0x00; -+ _buffer[1] = (byte) 0x56; -+ _buffer[2] = (byte) 0x56; -+ _buffer[3] = (byte) 0x56; -+ } -+ } -+ -+ @Override -+ public void close() -+ throws IOException -+ { -+ // hessian/3a8c -+ flush(); -+ -+ OutputStream os = _os; -+ _os = null; -+ -+ if (os != null) { -+ if (_isCloseStreamOnClose) -+ os.close(); -+ } -+ } -+ -+ public void free() -+ { -+ reset(); -+ -+ _os = null; -+ _isCloseStreamOnClose = false; -+ } -+ -+ /** -+ * Resets the references for streaming. -+ */ -+ @Override -+ public void resetReferences() -+ { -+ if (_refs != null) { -+ _refs.clear(); -+ _refCount = 0; -+ } -+ } -+ -+ /** -+ * Resets all counters and references -+ */ -+ public void reset() -+ { -+ if (_refs != null) { -+ _refs.clear(); -+ _refCount = 0; -+ } -+ -+ _classRefs.clear(); -+ _typeRefs = null; -+ _offset = 0; -+ _isPacket = false; -+ _isUnshared = false; -+ } -+ -+ class BytesOutputStream extends OutputStream { -+ private int _startOffset; -+ -+ BytesOutputStream() -+ throws IOException -+ { -+ if (SIZE < _offset + 16) { -+ Hessian2Output.this.flushBuffer(); -+ } -+ -+ _startOffset = _offset; -+ _offset += 3; // skip 'b' xNN xNN -+ } -+ -+ @Override -+ public void write(int ch) -+ throws IOException -+ { -+ if (SIZE <= _offset) { -+ int length = (_offset - _startOffset) - 3; -+ -+ _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; -+ _buffer[_startOffset + 1] = (byte) (length >> 8); -+ _buffer[_startOffset + 2] = (byte) (length); -+ -+ Hessian2Output.this.flushBuffer(); -+ -+ _startOffset = _offset; -+ _offset += 3; -+ } -+ -+ _buffer[_offset++] = (byte) ch; -+ } -+ -+ @Override -+ public void write(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ while (length > 0) { -+ int sublen = SIZE - _offset; -+ -+ if (length < sublen) -+ sublen = length; -+ -+ if (sublen > 0) { -+ System.arraycopy(buffer, offset, _buffer, _offset, sublen); -+ _offset += sublen; -+ } -+ -+ length -= sublen; -+ offset += sublen; -+ -+ if (SIZE <= _offset) { -+ int chunkLength = (_offset - _startOffset) - 3; -+ -+ _buffer[_startOffset] = (byte) BC_BINARY_CHUNK; -+ _buffer[_startOffset + 1] = (byte) (chunkLength >> 8); -+ _buffer[_startOffset + 2] = (byte) (chunkLength); -+ -+ Hessian2Output.this.flushBuffer(); -+ -+ _startOffset = _offset; -+ _offset += 3; -+ } -+ } -+ } -+ -+ @Override -+ public void close() -+ throws IOException -+ { -+ int startOffset = _startOffset; -+ _startOffset = -1; -+ -+ if (startOffset < 0) -+ return; -+ -+ int length = (_offset - startOffset) - 3; -+ -+ _buffer[startOffset] = (byte) 'B'; -+ _buffer[startOffset + 1] = (byte) (length >> 8); -+ _buffer[startOffset + 2] = (byte) (length); -+ -+ Hessian2Output.this.flushBuffer(); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingInput.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingInput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,288 +1,288 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; -- --import java.util.logging.*; -- --/** -- * Input stream for Hessian 2 streaming requests using WebSocket. -- * -- * For best performance, use HessianFactory: -- * -- *
-- * HessianFactory factory = new HessianFactory();
-- * Hessian2StreamingInput hIn = factory.createHessian2StreamingInput(is);
-- * 
-- */ --public class Hessian2StreamingInput --{ -- private static final Logger log -- = Logger.getLogger(Hessian2StreamingInput.class.getName()); -- -- private StreamingInputStream _is; -- private Hessian2Input _in; -- -- /** -- * Creates a new Hessian input stream, initialized with an -- * underlying input stream. -- * -- * @param is the underlying output stream. -- */ -- public Hessian2StreamingInput(InputStream is) -- { -- _is = new StreamingInputStream(is); -- _in = new Hessian2Input(_is); -- } -- -- public void setSerializerFactory(SerializerFactory factory) -- { -- _in.setSerializerFactory(factory); -- } -- -- public boolean isDataAvailable() -- { -- StreamingInputStream is = _is; -- -- return is != null && is.isDataAvailable(); -- } -- -- public Hessian2Input startPacket() -- throws IOException -- { -- if (_is.startPacket()) { -- _in.resetReferences(); -- _in.resetBuffer(); // XXX: -- return _in; -- } -- else -- return null; -- } -- -- public void endPacket() -- throws IOException -- { -- _is.endPacket(); -- _in.resetBuffer(); // XXX: -- } -- -- public Hessian2Input getHessianInput() -- { -- return _in; -- } -- -- /** -- * Read the next object -- */ -- public Object readObject() -- throws IOException -- { -- _is.startPacket(); -- -- Object obj = _in.readStreamingObject(); -- -- _is.endPacket(); -- -- return obj; -- } -- -- /** -- * Close the output. -- */ -- public void close() -- throws IOException -- { -- _in.close(); -- } -- -- static class StreamingInputStream extends InputStream { -- private InputStream _is; -- -- private int _length; -- private boolean _isPacketEnd; -- -- StreamingInputStream(InputStream is) -- { -- _is = is; -- } -- -- public boolean isDataAvailable() -- { -- try { -- return _is != null && _is.available() > 0; -- } catch (IOException e) { -- log.log(Level.FINER, e.toString(), e); -- -- return true; -- } -- } -- -- public boolean startPacket() -- throws IOException -- { -- // skip zero-length packets -- do { -- _isPacketEnd = false; -- } while ((_length = readChunkLength(_is)) == 0); -- -- return _length > 0; -- } -- -- public void endPacket() -- throws IOException -- { -- while (! _isPacketEnd) { -- if (_length <= 0) -- _length = readChunkLength(_is); -- -- if (_length > 0) { -- _is.skip(_length); -- _length = 0; -- } -- } -- -- if (_length > 0) { -- _is.skip(_length); -- _length = 0; -- } -- } -- -- public int read() -- throws IOException -- { -- InputStream is = _is; -- -- if (_length == 0) { -- if (_isPacketEnd) -- return -1; -- -- _length = readChunkLength(is); -- -- if (_length <= 0) -- return -1; -- } -- -- _length--; -- -- return is.read(); -- } -- -- @Override -- public int read(byte []buffer, int offset, int length) -- throws IOException -- { -- InputStream is = _is; -- -- if (_length <= 0) { -- if (_isPacketEnd) -- return -1; -- -- _length = readChunkLength(is); -- -- if (_length <= 0) -- return -1; -- } -- -- int sublen = _length; -- if (length < sublen) -- sublen = length; -- -- sublen = is.read(buffer, offset, sublen); -- -- if (sublen < 0) -- return -1; -- -- _length -= sublen; -- -- return sublen; -- } -- -- private int readChunkLength(InputStream is) -- throws IOException -- { -- if (_isPacketEnd) -- return -1; -- -- int length = 0; -- -- int code = is.read(); -- -- if (code < 0) { -- _isPacketEnd = true; -- return -1; -- } -- -- _isPacketEnd = (code & 0x80) == 0; -- -- int len = is.read() & 0x7f; -- -- if (len < 0x7e) { -- length = len; -- } -- else if (len == 0x7e) { -- length = (((is.read() & 0xff) << 8) -- + (is.read() & 0xff)); -- } -- else { -- length = (((is.read() & 0xff) << 56) -- + ((is.read() & 0xff) << 48) -- + ((is.read() & 0xff) << 40) -- + ((is.read() & 0xff) << 32) -- + ((is.read() & 0xff) << 24) -- + ((is.read() & 0xff) << 16) -- + ((is.read() & 0xff) << 8) -- + ((is.read() & 0xff))); -- } -- -- return length; -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+ -+import java.util.logging.*; -+ -+/** -+ * Input stream for Hessian 2 streaming requests using WebSocket. -+ * -+ * For best performance, use HessianFactory: -+ * -+ *
-+ * HessianFactory factory = new HessianFactory();
-+ * Hessian2StreamingInput hIn = factory.createHessian2StreamingInput(is);
-+ * 
-+ */ -+public class Hessian2StreamingInput -+{ -+ private static final Logger log -+ = Logger.getLogger(Hessian2StreamingInput.class.getName()); -+ -+ private StreamingInputStream _is; -+ private Hessian2Input _in; -+ -+ /** -+ * Creates a new Hessian input stream, initialized with an -+ * underlying input stream. -+ * -+ * @param is the underlying output stream. -+ */ -+ public Hessian2StreamingInput(InputStream is) -+ { -+ _is = new StreamingInputStream(is); -+ _in = new Hessian2Input(_is); -+ } -+ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _in.setSerializerFactory(factory); -+ } -+ -+ public boolean isDataAvailable() -+ { -+ StreamingInputStream is = _is; -+ -+ return is != null && is.isDataAvailable(); -+ } -+ -+ public Hessian2Input startPacket() -+ throws IOException -+ { -+ if (_is.startPacket()) { -+ _in.resetReferences(); -+ _in.resetBuffer(); // XXX: -+ return _in; -+ } -+ else -+ return null; -+ } -+ -+ public void endPacket() -+ throws IOException -+ { -+ _is.endPacket(); -+ _in.resetBuffer(); // XXX: -+ } -+ -+ public Hessian2Input getHessianInput() -+ { -+ return _in; -+ } -+ -+ /** -+ * Read the next object -+ */ -+ public Object readObject() -+ throws IOException -+ { -+ _is.startPacket(); -+ -+ Object obj = _in.readStreamingObject(); -+ -+ _is.endPacket(); -+ -+ return obj; -+ } -+ -+ /** -+ * Close the output. -+ */ -+ public void close() -+ throws IOException -+ { -+ _in.close(); -+ } -+ -+ static class StreamingInputStream extends InputStream { -+ private InputStream _is; -+ -+ private int _length; -+ private boolean _isPacketEnd; -+ -+ StreamingInputStream(InputStream is) -+ { -+ _is = is; -+ } -+ -+ public boolean isDataAvailable() -+ { -+ try { -+ return _is != null && _is.available() > 0; -+ } catch (IOException e) { -+ log.log(Level.FINER, e.toString(), e); -+ -+ return true; -+ } -+ } -+ -+ public boolean startPacket() -+ throws IOException -+ { -+ // skip zero-length packets -+ do { -+ _isPacketEnd = false; -+ } while ((_length = readChunkLength(_is)) == 0); -+ -+ return _length > 0; -+ } -+ -+ public void endPacket() -+ throws IOException -+ { -+ while (! _isPacketEnd) { -+ if (_length <= 0) -+ _length = readChunkLength(_is); -+ -+ if (_length > 0) { -+ _is.skip(_length); -+ _length = 0; -+ } -+ } -+ -+ if (_length > 0) { -+ _is.skip(_length); -+ _length = 0; -+ } -+ } -+ -+ public int read() -+ throws IOException -+ { -+ InputStream is = _is; -+ -+ if (_length == 0) { -+ if (_isPacketEnd) -+ return -1; -+ -+ _length = readChunkLength(is); -+ -+ if (_length <= 0) -+ return -1; -+ } -+ -+ _length--; -+ -+ return is.read(); -+ } -+ -+ @Override -+ public int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ InputStream is = _is; -+ -+ if (_length <= 0) { -+ if (_isPacketEnd) -+ return -1; -+ -+ _length = readChunkLength(is); -+ -+ if (_length <= 0) -+ return -1; -+ } -+ -+ int sublen = _length; -+ if (length < sublen) -+ sublen = length; -+ -+ sublen = is.read(buffer, offset, sublen); -+ -+ if (sublen < 0) -+ return -1; -+ -+ _length -= sublen; -+ -+ return sublen; -+ } -+ -+ private int readChunkLength(InputStream is) -+ throws IOException -+ { -+ if (_isPacketEnd) -+ return -1; -+ -+ int length = 0; -+ -+ int code = is.read(); -+ -+ if (code < 0) { -+ _isPacketEnd = true; -+ return -1; -+ } -+ -+ _isPacketEnd = (code & 0x80) == 0; -+ -+ int len = is.read() & 0x7f; -+ -+ if (len < 0x7e) { -+ length = len; -+ } -+ else if (len == 0x7e) { -+ length = (((is.read() & 0xff) << 8) -+ + (is.read() & 0xff)); -+ } -+ else { -+ length = (((is.read() & 0xff) << 56) -+ + ((is.read() & 0xff) << 48) -+ + ((is.read() & 0xff) << 40) -+ + ((is.read() & 0xff) << 32) -+ + ((is.read() & 0xff) << 24) -+ + ((is.read() & 0xff) << 16) -+ + ((is.read() & 0xff) << 8) -+ + ((is.read() & 0xff))); -+ } -+ -+ return length; -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingOutput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Hessian2StreamingOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Hessian2StreamingOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,118 +1,118 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.OutputStream; -- --/** -- * Output stream for Hessian 2 streaming requests. -- */ --public class Hessian2StreamingOutput --{ -- private Hessian2Output _out; -- -- /** -- * Creates a new Hessian output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public Hessian2StreamingOutput(OutputStream os) -- { -- _out = new Hessian2Output(os); -- } -- -- public Hessian2StreamingOutput(Hessian2Output out) -- { -- _out = out; -- } -- -- public Hessian2Output getHessian2Output() -- { -- return _out; -- } -- -- public void setCloseStreamOnClose(boolean isClose) -- { -- _out.setCloseStreamOnClose(isClose); -- } -- -- public boolean isCloseStreamOnClose() -- { -- return _out.isCloseStreamOnClose(); -- } -- -- /** -- * Writes any object to the output stream. -- */ -- public void writeObject(Object object) -- throws IOException -- { -- _out.writeStreamingObject(object); -- } -- -- /** -- * Flushes the output. -- */ -- public void flush() -- throws IOException -- { -- _out.flush(); -- } -- -- /** -- * Close the output. -- */ -- public void close() -- throws IOException -- { -- _out.close(); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+ -+/** -+ * Output stream for Hessian 2 streaming requests. -+ */ -+public class Hessian2StreamingOutput -+{ -+ private Hessian2Output _out; -+ -+ /** -+ * Creates a new Hessian output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public Hessian2StreamingOutput(OutputStream os) -+ { -+ _out = new Hessian2Output(os); -+ } -+ -+ public Hessian2StreamingOutput(Hessian2Output out) -+ { -+ _out = out; -+ } -+ -+ public Hessian2Output getHessian2Output() -+ { -+ return _out; -+ } -+ -+ public void setCloseStreamOnClose(boolean isClose) -+ { -+ _out.setCloseStreamOnClose(isClose); -+ } -+ -+ public boolean isCloseStreamOnClose() -+ { -+ return _out.isCloseStreamOnClose(); -+ } -+ -+ /** -+ * Writes any object to the output stream. -+ */ -+ public void writeObject(Object object) -+ throws IOException -+ { -+ _out.writeStreamingObject(object); -+ } -+ -+ /** -+ * Flushes the output. -+ */ -+ public void flush() -+ throws IOException -+ { -+ _out.flush(); -+ } -+ -+ /** -+ * Close the output. -+ */ -+ public void close() -+ throws IOException -+ { -+ _out.close(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugInputStream.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugInputStream.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugInputStream.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugInputStream.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,211 +1,211 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; --import java.io.Writer; --import java.io.PrintWriter; --import java.util.ArrayList; -- --import java.util.logging.Logger; --import java.util.logging.Level; -- --/** -- * Debugging input stream for Hessian requests. -- */ --public class HessianDebugInputStream extends InputStream --{ -- private InputStream _is; -- -- private HessianDebugState _state; -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugInputStream(InputStream is, OutputStream os) -- { -- this(is, new PrintWriter(os)); -- } -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugInputStream(InputStream is, PrintWriter dbg) -- { -- _is = is; -- -- if (dbg == null) -- dbg = new PrintWriter(System.out); -- -- _state = new HessianDebugState(dbg); -- } -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugInputStream(InputStream is, Logger log, Level level) -- { -- this(is, new PrintWriter(new LogWriter(log, level))); -- } -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugInputStream(Logger log, Level level) -- { -- this(null, log, level); -- } -- -- public void initPacket(InputStream is) -- { -- _is = is; -- } -- -- public void startTop2() -- { -- _state.startTop2(); -- } -- -- public void startData1() -- { -- _state.startData1(); -- } -- -- public void startStreaming() -- { -- _state.startStreaming(); -- } -- -- public void setDepth(int depth) -- { -- _state.setDepth(depth); -- } -- -- /** -- * Reads a character. -- */ -- public int read() -- throws IOException -- { -- int ch; -- -- InputStream is = _is; -- -- if (is == null) -- return -1; -- else { -- ch = is.read(); -- } -- -- _state.next(ch); -- -- return ch; -- } -- -- /** -- * closes the stream. -- */ -- public void close() -- throws IOException -- { -- InputStream is = _is; -- _is = null; -- -- if (is != null) -- is.close(); -- -- _state.println(); -- } -- -- static class LogWriter extends Writer { -- private Logger _log; -- private Level _level; -- private StringBuilder _sb = new StringBuilder(); -- -- LogWriter(Logger log, Level level) -- { -- _log = log; -- _level = level; -- } -- -- public void write(char ch) -- { -- if (ch == '\n' && _sb.length() > 0) { -- _log.log(_level, _sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- -- public void write(char []buffer, int offset, int length) -- { -- for (int i = 0; i < length; i++) { -- char ch = buffer[offset + i]; -- -- if (ch == '\n' && _sb.length() > 0) { -- _log.log(_level, _sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- } -- -- public void flush() -- { -- } -- -- public void close() -- { -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.Writer; -+import java.io.PrintWriter; -+import java.util.ArrayList; -+ -+import java.util.logging.Logger; -+import java.util.logging.Level; -+ -+/** -+ * Debugging input stream for Hessian requests. -+ */ -+public class HessianDebugInputStream extends InputStream -+{ -+ private InputStream _is; -+ -+ private HessianDebugState _state; -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugInputStream(InputStream is, OutputStream os) -+ { -+ this(is, new PrintWriter(os)); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugInputStream(InputStream is, PrintWriter dbg) -+ { -+ _is = is; -+ -+ if (dbg == null) -+ dbg = new PrintWriter(System.out); -+ -+ _state = new HessianDebugState(dbg); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugInputStream(InputStream is, Logger log, Level level) -+ { -+ this(is, new PrintWriter(new LogWriter(log, level))); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugInputStream(Logger log, Level level) -+ { -+ this(null, log, level); -+ } -+ -+ public void initPacket(InputStream is) -+ { -+ _is = is; -+ } -+ -+ public void startTop2() -+ { -+ _state.startTop2(); -+ } -+ -+ public void startData1() -+ { -+ _state.startData1(); -+ } -+ -+ public void startStreaming() -+ { -+ _state.startStreaming(); -+ } -+ -+ public void setDepth(int depth) -+ { -+ _state.setDepth(depth); -+ } -+ -+ /** -+ * Reads a character. -+ */ -+ public int read() -+ throws IOException -+ { -+ int ch; -+ -+ InputStream is = _is; -+ -+ if (is == null) -+ return -1; -+ else { -+ ch = is.read(); -+ } -+ -+ _state.next(ch); -+ -+ return ch; -+ } -+ -+ /** -+ * closes the stream. -+ */ -+ public void close() -+ throws IOException -+ { -+ InputStream is = _is; -+ _is = null; -+ -+ if (is != null) -+ is.close(); -+ -+ _state.println(); -+ } -+ -+ static class LogWriter extends Writer { -+ private Logger _log; -+ private Level _level; -+ private StringBuilder _sb = new StringBuilder(); -+ -+ LogWriter(Logger log, Level level) -+ { -+ _log = log; -+ _level = level; -+ } -+ -+ public void write(char ch) -+ { -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.log(_level, _sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ -+ public void write(char []buffer, int offset, int length) -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = buffer[offset + i]; -+ -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.log(_level, _sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ } -+ -+ public void flush() -+ { -+ } -+ -+ public void close() -+ { -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugOutputStream.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugOutputStream.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugOutputStream.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugOutputStream.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,198 +1,198 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.OutputStream; --import java.io.Writer; --import java.io.PrintWriter; -- --import java.util.logging.Logger; --import java.util.logging.Level; -- --/** -- * Debugging output stream for Hessian requests. -- */ --public class HessianDebugOutputStream extends OutputStream --{ -- private static final Logger log -- = Logger.getLogger(HessianDebugOutputStream.class.getName()); -- -- private OutputStream _os; -- -- private HessianDebugState _state; -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugOutputStream(OutputStream os, PrintWriter dbg) -- { -- _os = os; -- -- _state = new HessianDebugState(dbg); -- } -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugOutputStream(OutputStream os, Logger log, Level level) -- { -- this(os, new PrintWriter(new LogWriter(log, level))); -- } -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugOutputStream(Logger log, Level level) -- { -- this(null, new PrintWriter(new LogWriter(log, level))); -- } -- -- public void initPacket(OutputStream os) -- { -- _os = os; -- } -- -- public void startTop2() -- { -- _state.startTop2(); -- } -- -- public void startStreaming() -- { -- _state.startStreaming(); -- } -- -- /** -- * Writes a character. -- */ -- @Override -- public void write(int ch) -- throws IOException -- { -- ch = ch & 0xff; -- -- _os.write(ch); -- -- try { -- _state.next(ch); -- } catch (Exception e) { -- log.log(Level.WARNING, e.toString(), e); -- } -- } -- -- @Override -- public void flush() -- throws IOException -- { -- _os.flush(); -- } -- -- /** -- * closes the stream. -- */ -- @Override -- public void close() -- throws IOException -- { -- OutputStream os = _os; -- _os = null; -- -- if (os != null) { -- _state.next(-1); -- os.close(); -- } -- -- _state.println(); -- } -- -- static class LogWriter extends Writer { -- private Logger _log; -- private Level _level; -- private StringBuilder _sb = new StringBuilder(); -- -- LogWriter(Logger log, Level level) -- { -- _log = log; -- _level = level; -- } -- -- public void write(char ch) -- { -- if (ch == '\n' && _sb.length() > 0) { -- _log.log(_level, _sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- -- public void write(char []buffer, int offset, int length) -- { -- for (int i = 0; i < length; i++) { -- char ch = buffer[offset + i]; -- -- if (ch == '\n' && _sb.length() > 0) { -- _log.log(_level, _sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- } -- -- public void flush() -- { -- } -- -- public void close() -- { -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+import java.io.Writer; -+import java.io.PrintWriter; -+ -+import java.util.logging.Logger; -+import java.util.logging.Level; -+ -+/** -+ * Debugging output stream for Hessian requests. -+ */ -+public class HessianDebugOutputStream extends OutputStream -+{ -+ private static final Logger log -+ = Logger.getLogger(HessianDebugOutputStream.class.getName()); -+ -+ private OutputStream _os; -+ -+ private HessianDebugState _state; -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugOutputStream(OutputStream os, PrintWriter dbg) -+ { -+ _os = os; -+ -+ _state = new HessianDebugState(dbg); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugOutputStream(OutputStream os, Logger log, Level level) -+ { -+ this(os, new PrintWriter(new LogWriter(log, level))); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugOutputStream(Logger log, Level level) -+ { -+ this(null, new PrintWriter(new LogWriter(log, level))); -+ } -+ -+ public void initPacket(OutputStream os) -+ { -+ _os = os; -+ } -+ -+ public void startTop2() -+ { -+ _state.startTop2(); -+ } -+ -+ public void startStreaming() -+ { -+ _state.startStreaming(); -+ } -+ -+ /** -+ * Writes a character. -+ */ -+ @Override -+ public void write(int ch) -+ throws IOException -+ { -+ ch = ch & 0xff; -+ -+ _os.write(ch); -+ -+ try { -+ _state.next(ch); -+ } catch (Exception e) { -+ log.log(Level.WARNING, e.toString(), e); -+ } -+ } -+ -+ @Override -+ public void flush() -+ throws IOException -+ { -+ _os.flush(); -+ } -+ -+ /** -+ * closes the stream. -+ */ -+ @Override -+ public void close() -+ throws IOException -+ { -+ OutputStream os = _os; -+ _os = null; -+ -+ if (os != null) { -+ _state.next(-1); -+ os.close(); -+ } -+ -+ _state.println(); -+ } -+ -+ static class LogWriter extends Writer { -+ private Logger _log; -+ private Level _level; -+ private StringBuilder _sb = new StringBuilder(); -+ -+ LogWriter(Logger log, Level level) -+ { -+ _log = log; -+ _level = level; -+ } -+ -+ public void write(char ch) -+ { -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.log(_level, _sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ -+ public void write(char []buffer, int offset, int length) -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = buffer[offset + i]; -+ -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.log(_level, _sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ } -+ -+ public void flush() -+ { -+ } -+ -+ public void close() -+ { -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugState.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugState.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianDebugState.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianDebugState.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,2527 +1,2527 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.PrintWriter; --import java.util.ArrayList; --import java.util.logging.Logger; -- --/** -- * Debugging input stream for Hessian requests. -- */ --public class HessianDebugState implements Hessian2Constants --{ -- private static final Logger log -- = Logger.getLogger(HessianDebugState.class.getName()); -- -- private PrintWriter _dbg; -- -- private State _state; -- private ArrayList _stateStack = new ArrayList(); -- -- private ArrayList _objectDefList -- = new ArrayList(); -- -- private ArrayList _typeDefList -- = new ArrayList(); -- -- private int _refId; -- private boolean _isNewline = true; -- private boolean _isObject = false; -- private int _column; -- -- private int _depth = 0; -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianDebugState(PrintWriter dbg) -- { -- _dbg = dbg; -- -- _state = new InitialState(); -- } -- -- public void startTop2() -- { -- _state = new Top2State(); -- } -- -- public void startData1() -- { -- _state = new InitialState1(); -- } -- -- public void startStreaming() -- { -- _state = new StreamingState(new InitialState(), false); -- } -- -- /** -- * Reads a character. -- */ -- public void next(int ch) -- throws IOException -- { -- _state = _state.next(ch); -- } -- -- void pushStack(State state) -- { -- _stateStack.add(state); -- } -- -- State popStack() -- { -- return _stateStack.remove(_stateStack.size() - 1); -- } -- -- public void setDepth(int depth) -- { -- _depth = depth; -- } -- -- public int getDepth() -- { -- return _depth; -- } -- -- void println() -- { -- if (! _isNewline) { -- _dbg.println(); -- _dbg.flush(); -- } -- -- _isNewline = true; -- _column = 0; -- } -- -- static boolean isString(int ch) -- { -- switch (ch) { -- case 0x00: case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- -- case 'R': -- case 'S': -- return true; -- -- default: -- return false; -- } -- } -- -- static boolean isInteger(int ch) -- { -- switch (ch) { -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc8: case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd4: case 0xd5: case 0xd6: case 0xd7: -- -- case 'I': -- return true; -- -- default: -- return false; -- } -- } -- -- abstract class State { -- State _next; -- -- State() -- { -- } -- -- State(State next) -- { -- _next = next; -- } -- -- abstract State next(int ch); -- -- boolean isShift(Object value) -- { -- return false; -- } -- -- State shift(Object value) -- { -- return this; -- } -- -- int depth() -- { -- if (_next != null) -- return _next.depth(); -- else -- return HessianDebugState.this.getDepth(); -- } -- -- void printIndent(int depth) -- { -- if (_isNewline) { -- for (int i = _column; i < depth() + depth; i++) { -- _dbg.print(" "); -- _column++; -- } -- } -- } -- -- void print(String string) -- { -- print(0, string); -- } -- -- void print(int depth, String string) -- { -- printIndent(depth); -- -- _dbg.print(string); -- _isNewline = false; -- _isObject = false; -- -- int p = string.lastIndexOf('\n'); -- if (p > 0) -- _column = string.length() - p - 1; -- else -- _column += string.length(); -- } -- -- void println(String string) -- { -- println(0, string); -- } -- -- void println(int depth, String string) -- { -- printIndent(depth); -- -- _dbg.println(string); -- _dbg.flush(); -- _isNewline = true; -- _isObject = false; -- _column = 0; -- } -- -- void println() -- { -- if (! _isNewline) { -- _dbg.println(); -- _dbg.flush(); -- } -- -- _isNewline = true; -- _isObject = false; -- _column = 0; -- } -- -- void printObject(String string) -- { -- if (_isObject) -- println(); -- -- printIndent(0); -- -- _dbg.print(string); -- _dbg.flush(); -- -- _column += string.length(); -- -- _isNewline = false; -- _isObject = true; -- } -- -- protected State nextObject(int ch) -- { -- switch (ch) { -- case -1: -- println(); -- return this; -- -- case 'N': -- if (isShift(null)) -- return shift(null); -- else { -- printObject("null"); -- return this; -- } -- -- case 'T': -- if (isShift(Boolean.TRUE)) -- return shift(Boolean.TRUE); -- else { -- printObject("true"); -- return this; -- } -- -- case 'F': -- if (isShift(Boolean.FALSE)) -- return shift(Boolean.FALSE); -- else { -- printObject("false"); -- return this; -- } -- -- case 0x80: case 0x81: case 0x82: case 0x83: -- case 0x84: case 0x85: case 0x86: case 0x87: -- case 0x88: case 0x89: case 0x8a: case 0x8b: -- case 0x8c: case 0x8d: case 0x8e: case 0x8f: -- -- case 0x90: case 0x91: case 0x92: case 0x93: -- case 0x94: case 0x95: case 0x96: case 0x97: -- case 0x98: case 0x99: case 0x9a: case 0x9b: -- case 0x9c: case 0x9d: case 0x9e: case 0x9f: -- -- case 0xa0: case 0xa1: case 0xa2: case 0xa3: -- case 0xa4: case 0xa5: case 0xa6: case 0xa7: -- case 0xa8: case 0xa9: case 0xaa: case 0xab: -- case 0xac: case 0xad: case 0xae: case 0xaf: -- -- case 0xb0: case 0xb1: case 0xb2: case 0xb3: -- case 0xb4: case 0xb5: case 0xb6: case 0xb7: -- case 0xb8: case 0xb9: case 0xba: case 0xbb: -- case 0xbc: case 0xbd: case 0xbe: case 0xbf: -- { -- Integer value = new Integer(ch - 0x90); -- -- if (isShift(value)) -- return shift(value); -- else { -- printObject(value.toString()); -- return this; -- } -- } -- -- case 0xc0: case 0xc1: case 0xc2: case 0xc3: -- case 0xc4: case 0xc5: case 0xc6: case 0xc7: -- case 0xc8: case 0xc9: case 0xca: case 0xcb: -- case 0xcc: case 0xcd: case 0xce: case 0xcf: -- return new IntegerState(this, "int", ch - 0xc8, 3); -- -- case 0xd0: case 0xd1: case 0xd2: case 0xd3: -- case 0xd4: case 0xd5: case 0xd6: case 0xd7: -- return new IntegerState(this, "int", ch - 0xd4, 2); -- -- case 'I': -- return new IntegerState(this, "int"); -- -- case 0xd8: case 0xd9: case 0xda: case 0xdb: -- case 0xdc: case 0xdd: case 0xde: case 0xdf: -- case 0xe0: case 0xe1: case 0xe2: case 0xe3: -- case 0xe4: case 0xe5: case 0xe6: case 0xe7: -- case 0xe8: case 0xe9: case 0xea: case 0xeb: -- case 0xec: case 0xed: case 0xee: case 0xef: -- { -- Long value = new Long(ch - 0xe0); -- -- if (isShift(value)) -- return shift(value); -- else { -- printObject(value.toString() + "L"); -- return this; -- } -- } -- -- case 0xf0: case 0xf1: case 0xf2: case 0xf3: -- case 0xf4: case 0xf5: case 0xf6: case 0xf7: -- case 0xf8: case 0xf9: case 0xfa: case 0xfb: -- case 0xfc: case 0xfd: case 0xfe: case 0xff: -- return new LongState(this, "long", ch - 0xf8, 7); -- -- case 0x38: case 0x39: case 0x3a: case 0x3b: -- case 0x3c: case 0x3d: case 0x3e: case 0x3f: -- return new LongState(this, "long", ch - 0x3c, 6); -- -- case BC_LONG_INT: -- return new LongState(this, "long", 0, 4); -- -- case 'L': -- return new LongState(this, "long"); -- -- case 0x5b: case 0x5c: -- { -- Double value = new Double(ch - 0x5b); -- -- if (isShift(value)) -- return shift(value); -- else { -- printObject(value.toString()); -- return this; -- } -- } -- -- case 0x5d: -- return new DoubleIntegerState(this, 3); -- -- case 0x5e: -- return new DoubleIntegerState(this, 2); -- -- case 0x5f: -- return new MillsState(this); -- -- case 'D': -- return new DoubleState(this); -- -- case 'Q': -- return new RefState(this); -- -- case BC_DATE: -- return new DateState(this); -- -- case BC_DATE_MINUTE: -- return new DateState(this, true); -- -- case 0x00: -- { -- String value = "\"\""; -- -- if (isShift(value)) -- return shift(value); -- else { -- printObject(value.toString()); -- return this; -- } -- } -- -- case 0x01: case 0x02: case 0x03: -- case 0x04: case 0x05: case 0x06: case 0x07: -- case 0x08: case 0x09: case 0x0a: case 0x0b: -- case 0x0c: case 0x0d: case 0x0e: case 0x0f: -- -- case 0x10: case 0x11: case 0x12: case 0x13: -- case 0x14: case 0x15: case 0x16: case 0x17: -- case 0x18: case 0x19: case 0x1a: case 0x1b: -- case 0x1c: case 0x1d: case 0x1e: case 0x1f: -- return new StringState(this, 'S', ch); -- -- case 0x30: case 0x31: case 0x32: case 0x33: -- return new StringState(this, 'S', ch - 0x30, true); -- -- case 'R': -- return new StringState(this, 'S', false); -- -- case 'S': -- return new StringState(this, 'S', true); -- -- case 0x20: -- { -- String value = "binary(0)"; -- -- if (isShift(value)) -- return shift(value); -- else { -- printObject(value.toString()); -- return this; -- } -- } -- -- case 0x21: case 0x22: case 0x23: -- case 0x24: case 0x25: case 0x26: case 0x27: -- case 0x28: case 0x29: case 0x2a: case 0x2b: -- case 0x2c: case 0x2d: case 0x2e: case 0x2f: -- return new BinaryState(this, 'B', ch - 0x20); -- -- case 0x34: case 0x35: case 0x36: case 0x37: -- return new BinaryState(this, 'B', ch - 0x34, true); -- -- case 'A': -- return new BinaryState(this, 'B', false); -- -- case 'B': -- return new BinaryState(this, 'B', true); -- -- case 'M': -- return new MapState(this, _refId++); -- -- case 'H': -- return new MapState(this, _refId++, false); -- -- case BC_LIST_VARIABLE: -- return new ListState(this, _refId++, true); -- -- case BC_LIST_VARIABLE_UNTYPED: -- return new ListState(this, _refId++, false); -- -- case BC_LIST_FIXED: -- return new CompactListState(this, _refId++, true); -- -- case BC_LIST_FIXED_UNTYPED: -- return new CompactListState(this, _refId++, false); -- -- case 0x70: case 0x71: case 0x72: case 0x73: -- case 0x74: case 0x75: case 0x76: case 0x77: -- return new CompactListState(this, _refId++, true, ch - 0x70); -- -- case 0x78: case 0x79: case 0x7a: case 0x7b: -- case 0x7c: case 0x7d: case 0x7e: case 0x7f: -- return new CompactListState(this, _refId++, false, ch - 0x78); -- -- case 'C': -- return new ObjectDefState(this); -- -- case 0x60: case 0x61: case 0x62: case 0x63: -- case 0x64: case 0x65: case 0x66: case 0x67: -- case 0x68: case 0x69: case 0x6a: case 0x6b: -- case 0x6c: case 0x6d: case 0x6e: case 0x6f: -- return new ObjectState(this, _refId++, ch - 0x60); -- -- case 'O': -- return new ObjectState(this, _refId++); -- -- default: -- return this; -- } -- } -- } -- -- abstract class State1 extends State { -- State1() -- { -- } -- -- State1(State next) -- { -- super(next); -- } -- -- protected State nextObject(int ch) -- { -- switch (ch) { -- case -1: -- println(); -- return this; -- -- case 'N': -- if (isShift(null)) -- return shift(null); -- else { -- printObject("null"); -- return this; -- } -- -- case 'T': -- if (isShift(Boolean.TRUE)) -- return shift(Boolean.TRUE); -- else { -- printObject("true"); -- return this; -- } -- -- case 'F': -- if (isShift(Boolean.FALSE)) -- return shift(Boolean.FALSE); -- else { -- printObject("false"); -- return this; -- } -- -- case 'I': -- return new IntegerState(this, "int"); -- -- case 'L': -- return new LongState(this, "long"); -- -- case 'D': -- return new DoubleState(this); -- -- case 'Q': -- return new RefState(this); -- -- case 'd': -- return new DateState(this); -- -- case 's': -- return new StringState(this, 'S', false); -- -- case 'S': -- return new StringState(this, 'S', true); -- -- case 'b': -- case 'A': -- return new BinaryState(this, 'B', false); -- -- case 'B': -- return new BinaryState(this, 'B', true); -- -- case 'M': -- return new MapState1(this, _refId++); -- -- case 'V': -- return new ListState1(this, _refId++); -- -- case 'R': -- return new IntegerState(new RefState1(this), "ref"); -- -- default: -- printObject("x" + String.format("%02x", ch)); -- return this; -- } -- } -- } -- -- class InitialState extends State { -- State next(int ch) -- { -- return nextObject(ch); -- } -- } -- -- class InitialState1 extends State1 { -- State next(int ch) -- { -- return nextObject(ch); -- } -- } -- -- class Top1State extends State1 { -- State next(int ch) -- { -- println(); -- -- if (ch == 'r') { -- return new ReplyState1(this); -- } -- else if (ch == 'c') { -- return new CallState1(this); -- } -- else -- return nextObject(ch); -- } -- } -- -- class Top2State extends State { -- State next(int ch) -- { -- println(); -- -- if (ch == 'R') { -- return new Reply2State(this); -- } -- else if (ch == 'F') { -- return new Fault2State(this); -- } -- else if (ch == 'C') { -- return new Call2State(this); -- } -- else if (ch == 'H') { -- return new Hessian2State(this); -- } -- else if (ch == 'r') { -- return new ReplyState1(this); -- } -- else if (ch == 'c') { -- return new CallState1(this); -- } -- else -- return nextObject(ch); -- } -- } -- -- class IntegerState extends State { -- String _typeCode; -- -- int _length; -- int _value; -- -- IntegerState(State next, String typeCode) -- { -- super(next); -- -- _typeCode = typeCode; -- } -- -- IntegerState(State next, String typeCode, int value, int length) -- { -- super(next); -- -- _typeCode = typeCode; -- -- _value = value; -- _length = length; -- } -- -- State next(int ch) -- { -- _value = 256 * _value + (ch & 0xff); -- -- if (++_length == 4) { -- Integer value = new Integer(_value); -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value.toString()); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class LongState extends State { -- String _typeCode; -- -- int _length; -- long _value; -- -- LongState(State next, String typeCode) -- { -- super(next); -- -- _typeCode = typeCode; -- } -- -- LongState(State next, String typeCode, long value, int length) -- { -- super(next); -- -- _typeCode = typeCode; -- -- _value = value; -- _length = length; -- } -- -- State next(int ch) -- { -- _value = 256 * _value + (ch & 0xff); -- -- if (++_length == 8) { -- Long value = new Long(_value); -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value.toString() + "L"); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class DoubleIntegerState extends State { -- int _length; -- int _value; -- boolean _isFirst = true; -- -- DoubleIntegerState(State next, int length) -- { -- super(next); -- -- _length = length; -- } -- -- State next(int ch) -- { -- if (_isFirst) -- _value = (byte) ch; -- else -- _value = 256 * _value + (ch & 0xff); -- -- _isFirst = false; -- -- if (++_length == 4) { -- Double value = new Double(_value); -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value.toString()); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class RefState extends State { -- String _typeCode; -- -- int _length; -- int _value; -- -- RefState(State next) -- { -- super(next); -- } -- -- RefState(State next, String typeCode) -- { -- super(next); -- -- _typeCode = typeCode; -- } -- -- RefState(State next, String typeCode, int value, int length) -- { -- super(next); -- -- _typeCode = typeCode; -- -- _value = value; -- _length = length; -- } -- -- @Override -- boolean isShift(Object o) -- { -- return true; -- } -- -- @Override -- State shift(Object o) -- { -- println("ref #" + o); -- -- return _next; -- } -- -- @Override -- State next(int ch) -- { -- return nextObject(ch); -- } -- } -- -- class RefState1 extends State { -- String _typeCode; -- -- RefState1(State next) -- { -- super(next); -- } -- -- @Override -- boolean isShift(Object o) -- { -- return true; -- } -- -- @Override -- State shift(Object o) -- { -- println("ref #" + o); -- -- return _next; -- } -- -- @Override -- State next(int ch) -- { -- return nextObject(ch); -- } -- } -- -- class DateState extends State { -- int _length; -- long _value; -- boolean _isMinute; -- -- DateState(State next) -- { -- super(next); -- } -- -- DateState(State next, boolean isMinute) -- { -- super(next); -- -- _length = 4; -- _isMinute = isMinute; -- } -- -- -- State next(int ch) -- { -- _value = 256 * _value + (ch & 0xff); -- -- if (++_length == 8) { -- java.util.Date value; -- -- if (_isMinute) -- value = new java.util.Date(_value * 60000L); -- else -- value = new java.util.Date(_value); -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value.toString()); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class DoubleState extends State { -- int _length; -- long _value; -- -- DoubleState(State next) -- { -- super(next); -- } -- -- State next(int ch) -- { -- _value = 256 * _value + (ch & 0xff); -- -- if (++_length == 8) { -- Double value = Double.longBitsToDouble(_value); -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value.toString()); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class MillsState extends State { -- int _length; -- int _value; -- -- MillsState(State next) -- { -- super(next); -- } -- -- State next(int ch) -- { -- _value = 256 * _value + (ch & 0xff); -- -- if (++_length == 4) { -- Double value = 0.001 * _value; -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value.toString()); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class StringState extends State { -- private static final int TOP = 0; -- private static final int UTF_2_1 = 1; -- private static final int UTF_3_1 = 2; -- private static final int UTF_3_2 = 3; -- -- char _typeCode; -- -- StringBuilder _value = new StringBuilder(); -- int _lengthIndex; -- int _length; -- boolean _isLastChunk; -- -- int _utfState; -- char _ch; -- -- StringState(State next, char typeCode, boolean isLastChunk) -- { -- super(next); -- -- _typeCode = typeCode; -- _isLastChunk = isLastChunk; -- } -- -- StringState(State next, char typeCode, int length) -- { -- super(next); -- -- _typeCode = typeCode; -- _isLastChunk = true; -- _length = length; -- _lengthIndex = 2; -- } -- -- StringState(State next, char typeCode, int length, boolean isLastChunk) -- { -- super(next); -- -- _typeCode = typeCode; -- _isLastChunk = isLastChunk; -- _length = length; -- _lengthIndex = 1; -- } -- -- State next(int ch) -- { -- if (_lengthIndex < 2) { -- _length = 256 * _length + (ch & 0xff); -- -- if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { -- if (_next.isShift(_value.toString())) -- return _next.shift(_value.toString()); -- else { -- printObject("\"" + _value + "\""); -- return _next; -- } -- } -- else -- return this; -- } -- else if (_length == 0) { -- if (ch == 's' || ch == 'x') { -- _isLastChunk = false; -- _lengthIndex = 0; -- return this; -- } -- else if (ch == 'S' || ch == 'X') { -- _isLastChunk = true; -- _lengthIndex = 0; -- return this; -- } -- else if (ch == 0x00) { -- if (_next.isShift(_value.toString())) -- return _next.shift(_value.toString()); -- else { -- printObject("\"" + _value + "\""); -- return _next; -- } -- } -- else if (0x00 <= ch && ch < 0x20) { -- _isLastChunk = true; -- _lengthIndex = 2; -- _length = ch & 0xff; -- return this; -- } -- else if (0x30 <= ch && ch < 0x34) { -- _isLastChunk = true; -- _lengthIndex = 1; -- _length = (ch - 0x30); -- return this; -- } -- else { -- println(this + " " + String.valueOf((char) ch) + ": unexpected character"); -- return _next; -- } -- } -- -- switch (_utfState) { -- case TOP: -- if (ch < 0x80) { -- _length--; -- -- _value.append((char) ch); -- } -- else if (ch < 0xe0) { -- _ch = (char) ((ch & 0x1f) << 6); -- _utfState = UTF_2_1; -- } -- else { -- _ch = (char) ((ch & 0xf) << 12); -- _utfState = UTF_3_1; -- } -- break; -- -- case UTF_2_1: -- case UTF_3_2: -- _ch += ch & 0x3f; -- _value.append(_ch); -- _length--; -- _utfState = TOP; -- break; -- -- case UTF_3_1: -- _ch += (char) ((ch & 0x3f) << 6); -- _utfState = UTF_3_2; -- break; -- } -- -- if (_length == 0 && _isLastChunk) { -- if (_next.isShift(_value.toString())) -- return _next.shift(_value.toString()); -- else { -- printObject("\"" + _value + "\""); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class BinaryState extends State { -- char _typeCode; -- -- int _totalLength; -- -- int _lengthIndex; -- int _length; -- boolean _isLastChunk; -- -- BinaryState(State next, char typeCode, boolean isLastChunk) -- { -- super(next); -- -- _typeCode = typeCode; -- _isLastChunk = isLastChunk; -- } -- -- BinaryState(State next, char typeCode, int length) -- { -- super(next); -- -- _typeCode = typeCode; -- _isLastChunk = true; -- _length = length; -- _lengthIndex = 2; -- } -- -- BinaryState(State next, char typeCode, int length, boolean isLastChunk) -- { -- super(next); -- -- _typeCode = typeCode; -- _isLastChunk = isLastChunk; -- _length = length; -- _lengthIndex = 1; -- } -- -- @Override -- State next(int ch) -- { -- if (_lengthIndex < 2) { -- _length = 256 * _length + (ch & 0xff); -- -- if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { -- String value = "binary(" + _totalLength + ")"; -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value); -- return _next; -- } -- } -- else -- return this; -- } -- else if (_length == 0) { -- if (ch == 'b' || ch == 'A') { -- _isLastChunk = false; -- _lengthIndex = 0; -- return this; -- } -- else if (ch == 'B') { -- _isLastChunk = true; -- _lengthIndex = 0; -- return this; -- } -- else if (ch == 0x20) { -- String value = "binary(" + _totalLength + ")"; -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value); -- return _next; -- } -- } -- else if (0x20 <= ch && ch < 0x30) { -- _isLastChunk = true; -- _lengthIndex = 2; -- _length = (ch & 0xff) - 0x20; -- return this; -- } -- else { -- println(this + " 0x" + Integer.toHexString(ch) + " " + String.valueOf((char) ch) + ": unexpected character"); -- return _next; -- } -- } -- -- _length--; -- _totalLength++; -- -- if (_length == 0 && _isLastChunk) { -- String value = "binary(" + _totalLength + ")"; -- -- if (_next.isShift(value)) -- return _next.shift(value); -- else { -- printObject(value); -- -- return _next; -- } -- } -- else -- return this; -- } -- } -- -- class MapState extends State { -- private static final int TYPE = 0; -- private static final int KEY = 1; -- private static final int VALUE = 2; -- -- private int _refId; -- -- private int _state; -- private int _valueDepth; -- private boolean _hasData; -- -- MapState(State next, int refId) -- { -- super(next); -- -- _refId = refId; -- _state = TYPE; -- } -- -- MapState(State next, int refId, boolean isType) -- { -- super(next); -- -- _refId = refId; -- -- if (isType) -- _state = TYPE; -- else { -- printObject("map (#" + _refId + ")"); -- _state = VALUE; -- } -- } -- -- @Override -- boolean isShift(Object value) -- { -- return _state == TYPE; -- } -- -- @Override -- State shift(Object type) -- { -- if (_state == TYPE) { -- if (type instanceof String) { -- _typeDefList.add((String) type); -- } -- else if (type instanceof Integer) { -- int iValue = (Integer) type; -- -- if (iValue >= 0 && iValue < _typeDefList.size()) -- type = _typeDefList.get(iValue); -- } -- -- printObject("map " + type + " (#" + _refId + ")"); -- -- _state = VALUE; -- -- return this; -- } -- else { -- printObject(this + " unknown shift state= " + _state + " type=" + type); -- -- return this; -- } -- } -- -- @Override -- int depth() -- { -- if (_state == TYPE) -- return _next.depth(); -- else if (_state == KEY) -- return _next.depth() + 2; -- else -- return _valueDepth; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- return nextObject(ch); -- -- case VALUE: -- if (ch == 'Z') { -- if (_hasData) -- println(); -- -- return _next; -- } -- else { -- if (_hasData) -- println(); -- -- _hasData = true; -- _state = KEY; -- -- return nextObject(ch); -- } -- -- case KEY: -- print(" => "); -- _isObject = false; -- _valueDepth = _column; -- -- _state = VALUE; -- -- return nextObject(ch); -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class MapState1 extends State1 { -- private static final int TYPE = 0; -- private static final int KEY = 1; -- private static final int VALUE = 2; -- -- private int _refId; -- -- private int _state; -- private int _valueDepth; -- private boolean _hasData; -- -- MapState1(State next, int refId) -- { -- super(next); -- -- _refId = refId; -- _state = TYPE; -- } -- -- MapState1(State next, int refId, boolean isType) -- { -- super(next); -- -- _refId = refId; -- -- if (isType) -- _state = TYPE; -- else { -- printObject("map (#" + _refId + ")"); -- _state = VALUE; -- } -- } -- -- @Override -- boolean isShift(Object value) -- { -- return _state == TYPE; -- } -- -- @Override -- State shift(Object type) -- { -- if (_state == TYPE) { -- if (type instanceof String) { -- _typeDefList.add((String) type); -- } -- else if (type instanceof Integer) { -- int iValue = (Integer) type; -- -- if (iValue >= 0 && iValue < _typeDefList.size()) -- type = _typeDefList.get(iValue); -- } -- -- printObject("map " + type + " (#" + _refId + ")"); -- -- _state = VALUE; -- -- return this; -- } -- else -- throw new IllegalStateException(); -- } -- -- @Override -- int depth() -- { -- if (_state == TYPE) -- return _next.depth(); -- else if (_state == KEY) -- return _next.depth() + 2; -- else -- return _valueDepth; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- if (ch == 't') { -- return new StringState(this, 't', true); -- } -- else if (ch == 'z') { -- println("map (#" + _refId + ")"); -- return _next; -- } -- else { -- println("map (#" + _refId + ")"); -- _hasData = true; -- _state = KEY; -- return nextObject(ch); -- } -- -- case VALUE: -- if (ch == 'z') { -- if (_hasData) -- println(); -- -- return _next; -- } -- else { -- if (_hasData) -- println(); -- -- _hasData = true; -- _state = KEY; -- -- return nextObject(ch); -- } -- -- case KEY: -- print(" => "); -- _isObject = false; -- _valueDepth = _column; -- -- _state = VALUE; -- -- return nextObject(ch); -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class ObjectDefState extends State { -- private static final int TYPE = 1; -- private static final int COUNT = 2; -- private static final int FIELD = 3; -- private static final int COMPLETE = 4; -- -- private int _state; -- private int _count; -- -- private String _type; -- private ArrayList _fields = new ArrayList(); -- -- ObjectDefState(State next) -- { -- super(next); -- -- _state = TYPE; -- } -- -- @Override -- boolean isShift(Object value) -- { -- return true; -- } -- -- @Override -- State shift(Object object) -- { -- if (_state == TYPE) { -- _type = (String) object; -- -- print("/* defun " + _type + " ["); -- -- _objectDefList.add(new ObjectDef(_type, _fields)); -- -- _state = COUNT; -- } -- else if (_state == COUNT) { -- _count = (Integer) object; -- -- _state = FIELD; -- } -- else if (_state == FIELD) { -- String field = (String) object; -- -- _count--; -- -- _fields.add(field); -- -- if (_fields.size() == 1) -- print(field); -- else -- print(", " + field); -- } -- else { -- throw new UnsupportedOperationException(); -- } -- -- return this; -- } -- -- @Override -- int depth() -- { -- if (_state <= TYPE) -- return _next.depth(); -- else -- return _next.depth() + 2; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- return nextObject(ch); -- -- case COUNT: -- return nextObject(ch); -- -- case FIELD: -- if (_count == 0) { -- println("] */"); -- _next.printIndent(0); -- -- return _next.nextObject(ch); -- } -- else -- return nextObject(ch); -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class ObjectState extends State { -- private static final int TYPE = 0; -- private static final int FIELD = 1; -- -- private int _refId; -- -- private int _state; -- private ObjectDef _def; -- private int _count; -- private int _fieldDepth; -- -- ObjectState(State next, int refId) -- { -- super(next); -- -- _refId = refId; -- _state = TYPE; -- } -- -- ObjectState(State next, int refId, int def) -- { -- super(next); -- -- _refId = refId; -- _state = FIELD; -- -- if (def < 0 || _objectDefList.size() <= def) { -- log.warning(this + " " + def + " is an unknown object type"); -- -- println(this + " object unknown (#" + _refId + ")"); -- } -- -- _def = _objectDefList.get(def); -- -- if (_isObject) -- println(); -- -- println("object " + _def.getType() + " (#" + _refId + ")"); -- } -- -- @Override -- boolean isShift(Object value) -- { -- if (_state == TYPE) -- return true; -- else -- return false; -- } -- -- @Override -- State shift(Object object) -- { -- if (_state == TYPE) { -- int def = (Integer) object; -- -- _def = _objectDefList.get(def); -- -- println("object " + _def.getType() + " (#" + _refId + ")"); -- -- _state = FIELD; -- -- if (_def.getFields().size() == 0) -- return _next; -- } -- -- return this; -- } -- -- @Override -- int depth() -- { -- if (_state <= TYPE) -- return _next.depth(); -- else -- return _fieldDepth; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- return nextObject(ch); -- -- case FIELD: -- if (_def.getFields().size() <= _count) -- return _next.next(ch); -- -- _fieldDepth = _next.depth() + 2; -- println(); -- print(_def.getFields().get(_count++) + ": "); -- -- _fieldDepth = _column; -- -- _isObject = false; -- return nextObject(ch); -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class ListState1 extends State1 { -- private static final int TYPE = 0; -- private static final int LENGTH = 1; -- private static final int VALUE = 2; -- -- private int _refId; -- -- private int _state; -- private int _count; -- private int _valueDepth; -- -- ListState1(State next, int refId) -- { -- super(next); -- -- _refId = refId; -- -- _state = TYPE; -- } -- -- @Override -- boolean isShift(Object value) -- { -- return _state == TYPE || _state == LENGTH; -- } -- -- @Override -- State shift(Object object) -- { -- if (_state == TYPE) { -- Object type = object; -- -- if (type instanceof String) { -- _typeDefList.add((String) type); -- } -- else if (object instanceof Integer) { -- int index = (Integer) object; -- -- if (index >= 0 && index < _typeDefList.size()) -- type = _typeDefList.get(index); -- else -- type = "type-unknown(" + index + ")"; -- } -- -- printObject("list " + type + "(#" + _refId + ")"); -- -- _state = VALUE; -- -- return this; -- } -- else if (_state == LENGTH) { -- _state = VALUE; -- -- return this; -- } -- else -- return this; -- } -- -- @Override -- int depth() -- { -- if (_state <= LENGTH) -- return _next.depth(); -- else if (_state == VALUE) -- return _valueDepth; -- else -- return _next.depth() + 2; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- if (ch == 'z') { -- printObject("list (#" + _refId + ")"); -- -- return _next; -- } -- else if (ch == 't') { -- return new StringState(this, 't', true); -- } -- else { -- printObject("list (#" + _refId + ")"); -- printObject(" " + _count++ + ": "); -- _valueDepth = _column; -- _isObject = false; -- _state = VALUE; -- -- return nextObject(ch); -- } -- -- case VALUE: -- if (ch == 'z') { -- if (_count > 0) -- println(); -- -- return _next; -- } -- else { -- _valueDepth = _next.depth() + 2; -- println(); -- printObject(_count++ + ": "); -- _valueDepth = _column; -- _isObject = false; -- -- return nextObject(ch); -- } -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class ListState extends State { -- private static final int TYPE = 0; -- private static final int LENGTH = 1; -- private static final int VALUE = 2; -- -- private int _refId; -- -- private int _state; -- private int _count; -- private int _valueDepth; -- -- ListState(State next, int refId, boolean isType) -- { -- super(next); -- -- _refId = refId; -- -- if (isType) -- _state = TYPE; -- else { -- printObject("list (#" + _refId + ")"); -- _state = VALUE; -- } -- } -- -- @Override -- boolean isShift(Object value) -- { -- return _state == TYPE || _state == LENGTH; -- } -- -- @Override -- State shift(Object object) -- { -- if (_state == TYPE) { -- Object type = object; -- -- if (type instanceof String) { -- _typeDefList.add((String) type); -- } -- else if (object instanceof Integer) { -- int index = (Integer) object; -- -- if (index >= 0 && index < _typeDefList.size()) -- type = _typeDefList.get(index); -- else -- type = "type-unknown(" + index + ")"; -- } -- -- printObject("list " + type + "(#" + _refId + ")"); -- -- _state = VALUE; -- -- return this; -- } -- else if (_state == LENGTH) { -- _state = VALUE; -- -- return this; -- } -- else -- return this; -- } -- -- @Override -- int depth() -- { -- if (_state <= LENGTH) -- return _next.depth(); -- else if (_state == VALUE) -- return _valueDepth; -- else -- return _next.depth() + 2; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- return nextObject(ch); -- -- case VALUE: -- if (ch == 'Z') { -- if (_count > 0) -- println(); -- -- return _next; -- } -- else { -- _valueDepth = _next.depth() + 2; -- println(); -- printObject(_count++ + ": "); -- _valueDepth = _column; -- _isObject = false; -- -- return nextObject(ch); -- } -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class CompactListState extends State { -- private static final int TYPE = 0; -- private static final int LENGTH = 1; -- private static final int VALUE = 2; -- -- private int _refId; -- -- private boolean _isTyped; -- private boolean _isLength; -- -- private int _state; -- private int _length; -- private int _count; -- private int _valueDepth; -- -- CompactListState(State next, int refId, boolean isTyped) -- { -- super(next); -- -- _isTyped = isTyped; -- _refId = refId; -- -- if (isTyped) -- _state = TYPE; -- else -- _state = LENGTH; -- } -- -- CompactListState(State next, int refId, boolean isTyped, int length) -- { -- super(next); -- -- _isTyped = isTyped; -- _refId = refId; -- _length = length; -- -- _isLength = true; -- -- if (isTyped) -- _state = TYPE; -- else { -- printObject("list (#" + _refId + ")"); -- -- _state = VALUE; -- } -- } -- -- @Override -- boolean isShift(Object value) -- { -- return _state == TYPE || _state == LENGTH; -- } -- -- @Override -- State shift(Object object) -- { -- if (_state == TYPE) { -- Object type = object; -- -- if (object instanceof Integer) { -- int index = (Integer) object; -- -- if (index >= 0 && index < _typeDefList.size()) -- type = _typeDefList.get(index); -- else -- type = "type-unknown(" + index + ")"; -- } -- else if (object instanceof String) -- _typeDefList.add((String) object); -- -- printObject("list " + type + " (#" + _refId + ")"); -- -- if (_isLength) { -- _state = VALUE; -- -- if (_length == 0) -- return _next; -- } -- else -- _state = LENGTH; -- -- return this; -- } -- else if (_state == LENGTH) { -- _length = (Integer) object; -- -- if (! _isTyped) -- printObject("list (#" + _refId + ")"); -- -- _state = VALUE; -- -- if (_length == 0) -- return _next; -- else -- return this; -- } -- else -- return this; -- } -- -- @Override -- int depth() -- { -- if (_state <= LENGTH) -- return _next.depth(); -- else if (_state == VALUE) -- return _valueDepth; -- else -- return _next.depth() + 2; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- return nextObject(ch); -- -- case LENGTH: -- return nextObject(ch); -- -- case VALUE: -- if (_length <= _count) -- return _next.next(ch); -- else { -- _valueDepth = _next.depth() + 2; -- println(); -- printObject(_count++ + ": "); -- _valueDepth = _column; -- _isObject = false; -- -- return nextObject(ch); -- } -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class Hessian2State extends State { -- private static final int MAJOR = 0; -- private static final int MINOR = 1; -- -- private int _state; -- private int _major; -- private int _minor; -- -- Hessian2State(State next) -- { -- super(next); -- } -- -- int depth() -- { -- return _next.depth() + 2; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case MAJOR: -- _major = ch; -- _state = MINOR; -- return this; -- -- case MINOR: -- _minor = ch; -- println(-2, "Hessian " + _major + "." + _minor); -- return _next; -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class CallState1 extends State1 { -- private static final int MAJOR = 0; -- private static final int MINOR = 1; -- private static final int HEADER = 2; -- private static final int METHOD = 3; -- private static final int VALUE = 4; -- private static final int ARG = 5; -- -- private int _state; -- private int _major; -- private int _minor; -- -- CallState1(State next) -- { -- super(next); -- } -- -- int depth() -- { -- return _next.depth() + 2; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case MAJOR: -- _major = ch; -- _state = MINOR; -- return this; -- -- case MINOR: -- _minor = ch; -- _state = HEADER; -- println(-2, "call " + _major + "." + _minor); -- return this; -- -- case HEADER: -- if (ch == 'H') { -- println(); -- print("header "); -- _isObject = false; -- _state = VALUE; -- return new StringState(this, 'H', true); -- } -- else if (ch == 'm') { -- println(); -- print("method "); -- _isObject = false; -- _state = ARG; -- return new StringState(this, 'm', true); -- } -- else { -- println((char) ch + ": unexpected char"); -- return popStack(); -- } -- -- case VALUE: -- print(" => "); -- _isObject = false; -- _state = HEADER; -- return nextObject(ch); -- -- case ARG: -- if (ch == 'z') { -- println(); -- return _next; -- } -- else -- return nextObject(ch); -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class Call2State extends State { -- private static final int METHOD = 0; -- private static final int COUNT = 1; -- private static final int ARG = 2; -- -- private int _state = METHOD; -- private int _i; -- private int _count; -- -- Call2State(State next) -- { -- super(next); -- } -- -- int depth() -- { -- return _next.depth() + 5; -- } -- -- @Override -- boolean isShift(Object value) -- { -- return _state != ARG; -- } -- -- @Override -- State shift(Object object) -- { -- if (_state == METHOD) { -- println(-5, "Call " + object); -- -- _state = COUNT; -- return this; -- } -- else if (_state == COUNT) { -- Integer count = (Integer) object; -- -- _count = count; -- -- _state = ARG; -- -- if (_count == 0) { -- return _next; -- } -- else -- return this; -- } -- else { -- return this; -- } -- } -- -- @Override -- State next(int ch) -- { -- switch (_state) { -- case COUNT: -- return nextObject(ch); -- -- case METHOD: -- return nextObject(ch); -- -- case ARG: -- if (_count <= _i) { -- println(); -- return _next.next(ch); -- } -- else { -- println(); -- print(-3, _i++ + ": "); -- -- return nextObject(ch); -- } -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class ReplyState1 extends State1 { -- private static final int MAJOR = 0; -- private static final int MINOR = 1; -- private static final int HEADER = 2; -- private static final int VALUE = 3; -- private static final int END = 4; -- -- private int _state; -- private int _major; -- private int _minor; -- -- ReplyState1(State next) -- { -- _next = next; -- } -- -- int depth() -- { -- return _next.depth() + 2; -- } -- -- State next(int ch) -- { -- switch (_state) { -- case MAJOR: -- if (ch == 't' || ch == 'S') -- return new RemoteState(this).next(ch); -- -- _major = ch; -- _state = MINOR; -- return this; -- -- case MINOR: -- _minor = ch; -- _state = HEADER; -- println(-2, "reply " + _major + "." + _minor); -- return this; -- -- case HEADER: -- if (ch == 'H') { -- _state = VALUE; -- return new StringState(this, 'H', true); -- } -- else if (ch == 'f') { -- print("fault "); -- _isObject = false; -- _state = END; -- return new MapState(this, 0); -- } -- else { -- _state = END; -- return nextObject(ch); -- } -- -- case VALUE: -- _state = HEADER; -- return nextObject(ch); -- -- case END: -- println(); -- if (ch == 'z') { -- return _next; -- } -- else -- return _next.next(ch); -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class Reply2State extends State { -- Reply2State(State next) -- { -- super(next); -- -- println(-2, "Reply"); -- } -- -- int depth() -- { -- return _next.depth() + 2; -- } -- -- @Override -- State next(int ch) -- { -- if (ch < 0) { -- println(); -- return _next; -- } -- else { -- return nextObject(ch); -- } -- } -- } -- -- class Fault2State extends State { -- Fault2State(State next) -- { -- super(next); -- -- println(-2, "Fault"); -- } -- -- int depth() -- { -- return _next.depth() + 2; -- } -- -- @Override -- State next(int ch) -- { -- return nextObject(ch); -- } -- } -- -- class IndirectState extends State { -- IndirectState(State next) -- { -- super(next); -- } -- -- boolean isShift(Object object) -- { -- return _next.isShift(object); -- } -- -- State shift(Object object) -- { -- return _next.shift(object); -- } -- -- State next(int ch) -- { -- return nextObject(ch); -- } -- } -- -- class RemoteState extends State { -- private static final int TYPE = 0; -- private static final int VALUE = 1; -- private static final int END = 2; -- -- private int _state; -- private int _major; -- private int _minor; -- -- RemoteState(State next) -- { -- super(next); -- } -- -- @Override -- State next(int ch) -- { -- switch (_state) { -- case TYPE: -- println(-1, "remote"); -- if (ch == 't') { -- _state = VALUE; -- return new StringState(this, 't', false); -- } -- else { -- _state = END; -- return nextObject(ch); -- } -- -- case VALUE: -- _state = END; -- return _next.nextObject(ch); -- -- case END: -- return _next.next(ch); -- -- default: -- throw new IllegalStateException(); -- } -- } -- } -- -- class StreamingState extends State { -- private long _length; -- private int _metaLength; -- private boolean _isLast; -- private boolean _isFirst = true; -- -- private boolean _isLengthState; -- -- private State _childState; -- -- StreamingState(State next, boolean isLast) -- { -- super(next); -- -- _isLast = isLast; -- _childState = new InitialState(); -- } -- -- State next(int ch) -- { -- if (_metaLength > 0) { -- _length = 256 * _length + ch; -- _metaLength--; -- -- if (_metaLength == 0 && _isFirst) { -- if (_isLast) -- println(-1, "--- packet-start(" + _length + ")"); -- else -- println(-1, "--- packet-start(fragment)"); -- _isFirst = false; -- } -- -- return this; -- } -- -- if (_length > 0) { -- _length--; -- _childState = _childState.next(ch); -- -- return this; -- } -- -- if (! _isLengthState) { -- _isLengthState = true; -- -- if (_isLast) { -- println(-1, ""); -- println(-1, "--- packet-end"); -- _refId = 0; -- -- _isFirst = true; -- } -- -- _isLast = (ch & 0x80) == 0x00; -- _isLengthState = true; -- } -- else { -- _isLengthState = false; -- _length = (ch & 0x7f); -- -- if (_length == 0x7e) { -- _length = 0; -- _metaLength = 2; -- } -- else if (_length == 0x7f) { -- _length = 0; -- _metaLength = 8; -- } -- else { -- if (_isFirst) { -- if (_isLast) -- println(-1, "--- packet-start(" + _length + ")"); -- else -- println(-1, "--- packet-start(fragment)"); -- _isFirst = false; -- } -- } -- } -- -- return this; -- } -- } -- -- static class ObjectDef { -- private String _type; -- private ArrayList _fields; -- -- ObjectDef(String type, ArrayList fields) -- { -- _type = type; -- _fields = fields; -- } -- -- String getType() -- { -- return _type; -- } -- -- ArrayList getFields() -- { -- return _fields; -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.PrintWriter; -+import java.util.ArrayList; -+import java.util.logging.Logger; -+ -+/** -+ * Debugging input stream for Hessian requests. -+ */ -+public class HessianDebugState implements Hessian2Constants -+{ -+ private static final Logger log -+ = Logger.getLogger(HessianDebugState.class.getName()); -+ -+ private PrintWriter _dbg; -+ -+ private State _state; -+ private ArrayList _stateStack = new ArrayList(); -+ -+ private ArrayList _objectDefList -+ = new ArrayList(); -+ -+ private ArrayList _typeDefList -+ = new ArrayList(); -+ -+ private int _refId; -+ private boolean _isNewline = true; -+ private boolean _isObject = false; -+ private int _column; -+ -+ private int _depth = 0; -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianDebugState(PrintWriter dbg) -+ { -+ _dbg = dbg; -+ -+ _state = new InitialState(); -+ } -+ -+ public void startTop2() -+ { -+ _state = new Top2State(); -+ } -+ -+ public void startData1() -+ { -+ _state = new InitialState1(); -+ } -+ -+ public void startStreaming() -+ { -+ _state = new StreamingState(new InitialState(), false); -+ } -+ -+ /** -+ * Reads a character. -+ */ -+ public void next(int ch) -+ throws IOException -+ { -+ _state = _state.next(ch); -+ } -+ -+ void pushStack(State state) -+ { -+ _stateStack.add(state); -+ } -+ -+ State popStack() -+ { -+ return _stateStack.remove(_stateStack.size() - 1); -+ } -+ -+ public void setDepth(int depth) -+ { -+ _depth = depth; -+ } -+ -+ public int getDepth() -+ { -+ return _depth; -+ } -+ -+ void println() -+ { -+ if (! _isNewline) { -+ _dbg.println(); -+ _dbg.flush(); -+ } -+ -+ _isNewline = true; -+ _column = 0; -+ } -+ -+ static boolean isString(int ch) -+ { -+ switch (ch) { -+ case 0x00: case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ -+ case 'R': -+ case 'S': -+ return true; -+ -+ default: -+ return false; -+ } -+ } -+ -+ static boolean isInteger(int ch) -+ { -+ switch (ch) { -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc8: case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd4: case 0xd5: case 0xd6: case 0xd7: -+ -+ case 'I': -+ return true; -+ -+ default: -+ return false; -+ } -+ } -+ -+ abstract class State { -+ State _next; -+ -+ State() -+ { -+ } -+ -+ State(State next) -+ { -+ _next = next; -+ } -+ -+ abstract State next(int ch); -+ -+ boolean isShift(Object value) -+ { -+ return false; -+ } -+ -+ State shift(Object value) -+ { -+ return this; -+ } -+ -+ int depth() -+ { -+ if (_next != null) -+ return _next.depth(); -+ else -+ return HessianDebugState.this.getDepth(); -+ } -+ -+ void printIndent(int depth) -+ { -+ if (_isNewline) { -+ for (int i = _column; i < depth() + depth; i++) { -+ _dbg.print(" "); -+ _column++; -+ } -+ } -+ } -+ -+ void print(String string) -+ { -+ print(0, string); -+ } -+ -+ void print(int depth, String string) -+ { -+ printIndent(depth); -+ -+ _dbg.print(string); -+ _isNewline = false; -+ _isObject = false; -+ -+ int p = string.lastIndexOf('\n'); -+ if (p > 0) -+ _column = string.length() - p - 1; -+ else -+ _column += string.length(); -+ } -+ -+ void println(String string) -+ { -+ println(0, string); -+ } -+ -+ void println(int depth, String string) -+ { -+ printIndent(depth); -+ -+ _dbg.println(string); -+ _dbg.flush(); -+ _isNewline = true; -+ _isObject = false; -+ _column = 0; -+ } -+ -+ void println() -+ { -+ if (! _isNewline) { -+ _dbg.println(); -+ _dbg.flush(); -+ } -+ -+ _isNewline = true; -+ _isObject = false; -+ _column = 0; -+ } -+ -+ void printObject(String string) -+ { -+ if (_isObject) -+ println(); -+ -+ printIndent(0); -+ -+ _dbg.print(string); -+ _dbg.flush(); -+ -+ _column += string.length(); -+ -+ _isNewline = false; -+ _isObject = true; -+ } -+ -+ protected State nextObject(int ch) -+ { -+ switch (ch) { -+ case -1: -+ println(); -+ return this; -+ -+ case 'N': -+ if (isShift(null)) -+ return shift(null); -+ else { -+ printObject("null"); -+ return this; -+ } -+ -+ case 'T': -+ if (isShift(Boolean.TRUE)) -+ return shift(Boolean.TRUE); -+ else { -+ printObject("true"); -+ return this; -+ } -+ -+ case 'F': -+ if (isShift(Boolean.FALSE)) -+ return shift(Boolean.FALSE); -+ else { -+ printObject("false"); -+ return this; -+ } -+ -+ case 0x80: case 0x81: case 0x82: case 0x83: -+ case 0x84: case 0x85: case 0x86: case 0x87: -+ case 0x88: case 0x89: case 0x8a: case 0x8b: -+ case 0x8c: case 0x8d: case 0x8e: case 0x8f: -+ -+ case 0x90: case 0x91: case 0x92: case 0x93: -+ case 0x94: case 0x95: case 0x96: case 0x97: -+ case 0x98: case 0x99: case 0x9a: case 0x9b: -+ case 0x9c: case 0x9d: case 0x9e: case 0x9f: -+ -+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: -+ case 0xa4: case 0xa5: case 0xa6: case 0xa7: -+ case 0xa8: case 0xa9: case 0xaa: case 0xab: -+ case 0xac: case 0xad: case 0xae: case 0xaf: -+ -+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: -+ case 0xb4: case 0xb5: case 0xb6: case 0xb7: -+ case 0xb8: case 0xb9: case 0xba: case 0xbb: -+ case 0xbc: case 0xbd: case 0xbe: case 0xbf: -+ { -+ Integer value = new Integer(ch - 0x90); -+ -+ if (isShift(value)) -+ return shift(value); -+ else { -+ printObject(value.toString()); -+ return this; -+ } -+ } -+ -+ case 0xc0: case 0xc1: case 0xc2: case 0xc3: -+ case 0xc4: case 0xc5: case 0xc6: case 0xc7: -+ case 0xc8: case 0xc9: case 0xca: case 0xcb: -+ case 0xcc: case 0xcd: case 0xce: case 0xcf: -+ return new IntegerState(this, "int", ch - 0xc8, 3); -+ -+ case 0xd0: case 0xd1: case 0xd2: case 0xd3: -+ case 0xd4: case 0xd5: case 0xd6: case 0xd7: -+ return new IntegerState(this, "int", ch - 0xd4, 2); -+ -+ case 'I': -+ return new IntegerState(this, "int"); -+ -+ case 0xd8: case 0xd9: case 0xda: case 0xdb: -+ case 0xdc: case 0xdd: case 0xde: case 0xdf: -+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: -+ case 0xe4: case 0xe5: case 0xe6: case 0xe7: -+ case 0xe8: case 0xe9: case 0xea: case 0xeb: -+ case 0xec: case 0xed: case 0xee: case 0xef: -+ { -+ Long value = new Long(ch - 0xe0); -+ -+ if (isShift(value)) -+ return shift(value); -+ else { -+ printObject(value.toString() + "L"); -+ return this; -+ } -+ } -+ -+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: -+ case 0xf4: case 0xf5: case 0xf6: case 0xf7: -+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: -+ case 0xfc: case 0xfd: case 0xfe: case 0xff: -+ return new LongState(this, "long", ch - 0xf8, 7); -+ -+ case 0x38: case 0x39: case 0x3a: case 0x3b: -+ case 0x3c: case 0x3d: case 0x3e: case 0x3f: -+ return new LongState(this, "long", ch - 0x3c, 6); -+ -+ case BC_LONG_INT: -+ return new LongState(this, "long", 0, 4); -+ -+ case 'L': -+ return new LongState(this, "long"); -+ -+ case 0x5b: case 0x5c: -+ { -+ Double value = new Double(ch - 0x5b); -+ -+ if (isShift(value)) -+ return shift(value); -+ else { -+ printObject(value.toString()); -+ return this; -+ } -+ } -+ -+ case 0x5d: -+ return new DoubleIntegerState(this, 3); -+ -+ case 0x5e: -+ return new DoubleIntegerState(this, 2); -+ -+ case 0x5f: -+ return new MillsState(this); -+ -+ case 'D': -+ return new DoubleState(this); -+ -+ case 'Q': -+ return new RefState(this); -+ -+ case BC_DATE: -+ return new DateState(this); -+ -+ case BC_DATE_MINUTE: -+ return new DateState(this, true); -+ -+ case 0x00: -+ { -+ String value = "\"\""; -+ -+ if (isShift(value)) -+ return shift(value); -+ else { -+ printObject(value.toString()); -+ return this; -+ } -+ } -+ -+ case 0x01: case 0x02: case 0x03: -+ case 0x04: case 0x05: case 0x06: case 0x07: -+ case 0x08: case 0x09: case 0x0a: case 0x0b: -+ case 0x0c: case 0x0d: case 0x0e: case 0x0f: -+ -+ case 0x10: case 0x11: case 0x12: case 0x13: -+ case 0x14: case 0x15: case 0x16: case 0x17: -+ case 0x18: case 0x19: case 0x1a: case 0x1b: -+ case 0x1c: case 0x1d: case 0x1e: case 0x1f: -+ return new StringState(this, 'S', ch); -+ -+ case 0x30: case 0x31: case 0x32: case 0x33: -+ return new StringState(this, 'S', ch - 0x30, true); -+ -+ case 'R': -+ return new StringState(this, 'S', false); -+ -+ case 'S': -+ return new StringState(this, 'S', true); -+ -+ case 0x20: -+ { -+ String value = "binary(0)"; -+ -+ if (isShift(value)) -+ return shift(value); -+ else { -+ printObject(value.toString()); -+ return this; -+ } -+ } -+ -+ case 0x21: case 0x22: case 0x23: -+ case 0x24: case 0x25: case 0x26: case 0x27: -+ case 0x28: case 0x29: case 0x2a: case 0x2b: -+ case 0x2c: case 0x2d: case 0x2e: case 0x2f: -+ return new BinaryState(this, 'B', ch - 0x20); -+ -+ case 0x34: case 0x35: case 0x36: case 0x37: -+ return new BinaryState(this, 'B', ch - 0x34, true); -+ -+ case 'A': -+ return new BinaryState(this, 'B', false); -+ -+ case 'B': -+ return new BinaryState(this, 'B', true); -+ -+ case 'M': -+ return new MapState(this, _refId++); -+ -+ case 'H': -+ return new MapState(this, _refId++, false); -+ -+ case BC_LIST_VARIABLE: -+ return new ListState(this, _refId++, true); -+ -+ case BC_LIST_VARIABLE_UNTYPED: -+ return new ListState(this, _refId++, false); -+ -+ case BC_LIST_FIXED: -+ return new CompactListState(this, _refId++, true); -+ -+ case BC_LIST_FIXED_UNTYPED: -+ return new CompactListState(this, _refId++, false); -+ -+ case 0x70: case 0x71: case 0x72: case 0x73: -+ case 0x74: case 0x75: case 0x76: case 0x77: -+ return new CompactListState(this, _refId++, true, ch - 0x70); -+ -+ case 0x78: case 0x79: case 0x7a: case 0x7b: -+ case 0x7c: case 0x7d: case 0x7e: case 0x7f: -+ return new CompactListState(this, _refId++, false, ch - 0x78); -+ -+ case 'C': -+ return new ObjectDefState(this); -+ -+ case 0x60: case 0x61: case 0x62: case 0x63: -+ case 0x64: case 0x65: case 0x66: case 0x67: -+ case 0x68: case 0x69: case 0x6a: case 0x6b: -+ case 0x6c: case 0x6d: case 0x6e: case 0x6f: -+ return new ObjectState(this, _refId++, ch - 0x60); -+ -+ case 'O': -+ return new ObjectState(this, _refId++); -+ -+ default: -+ return this; -+ } -+ } -+ } -+ -+ abstract class State1 extends State { -+ State1() -+ { -+ } -+ -+ State1(State next) -+ { -+ super(next); -+ } -+ -+ protected State nextObject(int ch) -+ { -+ switch (ch) { -+ case -1: -+ println(); -+ return this; -+ -+ case 'N': -+ if (isShift(null)) -+ return shift(null); -+ else { -+ printObject("null"); -+ return this; -+ } -+ -+ case 'T': -+ if (isShift(Boolean.TRUE)) -+ return shift(Boolean.TRUE); -+ else { -+ printObject("true"); -+ return this; -+ } -+ -+ case 'F': -+ if (isShift(Boolean.FALSE)) -+ return shift(Boolean.FALSE); -+ else { -+ printObject("false"); -+ return this; -+ } -+ -+ case 'I': -+ return new IntegerState(this, "int"); -+ -+ case 'L': -+ return new LongState(this, "long"); -+ -+ case 'D': -+ return new DoubleState(this); -+ -+ case 'Q': -+ return new RefState(this); -+ -+ case 'd': -+ return new DateState(this); -+ -+ case 's': -+ return new StringState(this, 'S', false); -+ -+ case 'S': -+ return new StringState(this, 'S', true); -+ -+ case 'b': -+ case 'A': -+ return new BinaryState(this, 'B', false); -+ -+ case 'B': -+ return new BinaryState(this, 'B', true); -+ -+ case 'M': -+ return new MapState1(this, _refId++); -+ -+ case 'V': -+ return new ListState1(this, _refId++); -+ -+ case 'R': -+ return new IntegerState(new RefState1(this), "ref"); -+ -+ default: -+ printObject("x" + String.format("%02x", ch)); -+ return this; -+ } -+ } -+ } -+ -+ class InitialState extends State { -+ State next(int ch) -+ { -+ return nextObject(ch); -+ } -+ } -+ -+ class InitialState1 extends State1 { -+ State next(int ch) -+ { -+ return nextObject(ch); -+ } -+ } -+ -+ class Top1State extends State1 { -+ State next(int ch) -+ { -+ println(); -+ -+ if (ch == 'r') { -+ return new ReplyState1(this); -+ } -+ else if (ch == 'c') { -+ return new CallState1(this); -+ } -+ else -+ return nextObject(ch); -+ } -+ } -+ -+ class Top2State extends State { -+ State next(int ch) -+ { -+ println(); -+ -+ if (ch == 'R') { -+ return new Reply2State(this); -+ } -+ else if (ch == 'F') { -+ return new Fault2State(this); -+ } -+ else if (ch == 'C') { -+ return new Call2State(this); -+ } -+ else if (ch == 'H') { -+ return new Hessian2State(this); -+ } -+ else if (ch == 'r') { -+ return new ReplyState1(this); -+ } -+ else if (ch == 'c') { -+ return new CallState1(this); -+ } -+ else -+ return nextObject(ch); -+ } -+ } -+ -+ class IntegerState extends State { -+ String _typeCode; -+ -+ int _length; -+ int _value; -+ -+ IntegerState(State next, String typeCode) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ } -+ -+ IntegerState(State next, String typeCode, int value, int length) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ -+ _value = value; -+ _length = length; -+ } -+ -+ State next(int ch) -+ { -+ _value = 256 * _value + (ch & 0xff); -+ -+ if (++_length == 4) { -+ Integer value = new Integer(_value); -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value.toString()); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class LongState extends State { -+ String _typeCode; -+ -+ int _length; -+ long _value; -+ -+ LongState(State next, String typeCode) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ } -+ -+ LongState(State next, String typeCode, long value, int length) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ -+ _value = value; -+ _length = length; -+ } -+ -+ State next(int ch) -+ { -+ _value = 256 * _value + (ch & 0xff); -+ -+ if (++_length == 8) { -+ Long value = new Long(_value); -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value.toString() + "L"); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class DoubleIntegerState extends State { -+ int _length; -+ int _value; -+ boolean _isFirst = true; -+ -+ DoubleIntegerState(State next, int length) -+ { -+ super(next); -+ -+ _length = length; -+ } -+ -+ State next(int ch) -+ { -+ if (_isFirst) -+ _value = (byte) ch; -+ else -+ _value = 256 * _value + (ch & 0xff); -+ -+ _isFirst = false; -+ -+ if (++_length == 4) { -+ Double value = new Double(_value); -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value.toString()); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class RefState extends State { -+ String _typeCode; -+ -+ int _length; -+ int _value; -+ -+ RefState(State next) -+ { -+ super(next); -+ } -+ -+ RefState(State next, String typeCode) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ } -+ -+ RefState(State next, String typeCode, int value, int length) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ -+ _value = value; -+ _length = length; -+ } -+ -+ @Override -+ boolean isShift(Object o) -+ { -+ return true; -+ } -+ -+ @Override -+ State shift(Object o) -+ { -+ println("ref #" + o); -+ -+ return _next; -+ } -+ -+ @Override -+ State next(int ch) -+ { -+ return nextObject(ch); -+ } -+ } -+ -+ class RefState1 extends State { -+ String _typeCode; -+ -+ RefState1(State next) -+ { -+ super(next); -+ } -+ -+ @Override -+ boolean isShift(Object o) -+ { -+ return true; -+ } -+ -+ @Override -+ State shift(Object o) -+ { -+ println("ref #" + o); -+ -+ return _next; -+ } -+ -+ @Override -+ State next(int ch) -+ { -+ return nextObject(ch); -+ } -+ } -+ -+ class DateState extends State { -+ int _length; -+ long _value; -+ boolean _isMinute; -+ -+ DateState(State next) -+ { -+ super(next); -+ } -+ -+ DateState(State next, boolean isMinute) -+ { -+ super(next); -+ -+ _length = 4; -+ _isMinute = isMinute; -+ } -+ -+ -+ State next(int ch) -+ { -+ _value = 256 * _value + (ch & 0xff); -+ -+ if (++_length == 8) { -+ java.util.Date value; -+ -+ if (_isMinute) -+ value = new java.util.Date(_value * 60000L); -+ else -+ value = new java.util.Date(_value); -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value.toString()); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class DoubleState extends State { -+ int _length; -+ long _value; -+ -+ DoubleState(State next) -+ { -+ super(next); -+ } -+ -+ State next(int ch) -+ { -+ _value = 256 * _value + (ch & 0xff); -+ -+ if (++_length == 8) { -+ Double value = Double.longBitsToDouble(_value); -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value.toString()); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class MillsState extends State { -+ int _length; -+ int _value; -+ -+ MillsState(State next) -+ { -+ super(next); -+ } -+ -+ State next(int ch) -+ { -+ _value = 256 * _value + (ch & 0xff); -+ -+ if (++_length == 4) { -+ Double value = 0.001 * _value; -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value.toString()); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class StringState extends State { -+ private static final int TOP = 0; -+ private static final int UTF_2_1 = 1; -+ private static final int UTF_3_1 = 2; -+ private static final int UTF_3_2 = 3; -+ -+ char _typeCode; -+ -+ StringBuilder _value = new StringBuilder(); -+ int _lengthIndex; -+ int _length; -+ boolean _isLastChunk; -+ -+ int _utfState; -+ char _ch; -+ -+ StringState(State next, char typeCode, boolean isLastChunk) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ _isLastChunk = isLastChunk; -+ } -+ -+ StringState(State next, char typeCode, int length) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ _isLastChunk = true; -+ _length = length; -+ _lengthIndex = 2; -+ } -+ -+ StringState(State next, char typeCode, int length, boolean isLastChunk) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ _isLastChunk = isLastChunk; -+ _length = length; -+ _lengthIndex = 1; -+ } -+ -+ State next(int ch) -+ { -+ if (_lengthIndex < 2) { -+ _length = 256 * _length + (ch & 0xff); -+ -+ if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { -+ if (_next.isShift(_value.toString())) -+ return _next.shift(_value.toString()); -+ else { -+ printObject("\"" + _value + "\""); -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ else if (_length == 0) { -+ if (ch == 's' || ch == 'x') { -+ _isLastChunk = false; -+ _lengthIndex = 0; -+ return this; -+ } -+ else if (ch == 'S' || ch == 'X') { -+ _isLastChunk = true; -+ _lengthIndex = 0; -+ return this; -+ } -+ else if (ch == 0x00) { -+ if (_next.isShift(_value.toString())) -+ return _next.shift(_value.toString()); -+ else { -+ printObject("\"" + _value + "\""); -+ return _next; -+ } -+ } -+ else if (0x00 <= ch && ch < 0x20) { -+ _isLastChunk = true; -+ _lengthIndex = 2; -+ _length = ch & 0xff; -+ return this; -+ } -+ else if (0x30 <= ch && ch < 0x34) { -+ _isLastChunk = true; -+ _lengthIndex = 1; -+ _length = (ch - 0x30); -+ return this; -+ } -+ else { -+ println(this + " " + String.valueOf((char) ch) + ": unexpected character"); -+ return _next; -+ } -+ } -+ -+ switch (_utfState) { -+ case TOP: -+ if (ch < 0x80) { -+ _length--; -+ -+ _value.append((char) ch); -+ } -+ else if (ch < 0xe0) { -+ _ch = (char) ((ch & 0x1f) << 6); -+ _utfState = UTF_2_1; -+ } -+ else { -+ _ch = (char) ((ch & 0xf) << 12); -+ _utfState = UTF_3_1; -+ } -+ break; -+ -+ case UTF_2_1: -+ case UTF_3_2: -+ _ch += ch & 0x3f; -+ _value.append(_ch); -+ _length--; -+ _utfState = TOP; -+ break; -+ -+ case UTF_3_1: -+ _ch += (char) ((ch & 0x3f) << 6); -+ _utfState = UTF_3_2; -+ break; -+ } -+ -+ if (_length == 0 && _isLastChunk) { -+ if (_next.isShift(_value.toString())) -+ return _next.shift(_value.toString()); -+ else { -+ printObject("\"" + _value + "\""); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class BinaryState extends State { -+ char _typeCode; -+ -+ int _totalLength; -+ -+ int _lengthIndex; -+ int _length; -+ boolean _isLastChunk; -+ -+ BinaryState(State next, char typeCode, boolean isLastChunk) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ _isLastChunk = isLastChunk; -+ } -+ -+ BinaryState(State next, char typeCode, int length) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ _isLastChunk = true; -+ _length = length; -+ _lengthIndex = 2; -+ } -+ -+ BinaryState(State next, char typeCode, int length, boolean isLastChunk) -+ { -+ super(next); -+ -+ _typeCode = typeCode; -+ _isLastChunk = isLastChunk; -+ _length = length; -+ _lengthIndex = 1; -+ } -+ -+ @Override -+ State next(int ch) -+ { -+ if (_lengthIndex < 2) { -+ _length = 256 * _length + (ch & 0xff); -+ -+ if (++_lengthIndex == 2 && _length == 0 && _isLastChunk) { -+ String value = "binary(" + _totalLength + ")"; -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value); -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ else if (_length == 0) { -+ if (ch == 'b' || ch == 'A') { -+ _isLastChunk = false; -+ _lengthIndex = 0; -+ return this; -+ } -+ else if (ch == 'B') { -+ _isLastChunk = true; -+ _lengthIndex = 0; -+ return this; -+ } -+ else if (ch == 0x20) { -+ String value = "binary(" + _totalLength + ")"; -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value); -+ return _next; -+ } -+ } -+ else if (0x20 <= ch && ch < 0x30) { -+ _isLastChunk = true; -+ _lengthIndex = 2; -+ _length = (ch & 0xff) - 0x20; -+ return this; -+ } -+ else { -+ println(this + " 0x" + Integer.toHexString(ch) + " " + String.valueOf((char) ch) + ": unexpected character"); -+ return _next; -+ } -+ } -+ -+ _length--; -+ _totalLength++; -+ -+ if (_length == 0 && _isLastChunk) { -+ String value = "binary(" + _totalLength + ")"; -+ -+ if (_next.isShift(value)) -+ return _next.shift(value); -+ else { -+ printObject(value); -+ -+ return _next; -+ } -+ } -+ else -+ return this; -+ } -+ } -+ -+ class MapState extends State { -+ private static final int TYPE = 0; -+ private static final int KEY = 1; -+ private static final int VALUE = 2; -+ -+ private int _refId; -+ -+ private int _state; -+ private int _valueDepth; -+ private boolean _hasData; -+ -+ MapState(State next, int refId) -+ { -+ super(next); -+ -+ _refId = refId; -+ _state = TYPE; -+ } -+ -+ MapState(State next, int refId, boolean isType) -+ { -+ super(next); -+ -+ _refId = refId; -+ -+ if (isType) -+ _state = TYPE; -+ else { -+ printObject("map (#" + _refId + ")"); -+ _state = VALUE; -+ } -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ return _state == TYPE; -+ } -+ -+ @Override -+ State shift(Object type) -+ { -+ if (_state == TYPE) { -+ if (type instanceof String) { -+ _typeDefList.add((String) type); -+ } -+ else if (type instanceof Integer) { -+ int iValue = (Integer) type; -+ -+ if (iValue >= 0 && iValue < _typeDefList.size()) -+ type = _typeDefList.get(iValue); -+ } -+ -+ printObject("map " + type + " (#" + _refId + ")"); -+ -+ _state = VALUE; -+ -+ return this; -+ } -+ else { -+ printObject(this + " unknown shift state= " + _state + " type=" + type); -+ -+ return this; -+ } -+ } -+ -+ @Override -+ int depth() -+ { -+ if (_state == TYPE) -+ return _next.depth(); -+ else if (_state == KEY) -+ return _next.depth() + 2; -+ else -+ return _valueDepth; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ return nextObject(ch); -+ -+ case VALUE: -+ if (ch == 'Z') { -+ if (_hasData) -+ println(); -+ -+ return _next; -+ } -+ else { -+ if (_hasData) -+ println(); -+ -+ _hasData = true; -+ _state = KEY; -+ -+ return nextObject(ch); -+ } -+ -+ case KEY: -+ print(" => "); -+ _isObject = false; -+ _valueDepth = _column; -+ -+ _state = VALUE; -+ -+ return nextObject(ch); -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class MapState1 extends State1 { -+ private static final int TYPE = 0; -+ private static final int KEY = 1; -+ private static final int VALUE = 2; -+ -+ private int _refId; -+ -+ private int _state; -+ private int _valueDepth; -+ private boolean _hasData; -+ -+ MapState1(State next, int refId) -+ { -+ super(next); -+ -+ _refId = refId; -+ _state = TYPE; -+ } -+ -+ MapState1(State next, int refId, boolean isType) -+ { -+ super(next); -+ -+ _refId = refId; -+ -+ if (isType) -+ _state = TYPE; -+ else { -+ printObject("map (#" + _refId + ")"); -+ _state = VALUE; -+ } -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ return _state == TYPE; -+ } -+ -+ @Override -+ State shift(Object type) -+ { -+ if (_state == TYPE) { -+ if (type instanceof String) { -+ _typeDefList.add((String) type); -+ } -+ else if (type instanceof Integer) { -+ int iValue = (Integer) type; -+ -+ if (iValue >= 0 && iValue < _typeDefList.size()) -+ type = _typeDefList.get(iValue); -+ } -+ -+ printObject("map " + type + " (#" + _refId + ")"); -+ -+ _state = VALUE; -+ -+ return this; -+ } -+ else -+ throw new IllegalStateException(); -+ } -+ -+ @Override -+ int depth() -+ { -+ if (_state == TYPE) -+ return _next.depth(); -+ else if (_state == KEY) -+ return _next.depth() + 2; -+ else -+ return _valueDepth; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ if (ch == 't') { -+ return new StringState(this, 't', true); -+ } -+ else if (ch == 'z') { -+ println("map (#" + _refId + ")"); -+ return _next; -+ } -+ else { -+ println("map (#" + _refId + ")"); -+ _hasData = true; -+ _state = KEY; -+ return nextObject(ch); -+ } -+ -+ case VALUE: -+ if (ch == 'z') { -+ if (_hasData) -+ println(); -+ -+ return _next; -+ } -+ else { -+ if (_hasData) -+ println(); -+ -+ _hasData = true; -+ _state = KEY; -+ -+ return nextObject(ch); -+ } -+ -+ case KEY: -+ print(" => "); -+ _isObject = false; -+ _valueDepth = _column; -+ -+ _state = VALUE; -+ -+ return nextObject(ch); -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class ObjectDefState extends State { -+ private static final int TYPE = 1; -+ private static final int COUNT = 2; -+ private static final int FIELD = 3; -+ private static final int COMPLETE = 4; -+ -+ private int _state; -+ private int _count; -+ -+ private String _type; -+ private ArrayList _fields = new ArrayList(); -+ -+ ObjectDefState(State next) -+ { -+ super(next); -+ -+ _state = TYPE; -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ return true; -+ } -+ -+ @Override -+ State shift(Object object) -+ { -+ if (_state == TYPE) { -+ _type = (String) object; -+ -+ print("/* defun " + _type + " ["); -+ -+ _objectDefList.add(new ObjectDef(_type, _fields)); -+ -+ _state = COUNT; -+ } -+ else if (_state == COUNT) { -+ _count = (Integer) object; -+ -+ _state = FIELD; -+ } -+ else if (_state == FIELD) { -+ String field = (String) object; -+ -+ _count--; -+ -+ _fields.add(field); -+ -+ if (_fields.size() == 1) -+ print(field); -+ else -+ print(", " + field); -+ } -+ else { -+ throw new UnsupportedOperationException(); -+ } -+ -+ return this; -+ } -+ -+ @Override -+ int depth() -+ { -+ if (_state <= TYPE) -+ return _next.depth(); -+ else -+ return _next.depth() + 2; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ return nextObject(ch); -+ -+ case COUNT: -+ return nextObject(ch); -+ -+ case FIELD: -+ if (_count == 0) { -+ println("] */"); -+ _next.printIndent(0); -+ -+ return _next.nextObject(ch); -+ } -+ else -+ return nextObject(ch); -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class ObjectState extends State { -+ private static final int TYPE = 0; -+ private static final int FIELD = 1; -+ -+ private int _refId; -+ -+ private int _state; -+ private ObjectDef _def; -+ private int _count; -+ private int _fieldDepth; -+ -+ ObjectState(State next, int refId) -+ { -+ super(next); -+ -+ _refId = refId; -+ _state = TYPE; -+ } -+ -+ ObjectState(State next, int refId, int def) -+ { -+ super(next); -+ -+ _refId = refId; -+ _state = FIELD; -+ -+ if (def < 0 || _objectDefList.size() <= def) { -+ log.warning(this + " " + def + " is an unknown object type"); -+ -+ println(this + " object unknown (#" + _refId + ")"); -+ } -+ -+ _def = _objectDefList.get(def); -+ -+ if (_isObject) -+ println(); -+ -+ println("object " + _def.getType() + " (#" + _refId + ")"); -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ if (_state == TYPE) -+ return true; -+ else -+ return false; -+ } -+ -+ @Override -+ State shift(Object object) -+ { -+ if (_state == TYPE) { -+ int def = (Integer) object; -+ -+ _def = _objectDefList.get(def); -+ -+ println("object " + _def.getType() + " (#" + _refId + ")"); -+ -+ _state = FIELD; -+ -+ if (_def.getFields().size() == 0) -+ return _next; -+ } -+ -+ return this; -+ } -+ -+ @Override -+ int depth() -+ { -+ if (_state <= TYPE) -+ return _next.depth(); -+ else -+ return _fieldDepth; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ return nextObject(ch); -+ -+ case FIELD: -+ if (_def.getFields().size() <= _count) -+ return _next.next(ch); -+ -+ _fieldDepth = _next.depth() + 2; -+ println(); -+ print(_def.getFields().get(_count++) + ": "); -+ -+ _fieldDepth = _column; -+ -+ _isObject = false; -+ return nextObject(ch); -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class ListState1 extends State1 { -+ private static final int TYPE = 0; -+ private static final int LENGTH = 1; -+ private static final int VALUE = 2; -+ -+ private int _refId; -+ -+ private int _state; -+ private int _count; -+ private int _valueDepth; -+ -+ ListState1(State next, int refId) -+ { -+ super(next); -+ -+ _refId = refId; -+ -+ _state = TYPE; -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ return _state == TYPE || _state == LENGTH; -+ } -+ -+ @Override -+ State shift(Object object) -+ { -+ if (_state == TYPE) { -+ Object type = object; -+ -+ if (type instanceof String) { -+ _typeDefList.add((String) type); -+ } -+ else if (object instanceof Integer) { -+ int index = (Integer) object; -+ -+ if (index >= 0 && index < _typeDefList.size()) -+ type = _typeDefList.get(index); -+ else -+ type = "type-unknown(" + index + ")"; -+ } -+ -+ printObject("list " + type + "(#" + _refId + ")"); -+ -+ _state = VALUE; -+ -+ return this; -+ } -+ else if (_state == LENGTH) { -+ _state = VALUE; -+ -+ return this; -+ } -+ else -+ return this; -+ } -+ -+ @Override -+ int depth() -+ { -+ if (_state <= LENGTH) -+ return _next.depth(); -+ else if (_state == VALUE) -+ return _valueDepth; -+ else -+ return _next.depth() + 2; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ if (ch == 'z') { -+ printObject("list (#" + _refId + ")"); -+ -+ return _next; -+ } -+ else if (ch == 't') { -+ return new StringState(this, 't', true); -+ } -+ else { -+ printObject("list (#" + _refId + ")"); -+ printObject(" " + _count++ + ": "); -+ _valueDepth = _column; -+ _isObject = false; -+ _state = VALUE; -+ -+ return nextObject(ch); -+ } -+ -+ case VALUE: -+ if (ch == 'z') { -+ if (_count > 0) -+ println(); -+ -+ return _next; -+ } -+ else { -+ _valueDepth = _next.depth() + 2; -+ println(); -+ printObject(_count++ + ": "); -+ _valueDepth = _column; -+ _isObject = false; -+ -+ return nextObject(ch); -+ } -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class ListState extends State { -+ private static final int TYPE = 0; -+ private static final int LENGTH = 1; -+ private static final int VALUE = 2; -+ -+ private int _refId; -+ -+ private int _state; -+ private int _count; -+ private int _valueDepth; -+ -+ ListState(State next, int refId, boolean isType) -+ { -+ super(next); -+ -+ _refId = refId; -+ -+ if (isType) -+ _state = TYPE; -+ else { -+ printObject("list (#" + _refId + ")"); -+ _state = VALUE; -+ } -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ return _state == TYPE || _state == LENGTH; -+ } -+ -+ @Override -+ State shift(Object object) -+ { -+ if (_state == TYPE) { -+ Object type = object; -+ -+ if (type instanceof String) { -+ _typeDefList.add((String) type); -+ } -+ else if (object instanceof Integer) { -+ int index = (Integer) object; -+ -+ if (index >= 0 && index < _typeDefList.size()) -+ type = _typeDefList.get(index); -+ else -+ type = "type-unknown(" + index + ")"; -+ } -+ -+ printObject("list " + type + "(#" + _refId + ")"); -+ -+ _state = VALUE; -+ -+ return this; -+ } -+ else if (_state == LENGTH) { -+ _state = VALUE; -+ -+ return this; -+ } -+ else -+ return this; -+ } -+ -+ @Override -+ int depth() -+ { -+ if (_state <= LENGTH) -+ return _next.depth(); -+ else if (_state == VALUE) -+ return _valueDepth; -+ else -+ return _next.depth() + 2; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ return nextObject(ch); -+ -+ case VALUE: -+ if (ch == 'Z') { -+ if (_count > 0) -+ println(); -+ -+ return _next; -+ } -+ else { -+ _valueDepth = _next.depth() + 2; -+ println(); -+ printObject(_count++ + ": "); -+ _valueDepth = _column; -+ _isObject = false; -+ -+ return nextObject(ch); -+ } -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class CompactListState extends State { -+ private static final int TYPE = 0; -+ private static final int LENGTH = 1; -+ private static final int VALUE = 2; -+ -+ private int _refId; -+ -+ private boolean _isTyped; -+ private boolean _isLength; -+ -+ private int _state; -+ private int _length; -+ private int _count; -+ private int _valueDepth; -+ -+ CompactListState(State next, int refId, boolean isTyped) -+ { -+ super(next); -+ -+ _isTyped = isTyped; -+ _refId = refId; -+ -+ if (isTyped) -+ _state = TYPE; -+ else -+ _state = LENGTH; -+ } -+ -+ CompactListState(State next, int refId, boolean isTyped, int length) -+ { -+ super(next); -+ -+ _isTyped = isTyped; -+ _refId = refId; -+ _length = length; -+ -+ _isLength = true; -+ -+ if (isTyped) -+ _state = TYPE; -+ else { -+ printObject("list (#" + _refId + ")"); -+ -+ _state = VALUE; -+ } -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ return _state == TYPE || _state == LENGTH; -+ } -+ -+ @Override -+ State shift(Object object) -+ { -+ if (_state == TYPE) { -+ Object type = object; -+ -+ if (object instanceof Integer) { -+ int index = (Integer) object; -+ -+ if (index >= 0 && index < _typeDefList.size()) -+ type = _typeDefList.get(index); -+ else -+ type = "type-unknown(" + index + ")"; -+ } -+ else if (object instanceof String) -+ _typeDefList.add((String) object); -+ -+ printObject("list " + type + " (#" + _refId + ")"); -+ -+ if (_isLength) { -+ _state = VALUE; -+ -+ if (_length == 0) -+ return _next; -+ } -+ else -+ _state = LENGTH; -+ -+ return this; -+ } -+ else if (_state == LENGTH) { -+ _length = (Integer) object; -+ -+ if (! _isTyped) -+ printObject("list (#" + _refId + ")"); -+ -+ _state = VALUE; -+ -+ if (_length == 0) -+ return _next; -+ else -+ return this; -+ } -+ else -+ return this; -+ } -+ -+ @Override -+ int depth() -+ { -+ if (_state <= LENGTH) -+ return _next.depth(); -+ else if (_state == VALUE) -+ return _valueDepth; -+ else -+ return _next.depth() + 2; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ return nextObject(ch); -+ -+ case LENGTH: -+ return nextObject(ch); -+ -+ case VALUE: -+ if (_length <= _count) -+ return _next.next(ch); -+ else { -+ _valueDepth = _next.depth() + 2; -+ println(); -+ printObject(_count++ + ": "); -+ _valueDepth = _column; -+ _isObject = false; -+ -+ return nextObject(ch); -+ } -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class Hessian2State extends State { -+ private static final int MAJOR = 0; -+ private static final int MINOR = 1; -+ -+ private int _state; -+ private int _major; -+ private int _minor; -+ -+ Hessian2State(State next) -+ { -+ super(next); -+ } -+ -+ int depth() -+ { -+ return _next.depth() + 2; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case MAJOR: -+ _major = ch; -+ _state = MINOR; -+ return this; -+ -+ case MINOR: -+ _minor = ch; -+ println(-2, "Hessian " + _major + "." + _minor); -+ return _next; -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class CallState1 extends State1 { -+ private static final int MAJOR = 0; -+ private static final int MINOR = 1; -+ private static final int HEADER = 2; -+ private static final int METHOD = 3; -+ private static final int VALUE = 4; -+ private static final int ARG = 5; -+ -+ private int _state; -+ private int _major; -+ private int _minor; -+ -+ CallState1(State next) -+ { -+ super(next); -+ } -+ -+ int depth() -+ { -+ return _next.depth() + 2; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case MAJOR: -+ _major = ch; -+ _state = MINOR; -+ return this; -+ -+ case MINOR: -+ _minor = ch; -+ _state = HEADER; -+ println(-2, "call " + _major + "." + _minor); -+ return this; -+ -+ case HEADER: -+ if (ch == 'H') { -+ println(); -+ print("header "); -+ _isObject = false; -+ _state = VALUE; -+ return new StringState(this, 'H', true); -+ } -+ else if (ch == 'm') { -+ println(); -+ print("method "); -+ _isObject = false; -+ _state = ARG; -+ return new StringState(this, 'm', true); -+ } -+ else { -+ println((char) ch + ": unexpected char"); -+ return popStack(); -+ } -+ -+ case VALUE: -+ print(" => "); -+ _isObject = false; -+ _state = HEADER; -+ return nextObject(ch); -+ -+ case ARG: -+ if (ch == 'z') { -+ println(); -+ return _next; -+ } -+ else -+ return nextObject(ch); -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class Call2State extends State { -+ private static final int METHOD = 0; -+ private static final int COUNT = 1; -+ private static final int ARG = 2; -+ -+ private int _state = METHOD; -+ private int _i; -+ private int _count; -+ -+ Call2State(State next) -+ { -+ super(next); -+ } -+ -+ int depth() -+ { -+ return _next.depth() + 5; -+ } -+ -+ @Override -+ boolean isShift(Object value) -+ { -+ return _state != ARG; -+ } -+ -+ @Override -+ State shift(Object object) -+ { -+ if (_state == METHOD) { -+ println(-5, "Call " + object); -+ -+ _state = COUNT; -+ return this; -+ } -+ else if (_state == COUNT) { -+ Integer count = (Integer) object; -+ -+ _count = count; -+ -+ _state = ARG; -+ -+ if (_count == 0) { -+ return _next; -+ } -+ else -+ return this; -+ } -+ else { -+ return this; -+ } -+ } -+ -+ @Override -+ State next(int ch) -+ { -+ switch (_state) { -+ case COUNT: -+ return nextObject(ch); -+ -+ case METHOD: -+ return nextObject(ch); -+ -+ case ARG: -+ if (_count <= _i) { -+ println(); -+ return _next.next(ch); -+ } -+ else { -+ println(); -+ print(-3, _i++ + ": "); -+ -+ return nextObject(ch); -+ } -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class ReplyState1 extends State1 { -+ private static final int MAJOR = 0; -+ private static final int MINOR = 1; -+ private static final int HEADER = 2; -+ private static final int VALUE = 3; -+ private static final int END = 4; -+ -+ private int _state; -+ private int _major; -+ private int _minor; -+ -+ ReplyState1(State next) -+ { -+ _next = next; -+ } -+ -+ int depth() -+ { -+ return _next.depth() + 2; -+ } -+ -+ State next(int ch) -+ { -+ switch (_state) { -+ case MAJOR: -+ if (ch == 't' || ch == 'S') -+ return new RemoteState(this).next(ch); -+ -+ _major = ch; -+ _state = MINOR; -+ return this; -+ -+ case MINOR: -+ _minor = ch; -+ _state = HEADER; -+ println(-2, "reply " + _major + "." + _minor); -+ return this; -+ -+ case HEADER: -+ if (ch == 'H') { -+ _state = VALUE; -+ return new StringState(this, 'H', true); -+ } -+ else if (ch == 'f') { -+ print("fault "); -+ _isObject = false; -+ _state = END; -+ return new MapState(this, 0); -+ } -+ else { -+ _state = END; -+ return nextObject(ch); -+ } -+ -+ case VALUE: -+ _state = HEADER; -+ return nextObject(ch); -+ -+ case END: -+ println(); -+ if (ch == 'z') { -+ return _next; -+ } -+ else -+ return _next.next(ch); -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class Reply2State extends State { -+ Reply2State(State next) -+ { -+ super(next); -+ -+ println(-2, "Reply"); -+ } -+ -+ int depth() -+ { -+ return _next.depth() + 2; -+ } -+ -+ @Override -+ State next(int ch) -+ { -+ if (ch < 0) { -+ println(); -+ return _next; -+ } -+ else { -+ return nextObject(ch); -+ } -+ } -+ } -+ -+ class Fault2State extends State { -+ Fault2State(State next) -+ { -+ super(next); -+ -+ println(-2, "Fault"); -+ } -+ -+ int depth() -+ { -+ return _next.depth() + 2; -+ } -+ -+ @Override -+ State next(int ch) -+ { -+ return nextObject(ch); -+ } -+ } -+ -+ class IndirectState extends State { -+ IndirectState(State next) -+ { -+ super(next); -+ } -+ -+ boolean isShift(Object object) -+ { -+ return _next.isShift(object); -+ } -+ -+ State shift(Object object) -+ { -+ return _next.shift(object); -+ } -+ -+ State next(int ch) -+ { -+ return nextObject(ch); -+ } -+ } -+ -+ class RemoteState extends State { -+ private static final int TYPE = 0; -+ private static final int VALUE = 1; -+ private static final int END = 2; -+ -+ private int _state; -+ private int _major; -+ private int _minor; -+ -+ RemoteState(State next) -+ { -+ super(next); -+ } -+ -+ @Override -+ State next(int ch) -+ { -+ switch (_state) { -+ case TYPE: -+ println(-1, "remote"); -+ if (ch == 't') { -+ _state = VALUE; -+ return new StringState(this, 't', false); -+ } -+ else { -+ _state = END; -+ return nextObject(ch); -+ } -+ -+ case VALUE: -+ _state = END; -+ return _next.nextObject(ch); -+ -+ case END: -+ return _next.next(ch); -+ -+ default: -+ throw new IllegalStateException(); -+ } -+ } -+ } -+ -+ class StreamingState extends State { -+ private long _length; -+ private int _metaLength; -+ private boolean _isLast; -+ private boolean _isFirst = true; -+ -+ private boolean _isLengthState; -+ -+ private State _childState; -+ -+ StreamingState(State next, boolean isLast) -+ { -+ super(next); -+ -+ _isLast = isLast; -+ _childState = new InitialState(); -+ } -+ -+ State next(int ch) -+ { -+ if (_metaLength > 0) { -+ _length = 256 * _length + ch; -+ _metaLength--; -+ -+ if (_metaLength == 0 && _isFirst) { -+ if (_isLast) -+ println(-1, "--- packet-start(" + _length + ")"); -+ else -+ println(-1, "--- packet-start(fragment)"); -+ _isFirst = false; -+ } -+ -+ return this; -+ } -+ -+ if (_length > 0) { -+ _length--; -+ _childState = _childState.next(ch); -+ -+ return this; -+ } -+ -+ if (! _isLengthState) { -+ _isLengthState = true; -+ -+ if (_isLast) { -+ println(-1, ""); -+ println(-1, "--- packet-end"); -+ _refId = 0; -+ -+ _isFirst = true; -+ } -+ -+ _isLast = (ch & 0x80) == 0x00; -+ _isLengthState = true; -+ } -+ else { -+ _isLengthState = false; -+ _length = (ch & 0x7f); -+ -+ if (_length == 0x7e) { -+ _length = 0; -+ _metaLength = 2; -+ } -+ else if (_length == 0x7f) { -+ _length = 0; -+ _metaLength = 8; -+ } -+ else { -+ if (_isFirst) { -+ if (_isLast) -+ println(-1, "--- packet-start(" + _length + ")"); -+ else -+ println(-1, "--- packet-start(fragment)"); -+ _isFirst = false; -+ } -+ } -+ } -+ -+ return this; -+ } -+ } -+ -+ static class ObjectDef { -+ private String _type; -+ private ArrayList _fields; -+ -+ ObjectDef(String type, ArrayList fields) -+ { -+ _type = type; -+ _fields = fields; -+ } -+ -+ String getType() -+ { -+ return _type; -+ } -+ -+ ArrayList getFields() -+ { -+ return _fields; -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianEnvelope.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianEnvelope.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianEnvelope.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianEnvelope.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,78 +1,78 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.*; -- --/** -- * Factory class for wrapping and unwrapping hessian streams. -- */ --abstract public class HessianEnvelope { -- /** -- * Wrap the Hessian output stream in an envelope. -- */ -- abstract public Hessian2Output wrap(Hessian2Output out) -- throws IOException; -- -- /** -- * Unwrap the Hessian input stream with this envelope. It is an -- * error if the actual envelope does not match the expected envelope -- * class. -- */ -- abstract public Hessian2Input unwrap(Hessian2Input in) -- throws IOException; -- -- /** -- * Unwrap the envelope after having read the envelope code ('E') and -- * the envelope method. Called by the EnvelopeFactory for dynamic -- * reading of the envelopes. -- */ -- abstract public Hessian2Input unwrapHeaders(Hessian2Input in) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.*; -+ -+/** -+ * Factory class for wrapping and unwrapping hessian streams. -+ */ -+abstract public class HessianEnvelope { -+ /** -+ * Wrap the Hessian output stream in an envelope. -+ */ -+ abstract public Hessian2Output wrap(Hessian2Output out) -+ throws IOException; -+ -+ /** -+ * Unwrap the Hessian input stream with this envelope. It is an -+ * error if the actual envelope does not match the expected envelope -+ * class. -+ */ -+ abstract public Hessian2Input unwrap(Hessian2Input in) -+ throws IOException; -+ -+ /** -+ * Unwrap the envelope after having read the envelope code ('E') and -+ * the envelope method. Called by the EnvelopeFactory for dynamic -+ * reading of the envelopes. -+ */ -+ abstract public Hessian2Input unwrapHeaders(Hessian2Input in) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,268 +1,268 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.logging.*; --import java.io.*; --import com.caucho.hessian.util.HessianFreeList; -- --/** -- * Factory for creating HessianInput and HessianOutput streams. -- */ --public class HessianFactory --{ -- public static final Logger log -- = Logger.getLogger(HessianFactory.class.getName()); -- -- private SerializerFactory _serializerFactory; -- private SerializerFactory _defaultSerializerFactory; -- -- private final HessianFreeList _freeHessian2Output -- = new HessianFreeList(32); -- -- private final HessianFreeList _freeHessianOutput -- = new HessianFreeList(32); -- -- private final HessianFreeList _freeHessian2Input -- = new HessianFreeList(32); -- -- private final HessianFreeList _freeHessianInput -- = new HessianFreeList(32); -- -- public HessianFactory() -- { -- _defaultSerializerFactory = SerializerFactory.createDefault(); -- _serializerFactory = _defaultSerializerFactory; -- } -- -- public void setSerializerFactory(SerializerFactory factory) -- { -- _serializerFactory = factory; -- } -- -- public SerializerFactory getSerializerFactory() -- { -- // the default serializer factory cannot be modified by external -- // callers -- if (_serializerFactory == _defaultSerializerFactory) { -- _serializerFactory = new SerializerFactory(); -- } -- -- return _serializerFactory; -- } -- -- /** -- * Enable whitelist deserialization mode. Only classes matching the whitelist -- * will be allowed. -- */ -- public void setWhitelist(boolean isWhitelist) -- { -- getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); -- } -- -- /** -- * Allow a class or package based on a pattern. -- * -- * Examples: "java.util.*", "com.foo.io.Bean" -- */ -- public void allow(String pattern) -- { -- getSerializerFactory().getClassFactory().allow(pattern); -- } -- -- -- /** -- * Deny a class or package based on a pattern. -- * -- * Examples: "java.util.*", "com.foo.io.Bean" -- */ -- public void deny(String pattern) -- { -- getSerializerFactory().getClassFactory().deny(pattern); -- } -- -- /** -- * Creates a new Hessian 2.0 deserializer. -- */ -- public Hessian2Input createHessian2Input(InputStream is) -- { -- Hessian2Input in = _freeHessian2Input.allocate(); -- -- if (in == null) { -- in = new Hessian2Input(is); -- in.setSerializerFactory(getSerializerFactory()); -- } -- else { -- in.init(is); -- } -- -- return in; -- } -- -- /** -- * Frees a Hessian 2.0 deserializer -- */ -- public void freeHessian2Input(Hessian2Input in) -- { -- if (in == null) -- return; -- -- in.free(); -- -- _freeHessian2Input.free(in); -- } -- -- /** -- * Creates a new Hessian 2.0 deserializer. -- */ -- public Hessian2StreamingInput createHessian2StreamingInput(InputStream is) -- { -- Hessian2StreamingInput in = new Hessian2StreamingInput(is); -- in.setSerializerFactory(getSerializerFactory()); -- -- return in; -- } -- -- /** -- * Frees a Hessian 2.0 deserializer -- */ -- public void freeHessian2StreamingInput(Hessian2StreamingInput in) -- { -- } -- -- /** -- * Creates a new Hessian 1.0 deserializer. -- */ -- public HessianInput createHessianInput(InputStream is) -- { -- return new HessianInput(is); -- } -- -- /** -- * Creates a new Hessian 2.0 serializer. -- */ -- public Hessian2Output createHessian2Output(OutputStream os) -- { -- Hessian2Output out = createHessian2Output(); -- -- out.init(os); -- -- return out; -- } -- -- /** -- * Creates a new Hessian 2.0 serializer. -- */ -- public Hessian2Output createHessian2Output() -- { -- Hessian2Output out = _freeHessian2Output.allocate(); -- -- if (out == null) { -- out = new Hessian2Output(); -- -- out.setSerializerFactory(getSerializerFactory()); -- } -- -- return out; -- } -- -- /** -- * Frees a Hessian 2.0 serializer -- */ -- public void freeHessian2Output(Hessian2Output out) -- { -- if (out == null) -- return; -- -- out.free(); -- -- _freeHessian2Output.free(out); -- } -- -- /** -- * Creates a new Hessian 2.0 serializer. -- */ -- public Hessian2StreamingOutput createHessian2StreamingOutput(OutputStream os) -- { -- Hessian2Output out = createHessian2Output(os); -- -- return new Hessian2StreamingOutput(out); -- } -- -- /** -- * Frees a Hessian 2.0 serializer -- */ -- public void freeHessian2StreamingOutput(Hessian2StreamingOutput out) -- { -- if (out == null) -- return; -- -- freeHessian2Output(out.getHessian2Output()); -- } -- -- /** -- * Creates a new Hessian 1.0 serializer. -- */ -- public HessianOutput createHessianOutput(OutputStream os) -- { -- return new HessianOutput(os); -- } -- -- public OutputStream createHessian2DebugOutput(OutputStream os, -- Logger log, -- Level level) -- { -- HessianDebugOutputStream out -- = new HessianDebugOutputStream(os, log, level); -- -- out.startTop2(); -- -- return out; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.logging.*; -+import java.io.*; -+import com.caucho.hessian.util.HessianFreeList; -+ -+/** -+ * Factory for creating HessianInput and HessianOutput streams. -+ */ -+public class HessianFactory -+{ -+ public static final Logger log -+ = Logger.getLogger(HessianFactory.class.getName()); -+ -+ private SerializerFactory _serializerFactory; -+ private SerializerFactory _defaultSerializerFactory; -+ -+ private final HessianFreeList _freeHessian2Output -+ = new HessianFreeList(32); -+ -+ private final HessianFreeList _freeHessianOutput -+ = new HessianFreeList(32); -+ -+ private final HessianFreeList _freeHessian2Input -+ = new HessianFreeList(32); -+ -+ private final HessianFreeList _freeHessianInput -+ = new HessianFreeList(32); -+ -+ public HessianFactory() -+ { -+ _defaultSerializerFactory = SerializerFactory.createDefault(); -+ _serializerFactory = _defaultSerializerFactory; -+ } -+ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ public SerializerFactory getSerializerFactory() -+ { -+ // the default serializer factory cannot be modified by external -+ // callers -+ if (_serializerFactory == _defaultSerializerFactory) { -+ _serializerFactory = new SerializerFactory(); -+ } -+ -+ return _serializerFactory; -+ } -+ -+ /** -+ * Enable whitelist deserialization mode. Only classes matching the whitelist -+ * will be allowed. -+ */ -+ public void setWhitelist(boolean isWhitelist) -+ { -+ getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); -+ } -+ -+ /** -+ * Allow a class or package based on a pattern. -+ * -+ * Examples: "java.util.*", "com.foo.io.Bean" -+ */ -+ public void allow(String pattern) -+ { -+ getSerializerFactory().getClassFactory().allow(pattern); -+ } -+ -+ -+ /** -+ * Deny a class or package based on a pattern. -+ * -+ * Examples: "java.util.*", "com.foo.io.Bean" -+ */ -+ public void deny(String pattern) -+ { -+ getSerializerFactory().getClassFactory().deny(pattern); -+ } -+ -+ /** -+ * Creates a new Hessian 2.0 deserializer. -+ */ -+ public Hessian2Input createHessian2Input(InputStream is) -+ { -+ Hessian2Input in = _freeHessian2Input.allocate(); -+ -+ if (in == null) { -+ in = new Hessian2Input(is); -+ in.setSerializerFactory(getSerializerFactory()); -+ } -+ else { -+ in.init(is); -+ } -+ -+ return in; -+ } -+ -+ /** -+ * Frees a Hessian 2.0 deserializer -+ */ -+ public void freeHessian2Input(Hessian2Input in) -+ { -+ if (in == null) -+ return; -+ -+ in.free(); -+ -+ _freeHessian2Input.free(in); -+ } -+ -+ /** -+ * Creates a new Hessian 2.0 deserializer. -+ */ -+ public Hessian2StreamingInput createHessian2StreamingInput(InputStream is) -+ { -+ Hessian2StreamingInput in = new Hessian2StreamingInput(is); -+ in.setSerializerFactory(getSerializerFactory()); -+ -+ return in; -+ } -+ -+ /** -+ * Frees a Hessian 2.0 deserializer -+ */ -+ public void freeHessian2StreamingInput(Hessian2StreamingInput in) -+ { -+ } -+ -+ /** -+ * Creates a new Hessian 1.0 deserializer. -+ */ -+ public HessianInput createHessianInput(InputStream is) -+ { -+ return new HessianInput(is); -+ } -+ -+ /** -+ * Creates a new Hessian 2.0 serializer. -+ */ -+ public Hessian2Output createHessian2Output(OutputStream os) -+ { -+ Hessian2Output out = createHessian2Output(); -+ -+ out.init(os); -+ -+ return out; -+ } -+ -+ /** -+ * Creates a new Hessian 2.0 serializer. -+ */ -+ public Hessian2Output createHessian2Output() -+ { -+ Hessian2Output out = _freeHessian2Output.allocate(); -+ -+ if (out == null) { -+ out = new Hessian2Output(); -+ -+ out.setSerializerFactory(getSerializerFactory()); -+ } -+ -+ return out; -+ } -+ -+ /** -+ * Frees a Hessian 2.0 serializer -+ */ -+ public void freeHessian2Output(Hessian2Output out) -+ { -+ if (out == null) -+ return; -+ -+ out.free(); -+ -+ _freeHessian2Output.free(out); -+ } -+ -+ /** -+ * Creates a new Hessian 2.0 serializer. -+ */ -+ public Hessian2StreamingOutput createHessian2StreamingOutput(OutputStream os) -+ { -+ Hessian2Output out = createHessian2Output(os); -+ -+ return new Hessian2StreamingOutput(out); -+ } -+ -+ /** -+ * Frees a Hessian 2.0 serializer -+ */ -+ public void freeHessian2StreamingOutput(Hessian2StreamingOutput out) -+ { -+ if (out == null) -+ return; -+ -+ freeHessian2Output(out.getHessian2Output()); -+ } -+ -+ /** -+ * Creates a new Hessian 1.0 serializer. -+ */ -+ public HessianOutput createHessianOutput(OutputStream os) -+ { -+ return new HessianOutput(os); -+ } -+ -+ public OutputStream createHessian2DebugOutput(OutputStream os, -+ Logger log, -+ Level level) -+ { -+ HessianDebugOutputStream out -+ = new HessianDebugOutputStream(os, log, level); -+ -+ out.startTop2(); -+ -+ return out; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianFieldException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianFieldException.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianFieldException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianFieldException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,87 +1,87 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Exception during field reading. -- */ --public class HessianFieldException extends HessianProtocolException { -- /** -- * Zero-arg constructor. -- */ -- public HessianFieldException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public HessianFieldException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public HessianFieldException(String message, Throwable cause) -- { -- super(message, cause); -- } -- -- /** -- * Create the exception. -- */ -- public HessianFieldException(Throwable cause) -- { -- super(cause); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Exception during field reading. -+ */ -+public class HessianFieldException extends HessianProtocolException { -+ /** -+ * Zero-arg constructor. -+ */ -+ public HessianFieldException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianFieldException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianFieldException(String message, Throwable cause) -+ { -+ super(message, cause); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianFieldException(Throwable cause) -+ { -+ super(cause); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianHandle.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianHandle.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianHandle.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,55 +1,55 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --/** -- * Marks a type as a handle -- */ --public interface HessianHandle { --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+/** -+ * Marks a type as a handle -+ */ -+public interface HessianHandle { -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianInput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianInput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,1707 +1,1707 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.ByteArrayOutputStream; --import java.io.IOException; --import java.io.InputStream; --import java.io.Reader; --import java.lang.reflect.Field; --import java.util.ArrayList; --import java.util.Date; --import java.util.HashMap; -- --/** -- * Input stream for Hessian requests. -- * -- *

HessianInput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * InputStream is = ...; // from http connection
-- * HessianInput in = new HessianInput(is);
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --public class HessianInput extends AbstractHessianInput { -- private static int END_OF_DATA = -2; -- -- private static Field _detailMessageField; -- -- // factory for deserializing objects in the input stream -- protected SerializerFactory _serializerFactory; -- -- protected ArrayList _refs; -- -- // the underlying input stream -- private InputStream _is; -- // a peek character -- protected int _peek = -1; -- -- // the method for a call -- private String _method; -- -- private Reader _chunkReader; -- private InputStream _chunkInputStream; -- -- private Throwable _replyFault; -- -- private StringBuffer _sbuf = new StringBuffer(); -- -- // true if this is the last chunk -- private boolean _isLastChunk; -- // the chunk length -- private int _chunkLength; -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianInput() -- { -- } -- -- /** -- * Creates a new Hessian input stream, initialized with an -- * underlying input stream. -- * -- * @param is the underlying input stream. -- */ -- public HessianInput(InputStream is) -- { -- init(is); -- } -- -- /** -- * Sets the serializer factory. -- */ -- public void setSerializerFactory(SerializerFactory factory) -- { -- _serializerFactory = factory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- public SerializerFactory getSerializerFactory() -- { -- return _serializerFactory; -- } -- -- /** -- * Initialize the hessian stream with the underlying input stream. -- */ -- public void init(InputStream is) -- { -- _is = is; -- _method = null; -- _isLastChunk = true; -- _chunkLength = 0; -- _peek = -1; -- _refs = null; -- _replyFault = null; -- -- if (_serializerFactory == null) -- _serializerFactory = new SerializerFactory(); -- } -- -- /** -- * Returns the calls method -- */ -- public String getMethod() -- { -- return _method; -- } -- -- /** -- * Returns any reply fault. -- */ -- public Throwable getReplyFault() -- { -- return _replyFault; -- } -- -- /** -- * Starts reading the call -- * -- *
--   * c major minor
--   * 
-- */ -- public int readCall() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'c') -- throw error("expected hessian call ('c') at " + codeName(tag)); -- -- int major = read(); -- int minor = read(); -- -- return (major << 16) + minor; -- } -- -- /** -- * For backward compatibility with HessianSkeleton -- */ -- public void skipOptionalCall() -- throws IOException -- { -- int tag = read(); -- -- if (tag == 'c') { -- read(); -- read(); -- } -- else -- _peek = tag; -- } -- -- /** -- * Starts reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * m b16 b8 method
--   * 
-- */ -- public String readMethod() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'm') -- throw error("expected hessian method ('m') at " + codeName(tag)); -- int d1 = read(); -- int d2 = read(); -- -- _isLastChunk = true; -- _chunkLength = d1 * 256 + d2; -- _sbuf.setLength(0); -- int ch; -- while ((ch = parseChar()) >= 0) -- _sbuf.append((char) ch); -- -- _method = _sbuf.toString(); -- -- return _method; -- } -- -- /** -- * Starts reading the call, including the headers. -- * -- *

The call expects the following protocol data -- * -- *

--   * c major minor
--   * m b16 b8 method
--   * 
-- */ -- public void startCall() -- throws IOException -- { -- readCall(); -- -- while (readHeader() != null) { -- readObject(); -- } -- -- readMethod(); -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- int tag = read(); -- -- if (tag == 'z') { -- } -- else -- throw error("expected end of call ('z') at " + codeName(tag) + ". Check method arguments and ensure method overloading is enabled if necessary"); -- } -- -- /** -- * Reads a reply as an object. -- * If the reply has a fault, throws the exception. -- */ -- public Object readReply(Class expectedClass) -- throws Throwable -- { -- int tag = read(); -- -- if (tag != 'r') -- error("expected hessian reply at " + codeName(tag)); -- -- int major = read(); -- int minor = read(); -- -- tag = read(); -- if (tag == 'f') -- throw prepareFault(); -- else { -- _peek = tag; -- -- Object value = readObject(expectedClass); -- -- completeValueReply(); -- -- return value; -- } -- } -- -- /** -- * Starts reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * r
--   * 
-- */ -- public void startReply() -- throws Throwable -- { -- int tag = read(); -- -- if (tag != 'r') -- error("expected hessian reply at " + codeName(tag)); -- -- int major = read(); -- int minor = read(); -- -- startReplyBody(); -- } -- -- public void startReplyBody() -- throws Throwable -- { -- int tag = read(); -- -- if (tag == 'f') -- throw prepareFault(); -- else -- _peek = tag; -- } -- -- /** -- * Prepares the fault. -- */ -- private Throwable prepareFault() -- throws IOException -- { -- HashMap fault = readFault(); -- -- Object detail = fault.get("detail"); -- String message = (String) fault.get("message"); -- -- if (detail instanceof Throwable) { -- _replyFault = (Throwable) detail; -- -- if (message != null && _detailMessageField != null) { -- try { -- _detailMessageField.set(_replyFault, message); -- } catch (Throwable e) { -- } -- } -- -- return _replyFault; -- } -- -- else { -- String code = (String) fault.get("code"); -- -- _replyFault = new HessianServiceException(message, code, detail); -- -- return _replyFault; -- } -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeReply() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'z') -- error("expected end of reply at " + codeName(tag)); -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeValueReply() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'z') -- error("expected end of reply at " + codeName(tag)); -- } -- -- /** -- * Reads a header, returning null if there are no headers. -- * -- *
--   * H b16 b8 value
--   * 
-- */ -- public String readHeader() -- throws IOException -- { -- int tag = read(); -- -- if (tag == 'H') { -- _isLastChunk = true; -- _chunkLength = (read() << 8) + read(); -- -- _sbuf.setLength(0); -- int ch; -- while ((ch = parseChar()) >= 0) -- _sbuf.append((char) ch); -- -- return _sbuf.toString(); -- } -- -- _peek = tag; -- -- return null; -- } -- -- /** -- * Reads a null -- * -- *
--   * N
--   * 
-- */ -- public void readNull() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': return; -- -- default: -- throw expect("null", tag); -- } -- } -- -- /** -- * Reads a boolean -- * -- *
--   * T
--   * F
--   * 
-- */ -- public boolean readBoolean() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'T': return true; -- case 'F': return false; -- case 'I': return parseInt() == 0; -- case 'L': return parseLong() == 0; -- case 'D': return parseDouble() == 0.0; -- case 'N': return false; -- -- default: -- throw expect("boolean", tag); -- } -- } -- -- /** -- * Reads a byte -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- */ -- /* -- public byte readByte() -- throws IOException -- { -- return (byte) readInt(); -- } -- */ -- -- /** -- * Reads a short -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- */ -- public short readShort() -- throws IOException -- { -- return (short) readInt(); -- } -- -- /** -- * Reads an integer -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- */ -- public int readInt() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'T': return 1; -- case 'F': return 0; -- case 'I': return parseInt(); -- case 'L': return (int) parseLong(); -- case 'D': return (int) parseDouble(); -- -- default: -- throw expect("int", tag); -- } -- } -- -- /** -- * Reads a long -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public long readLong() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'T': return 1; -- case 'F': return 0; -- case 'I': return parseInt(); -- case 'L': return parseLong(); -- case 'D': return (long) parseDouble(); -- -- default: -- throw expect("long", tag); -- } -- } -- -- /** -- * Reads a float -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public float readFloat() -- throws IOException -- { -- return (float) readDouble(); -- } -- -- /** -- * Reads a double -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public double readDouble() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'T': return 1; -- case 'F': return 0; -- case 'I': return parseInt(); -- case 'L': return (double) parseLong(); -- case 'D': return parseDouble(); -- -- default: -- throw expect("long", tag); -- } -- } -- -- /** -- * Reads a date. -- * -- *
--   * T b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public long readUTCDate() -- throws IOException -- { -- int tag = read(); -- -- if (tag != 'd') -- throw error("expected date at " + codeName(tag)); -- -- long b64 = read(); -- long b56 = read(); -- long b48 = read(); -- long b40 = read(); -- long b32 = read(); -- long b24 = read(); -- long b16 = read(); -- long b8 = read(); -- -- return ((b64 << 56) + -- (b56 << 48) + -- (b48 << 40) + -- (b40 << 32) + -- (b32 << 24) + -- (b24 << 16) + -- (b16 << 8) + -- b8); -- } -- -- /** -- * Reads a byte from the stream. -- */ -- public int readChar() -- throws IOException -- { -- if (_chunkLength > 0) { -- _chunkLength--; -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- int ch = parseUTF8Char(); -- return ch; -- } -- else if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'S': -- case 's': -- case 'X': -- case 'x': -- _isLastChunk = tag == 'S' || tag == 'X'; -- _chunkLength = (read() << 8) + read(); -- -- _chunkLength--; -- int value = parseUTF8Char(); -- -- // special code so successive read byte won't -- // be read as a single object. -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- return value; -- -- default: -- throw new IOException("expected 'S' at " + (char) tag); -- } -- } -- -- /** -- * Reads a byte array from the stream. -- */ -- public int readString(char []buffer, int offset, int length) -- throws IOException -- { -- int readLength = 0; -- -- if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- else if (_chunkLength == 0) { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'S': -- case 's': -- case 'X': -- case 'x': -- _isLastChunk = tag == 'S' || tag == 'X'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw new IOException("expected 'S' at " + (char) tag); -- } -- } -- -- while (length > 0) { -- if (_chunkLength > 0) { -- buffer[offset++] = (char) parseUTF8Char(); -- _chunkLength--; -- length--; -- readLength++; -- } -- else if (_isLastChunk) { -- if (readLength == 0) -- return -1; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- else { -- int tag = read(); -- -- switch (tag) { -- case 'S': -- case 's': -- case 'X': -- case 'x': -- _isLastChunk = tag == 'S' || tag == 'X'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw new IOException("expected 'S' at " + (char) tag); -- } -- } -- } -- -- if (readLength == 0) -- return -1; -- else if (_chunkLength > 0 || ! _isLastChunk) -- return readLength; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- -- /** -- * Reads a string -- * -- *
--   * S b16 b8 string value
--   * 
-- */ -- public String readString() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'I': -- return String.valueOf(parseInt()); -- case 'L': -- return String.valueOf(parseLong()); -- case 'D': -- return String.valueOf(parseDouble()); -- -- case 'S': -- case 's': -- case 'X': -- case 'x': -- _isLastChunk = tag == 'S' || tag == 'X'; -- _chunkLength = (read() << 8) + read(); -- -- _sbuf.setLength(0); -- int ch; -- -- while ((ch = parseChar()) >= 0) -- _sbuf.append((char) ch); -- -- return _sbuf.toString(); -- -- default: -- throw expect("string", tag); -- } -- } -- -- /** -- * Reads an XML node. -- * -- *
--   * S b16 b8 string value
--   * 
-- */ -- public org.w3c.dom.Node readNode() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'S': -- case 's': -- case 'X': -- case 'x': -- _isLastChunk = tag == 'S' || tag == 'X'; -- _chunkLength = (read() << 8) + read(); -- -- throw error("Can't handle string in this context"); -- -- default: -- throw expect("string", tag); -- } -- } -- -- /** -- * Reads a byte array -- * -- *
--   * B b16 b8 data value
--   * 
-- */ -- public byte []readBytes() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'B': -- case 'b': -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- int data; -- while ((data = parseByte()) >= 0) -- bos.write(data); -- -- return bos.toByteArray(); -- -- default: -- throw expect("bytes", tag); -- } -- } -- -- /** -- * Reads a byte from the stream. -- */ -- public int readByte() -- throws IOException -- { -- if (_chunkLength > 0) { -- _chunkLength--; -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- return read(); -- } -- else if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'B': -- case 'b': -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- -- int value = parseByte(); -- -- // special code so successive read byte won't -- // be read as a single object. -- if (_chunkLength == 0 && _isLastChunk) -- _chunkLength = END_OF_DATA; -- -- return value; -- -- default: -- throw new IOException("expected 'B' at " + (char) tag); -- } -- } -- -- /** -- * Reads a byte array from the stream. -- */ -- public int readBytes(byte []buffer, int offset, int length) -- throws IOException -- { -- int readLength = 0; -- -- if (_chunkLength == END_OF_DATA) { -- _chunkLength = 0; -- return -1; -- } -- else if (_chunkLength == 0) { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return -1; -- -- case 'B': -- case 'b': -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw new IOException("expected 'B' at " + (char) tag); -- } -- } -- -- while (length > 0) { -- if (_chunkLength > 0) { -- buffer[offset++] = (byte) read(); -- _chunkLength--; -- length--; -- readLength++; -- } -- else if (_isLastChunk) { -- if (readLength == 0) -- return -1; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- else { -- int tag = read(); -- -- switch (tag) { -- case 'B': -- case 'b': -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw new IOException("expected 'B' at " + (char) tag); -- } -- } -- } -- -- if (readLength == 0) -- return -1; -- else if (_chunkLength > 0 || ! _isLastChunk) -- return readLength; -- else { -- _chunkLength = END_OF_DATA; -- return readLength; -- } -- } -- -- /** -- * Reads a fault. -- */ -- private HashMap readFault() -- throws IOException -- { -- HashMap map = new HashMap(); -- -- int code = read(); -- for (; code > 0 && code != 'z'; code = read()) { -- _peek = code; -- -- Object key = readObject(); -- Object value = readObject(); -- -- if (key != null && value != null) -- map.put(key, value); -- } -- -- if (code != 'z') -- throw expect("fault", code); -- -- return map; -- } -- -- /** -- * Reads an object from the input stream with an expected type. -- */ -- public Object readObject(Class cl) -- throws IOException -- { -- if (cl == null || cl == Object.class) -- return readObject(); -- -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'M': -- { -- String type = readType(); -- -- // hessian/3386 -- if ("".equals(type)) { -- Deserializer reader; -- reader = _serializerFactory.getDeserializer(cl); -- -- return reader.readMap(this); -- } -- else { -- Deserializer reader; -- reader = _serializerFactory.getObjectDeserializer(type); -- -- return reader.readMap(this); -- } -- } -- -- case 'V': -- { -- String type = readType(); -- int length = readLength(); -- -- Deserializer reader; -- reader = _serializerFactory.getObjectDeserializer(type); -- -- if (cl != reader.getType() && cl.isAssignableFrom(reader.getType())) -- return reader.readList(this, length); -- -- reader = _serializerFactory.getDeserializer(cl); -- -- Object v = reader.readList(this, length); -- -- return v; -- } -- -- case 'R': -- { -- int ref = parseInt(); -- -- return _refs.get(ref); -- } -- -- case 'r': -- { -- String type = readType(); -- String url = readString(); -- -- return resolveRemote(type, url); -- } -- } -- -- _peek = tag; -- -- // hessian/332i vs hessian/3406 -- //return readObject(); -- -- Object value = _serializerFactory.getDeserializer(cl).readObject(this); -- -- return value; -- } -- -- /** -- * Reads an arbitrary object from the input stream when the type -- * is unknown. -- */ -- public Object readObject() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'T': -- return Boolean.valueOf(true); -- -- case 'F': -- return Boolean.valueOf(false); -- -- case 'I': -- return Integer.valueOf(parseInt()); -- -- case 'L': -- return Long.valueOf(parseLong()); -- -- case 'D': -- return Double.valueOf(parseDouble()); -- -- case 'd': -- return new Date(parseLong()); -- -- case 'x': -- case 'X': { -- _isLastChunk = tag == 'X'; -- _chunkLength = (read() << 8) + read(); -- -- return parseXML(); -- } -- -- case 's': -- case 'S': { -- _isLastChunk = tag == 'S'; -- _chunkLength = (read() << 8) + read(); -- -- int data; -- _sbuf.setLength(0); -- -- while ((data = parseChar()) >= 0) -- _sbuf.append((char) data); -- -- return _sbuf.toString(); -- } -- -- case 'b': -- case 'B': { -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- -- int data; -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- while ((data = parseByte()) >= 0) -- bos.write(data); -- -- return bos.toByteArray(); -- } -- -- case 'V': { -- String type = readType(); -- int length = readLength(); -- -- return _serializerFactory.readList(this, length, type); -- } -- -- case 'M': { -- String type = readType(); -- -- return _serializerFactory.readMap(this, type); -- } -- -- case 'R': { -- int ref = parseInt(); -- -- return _refs.get(ref); -- } -- -- case 'r': { -- String type = readType(); -- String url = readString(); -- -- return resolveRemote(type, url); -- } -- -- default: -- throw error("unknown code for readObject at " + codeName(tag)); -- } -- } -- -- /** -- * Reads a remote object. -- */ -- public Object readRemote() -- throws IOException -- { -- String type = readType(); -- String url = readString(); -- -- return resolveRemote(type, url); -- } -- -- /** -- * Reads a reference. -- */ -- public Object readRef() -- throws IOException -- { -- return _refs.get(parseInt()); -- } -- -- /** -- * Reads the start of a list. -- */ -- public int readListStart() -- throws IOException -- { -- return read(); -- } -- -- /** -- * Reads the start of a list. -- */ -- public int readMapStart() -- throws IOException -- { -- return read(); -- } -- -- /** -- * Returns true if this is the end of a list or a map. -- */ -- public boolean isEnd() -- throws IOException -- { -- int code = read(); -- -- _peek = code; -- -- return (code < 0 || code == 'z'); -- } -- -- /** -- * Reads the end byte. -- */ -- public void readEnd() -- throws IOException -- { -- int code = read(); -- -- if (code != 'z') -- throw error("unknown code at " + codeName(code)); -- } -- -- /** -- * Reads the end byte. -- */ -- public void readMapEnd() -- throws IOException -- { -- int code = read(); -- -- if (code != 'z') -- throw error("expected end of map ('z') at " + codeName(code)); -- } -- -- /** -- * Reads the end byte. -- */ -- public void readListEnd() -- throws IOException -- { -- int code = read(); -- -- if (code != 'z') -- throw error("expected end of list ('z') at " + codeName(code)); -- } -- -- /** -- * Adds a list/map reference. -- */ -- public int addRef(Object ref) -- { -- if (_refs == null) -- _refs = new ArrayList(); -- -- _refs.add(ref); -- -- return _refs.size() - 1; -- } -- -- /** -- * Adds a list/map reference. -- */ -- public void setRef(int i, Object ref) -- { -- _refs.set(i, ref); -- } -- -- /** -- * Resets the references for streaming. -- */ -- public void resetReferences() -- { -- if (_refs != null) -- _refs.clear(); -- } -- -- /** -- * Resolves a remote object. -- */ -- public Object resolveRemote(String type, String url) -- throws IOException -- { -- HessianRemoteResolver resolver = getRemoteResolver(); -- -- if (resolver != null) -- return resolver.lookup(type, url); -- else -- return new HessianRemote(type, url); -- } -- -- /** -- * Parses a type from the stream. -- * -- *
--   * t b16 b8
--   * 
-- */ -- public String readType() -- throws IOException -- { -- int code = read(); -- -- if (code != 't') { -- _peek = code; -- return ""; -- } -- -- _isLastChunk = true; -- _chunkLength = (read() << 8) + read(); -- -- _sbuf.setLength(0); -- int ch; -- while ((ch = parseChar()) >= 0) -- _sbuf.append((char) ch); -- -- return _sbuf.toString(); -- } -- -- /** -- * Parses the length for an array -- * -- *
--   * l b32 b24 b16 b8
--   * 
-- */ -- public int readLength() -- throws IOException -- { -- int code = read(); -- -- if (code != 'l') { -- _peek = code; -- return -1; -- } -- -- return parseInt(); -- } -- -- /** -- * Parses a 32-bit integer value from the stream. -- * -- *
--   * b32 b24 b16 b8
--   * 
-- */ -- private int parseInt() -- throws IOException -- { -- int b32 = read(); -- int b24 = read(); -- int b16 = read(); -- int b8 = read(); -- -- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -- } -- -- /** -- * Parses a 64-bit long value from the stream. -- * -- *
--   * b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- private long parseLong() -- throws IOException -- { -- long b64 = read(); -- long b56 = read(); -- long b48 = read(); -- long b40 = read(); -- long b32 = read(); -- long b24 = read(); -- long b16 = read(); -- long b8 = read(); -- -- return ((b64 << 56) + -- (b56 << 48) + -- (b48 << 40) + -- (b40 << 32) + -- (b32 << 24) + -- (b24 << 16) + -- (b16 << 8) + -- b8); -- } -- -- /** -- * Parses a 64-bit double value from the stream. -- * -- *
--   * b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- private double parseDouble() -- throws IOException -- { -- long b64 = read(); -- long b56 = read(); -- long b48 = read(); -- long b40 = read(); -- long b32 = read(); -- long b24 = read(); -- long b16 = read(); -- long b8 = read(); -- -- long bits = ((b64 << 56) + -- (b56 << 48) + -- (b48 << 40) + -- (b40 << 32) + -- (b32 << 24) + -- (b24 << 16) + -- (b16 << 8) + -- b8); -- -- return Double.longBitsToDouble(bits); -- } -- -- org.w3c.dom.Node parseXML() -- throws IOException -- { -- throw new UnsupportedOperationException(); -- } -- -- /** -- * Reads a character from the underlying stream. -- */ -- private int parseChar() -- throws IOException -- { -- while (_chunkLength <= 0) { -- if (_isLastChunk) -- return -1; -- -- int code = read(); -- -- switch (code) { -- case 's': -- case 'x': -- _isLastChunk = false; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 'S': -- case 'X': -- _isLastChunk = true; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw expect("string", code); -- } -- -- } -- -- _chunkLength--; -- -- return parseUTF8Char(); -- } -- -- /** -- * Parses a single UTF8 character. -- */ -- private int parseUTF8Char() -- throws IOException -- { -- int ch = read(); -- -- if (ch < 0x80) -- return ch; -- else if ((ch & 0xe0) == 0xc0) { -- int ch1 = read(); -- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -- -- return v; -- } -- else if ((ch & 0xf0) == 0xe0) { -- int ch1 = read(); -- int ch2 = read(); -- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -- -- return v; -- } -- else -- throw error("bad utf-8 encoding at " + codeName(ch)); -- } -- -- /** -- * Reads a byte from the underlying stream. -- */ -- private int parseByte() -- throws IOException -- { -- while (_chunkLength <= 0) { -- if (_isLastChunk) { -- return -1; -- } -- -- int code = read(); -- -- switch (code) { -- case 'b': -- _isLastChunk = false; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 'B': -- _isLastChunk = true; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw expect("byte[]", code); -- } -- } -- -- _chunkLength--; -- -- return read(); -- } -- -- /** -- * Reads bytes based on an input stream. -- */ -- public InputStream readInputStream() -- throws IOException -- { -- int tag = read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'B': -- case 'b': -- _isLastChunk = tag == 'B'; -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw expect("inputStream", tag); -- } -- -- return new InputStream() { -- boolean _isClosed = false; -- -- public int read() -- throws IOException -- { -- if (_isClosed || _is == null) -- return -1; -- -- int ch = parseByte(); -- if (ch < 0) -- _isClosed = true; -- -- return ch; -- } -- -- public int read(byte []buffer, int offset, int length) -- throws IOException -- { -- if (_isClosed || _is == null) -- return -1; -- -- int len = HessianInput.this.read(buffer, offset, length); -- if (len < 0) -- _isClosed = true; -- -- return len; -- } -- -- public void close() -- throws IOException -- { -- while (read() >= 0) { -- } -- -- _isClosed = true; -- } -- }; -- } -- -- /** -- * Reads bytes from the underlying stream. -- */ -- int read(byte []buffer, int offset, int length) -- throws IOException -- { -- int readLength = 0; -- -- while (length > 0) { -- while (_chunkLength <= 0) { -- if (_isLastChunk) -- return readLength == 0 ? -1 : readLength; -- -- int code = read(); -- -- switch (code) { -- case 'b': -- _isLastChunk = false; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- case 'B': -- _isLastChunk = true; -- -- _chunkLength = (read() << 8) + read(); -- break; -- -- default: -- throw expect("byte[]", code); -- } -- } -- -- int sublen = _chunkLength; -- if (length < sublen) -- sublen = length; -- -- sublen = _is.read(buffer, offset, sublen); -- offset += sublen; -- readLength += sublen; -- length -= sublen; -- _chunkLength -= sublen; -- } -- -- return readLength; -- } -- -- final int read() -- throws IOException -- { -- if (_peek >= 0) { -- int value = _peek; -- _peek = -1; -- return value; -- } -- -- int ch = _is.read(); -- -- return ch; -- } -- -- public void close() -- { -- _is = null; -- } -- -- public Reader getReader() -- { -- return null; -- } -- -- protected IOException expect(String expect, int ch) -- { -- return error("expected " + expect + " at " + codeName(ch)); -- } -- -- protected String codeName(int ch) -- { -- if (ch < 0) -- return "end of file"; -- else -- return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; -- } -- -- protected IOException error(String message) -- { -- if (_method != null) -- return new HessianProtocolException(_method + ": " + message); -- else -- return new HessianProtocolException(message); -- } -- -- static { -- try { -- _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); -- _detailMessageField.setAccessible(true); -- } catch (Throwable e) { -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.ByteArrayOutputStream; -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.Reader; -+import java.lang.reflect.Field; -+import java.util.ArrayList; -+import java.util.Date; -+import java.util.HashMap; -+ -+/** -+ * Input stream for Hessian requests. -+ * -+ *

HessianInput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * InputStream is = ...; // from http connection
-+ * HessianInput in = new HessianInput(is);
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+public class HessianInput extends AbstractHessianInput { -+ private static int END_OF_DATA = -2; -+ -+ private static Field _detailMessageField; -+ -+ // factory for deserializing objects in the input stream -+ protected SerializerFactory _serializerFactory; -+ -+ protected ArrayList _refs; -+ -+ // the underlying input stream -+ private InputStream _is; -+ // a peek character -+ protected int _peek = -1; -+ -+ // the method for a call -+ private String _method; -+ -+ private Reader _chunkReader; -+ private InputStream _chunkInputStream; -+ -+ private Throwable _replyFault; -+ -+ private StringBuffer _sbuf = new StringBuffer(); -+ -+ // true if this is the last chunk -+ private boolean _isLastChunk; -+ // the chunk length -+ private int _chunkLength; -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianInput() -+ { -+ } -+ -+ /** -+ * Creates a new Hessian input stream, initialized with an -+ * underlying input stream. -+ * -+ * @param is the underlying input stream. -+ */ -+ public HessianInput(InputStream is) -+ { -+ init(is); -+ } -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ public SerializerFactory getSerializerFactory() -+ { -+ return _serializerFactory; -+ } -+ -+ /** -+ * Initialize the hessian stream with the underlying input stream. -+ */ -+ public void init(InputStream is) -+ { -+ _is = is; -+ _method = null; -+ _isLastChunk = true; -+ _chunkLength = 0; -+ _peek = -1; -+ _refs = null; -+ _replyFault = null; -+ -+ if (_serializerFactory == null) -+ _serializerFactory = new SerializerFactory(); -+ } -+ -+ /** -+ * Returns the calls method -+ */ -+ public String getMethod() -+ { -+ return _method; -+ } -+ -+ /** -+ * Returns any reply fault. -+ */ -+ public Throwable getReplyFault() -+ { -+ return _replyFault; -+ } -+ -+ /** -+ * Starts reading the call -+ * -+ *
-+   * c major minor
-+   * 
-+ */ -+ public int readCall() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'c') -+ throw error("expected hessian call ('c') at " + codeName(tag)); -+ -+ int major = read(); -+ int minor = read(); -+ -+ return (major << 16) + minor; -+ } -+ -+ /** -+ * For backward compatibility with HessianSkeleton -+ */ -+ public void skipOptionalCall() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag == 'c') { -+ read(); -+ read(); -+ } -+ else -+ _peek = tag; -+ } -+ -+ /** -+ * Starts reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * m b16 b8 method
-+   * 
-+ */ -+ public String readMethod() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'm') -+ throw error("expected hessian method ('m') at " + codeName(tag)); -+ int d1 = read(); -+ int d2 = read(); -+ -+ _isLastChunk = true; -+ _chunkLength = d1 * 256 + d2; -+ _sbuf.setLength(0); -+ int ch; -+ while ((ch = parseChar()) >= 0) -+ _sbuf.append((char) ch); -+ -+ _method = _sbuf.toString(); -+ -+ return _method; -+ } -+ -+ /** -+ * Starts reading the call, including the headers. -+ * -+ *

The call expects the following protocol data -+ * -+ *

-+   * c major minor
-+   * m b16 b8 method
-+   * 
-+ */ -+ public void startCall() -+ throws IOException -+ { -+ readCall(); -+ -+ while (readHeader() != null) { -+ readObject(); -+ } -+ -+ readMethod(); -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag == 'z') { -+ } -+ else -+ throw error("expected end of call ('z') at " + codeName(tag) + ". Check method arguments and ensure method overloading is enabled if necessary"); -+ } -+ -+ /** -+ * Reads a reply as an object. -+ * If the reply has a fault, throws the exception. -+ */ -+ public Object readReply(Class expectedClass) -+ throws Throwable -+ { -+ int tag = read(); -+ -+ if (tag != 'r') -+ error("expected hessian reply at " + codeName(tag)); -+ -+ int major = read(); -+ int minor = read(); -+ -+ tag = read(); -+ if (tag == 'f') -+ throw prepareFault(); -+ else { -+ _peek = tag; -+ -+ Object value = readObject(expectedClass); -+ -+ completeValueReply(); -+ -+ return value; -+ } -+ } -+ -+ /** -+ * Starts reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * r
-+   * 
-+ */ -+ public void startReply() -+ throws Throwable -+ { -+ int tag = read(); -+ -+ if (tag != 'r') -+ error("expected hessian reply at " + codeName(tag)); -+ -+ int major = read(); -+ int minor = read(); -+ -+ startReplyBody(); -+ } -+ -+ public void startReplyBody() -+ throws Throwable -+ { -+ int tag = read(); -+ -+ if (tag == 'f') -+ throw prepareFault(); -+ else -+ _peek = tag; -+ } -+ -+ /** -+ * Prepares the fault. -+ */ -+ private Throwable prepareFault() -+ throws IOException -+ { -+ HashMap fault = readFault(); -+ -+ Object detail = fault.get("detail"); -+ String message = (String) fault.get("message"); -+ -+ if (detail instanceof Throwable) { -+ _replyFault = (Throwable) detail; -+ -+ if (message != null && _detailMessageField != null) { -+ try { -+ _detailMessageField.set(_replyFault, message); -+ } catch (Throwable e) { -+ } -+ } -+ -+ return _replyFault; -+ } -+ -+ else { -+ String code = (String) fault.get("code"); -+ -+ _replyFault = new HessianServiceException(message, code, detail); -+ -+ return _replyFault; -+ } -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeReply() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'z') -+ error("expected end of reply at " + codeName(tag)); -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeValueReply() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'z') -+ error("expected end of reply at " + codeName(tag)); -+ } -+ -+ /** -+ * Reads a header, returning null if there are no headers. -+ * -+ *
-+   * H b16 b8 value
-+   * 
-+ */ -+ public String readHeader() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag == 'H') { -+ _isLastChunk = true; -+ _chunkLength = (read() << 8) + read(); -+ -+ _sbuf.setLength(0); -+ int ch; -+ while ((ch = parseChar()) >= 0) -+ _sbuf.append((char) ch); -+ -+ return _sbuf.toString(); -+ } -+ -+ _peek = tag; -+ -+ return null; -+ } -+ -+ /** -+ * Reads a null -+ * -+ *
-+   * N
-+   * 
-+ */ -+ public void readNull() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': return; -+ -+ default: -+ throw expect("null", tag); -+ } -+ } -+ -+ /** -+ * Reads a boolean -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ */ -+ public boolean readBoolean() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'T': return true; -+ case 'F': return false; -+ case 'I': return parseInt() == 0; -+ case 'L': return parseLong() == 0; -+ case 'D': return parseDouble() == 0.0; -+ case 'N': return false; -+ -+ default: -+ throw expect("boolean", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ */ -+ /* -+ public byte readByte() -+ throws IOException -+ { -+ return (byte) readInt(); -+ } -+ */ -+ -+ /** -+ * Reads a short -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ */ -+ public short readShort() -+ throws IOException -+ { -+ return (short) readInt(); -+ } -+ -+ /** -+ * Reads an integer -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ */ -+ public int readInt() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'T': return 1; -+ case 'F': return 0; -+ case 'I': return parseInt(); -+ case 'L': return (int) parseLong(); -+ case 'D': return (int) parseDouble(); -+ -+ default: -+ throw expect("int", tag); -+ } -+ } -+ -+ /** -+ * Reads a long -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public long readLong() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'T': return 1; -+ case 'F': return 0; -+ case 'I': return parseInt(); -+ case 'L': return parseLong(); -+ case 'D': return (long) parseDouble(); -+ -+ default: -+ throw expect("long", tag); -+ } -+ } -+ -+ /** -+ * Reads a float -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public float readFloat() -+ throws IOException -+ { -+ return (float) readDouble(); -+ } -+ -+ /** -+ * Reads a double -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public double readDouble() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'T': return 1; -+ case 'F': return 0; -+ case 'I': return parseInt(); -+ case 'L': return (double) parseLong(); -+ case 'D': return parseDouble(); -+ -+ default: -+ throw expect("long", tag); -+ } -+ } -+ -+ /** -+ * Reads a date. -+ * -+ *
-+   * T b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public long readUTCDate() -+ throws IOException -+ { -+ int tag = read(); -+ -+ if (tag != 'd') -+ throw error("expected date at " + codeName(tag)); -+ -+ long b64 = read(); -+ long b56 = read(); -+ long b48 = read(); -+ long b40 = read(); -+ long b32 = read(); -+ long b24 = read(); -+ long b16 = read(); -+ long b8 = read(); -+ -+ return ((b64 << 56) + -+ (b56 << 48) + -+ (b48 << 40) + -+ (b40 << 32) + -+ (b32 << 24) + -+ (b24 << 16) + -+ (b16 << 8) + -+ b8); -+ } -+ -+ /** -+ * Reads a byte from the stream. -+ */ -+ public int readChar() -+ throws IOException -+ { -+ if (_chunkLength > 0) { -+ _chunkLength--; -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ int ch = parseUTF8Char(); -+ return ch; -+ } -+ else if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'S': -+ case 's': -+ case 'X': -+ case 'x': -+ _isLastChunk = tag == 'S' || tag == 'X'; -+ _chunkLength = (read() << 8) + read(); -+ -+ _chunkLength--; -+ int value = parseUTF8Char(); -+ -+ // special code so successive read byte won't -+ // be read as a single object. -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ return value; -+ -+ default: -+ throw new IOException("expected 'S' at " + (char) tag); -+ } -+ } -+ -+ /** -+ * Reads a byte array from the stream. -+ */ -+ public int readString(char []buffer, int offset, int length) -+ throws IOException -+ { -+ int readLength = 0; -+ -+ if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ else if (_chunkLength == 0) { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'S': -+ case 's': -+ case 'X': -+ case 'x': -+ _isLastChunk = tag == 'S' || tag == 'X'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw new IOException("expected 'S' at " + (char) tag); -+ } -+ } -+ -+ while (length > 0) { -+ if (_chunkLength > 0) { -+ buffer[offset++] = (char) parseUTF8Char(); -+ _chunkLength--; -+ length--; -+ readLength++; -+ } -+ else if (_isLastChunk) { -+ if (readLength == 0) -+ return -1; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ else { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'S': -+ case 's': -+ case 'X': -+ case 'x': -+ _isLastChunk = tag == 'S' || tag == 'X'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw new IOException("expected 'S' at " + (char) tag); -+ } -+ } -+ } -+ -+ if (readLength == 0) -+ return -1; -+ else if (_chunkLength > 0 || ! _isLastChunk) -+ return readLength; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ -+ /** -+ * Reads a string -+ * -+ *
-+   * S b16 b8 string value
-+   * 
-+ */ -+ public String readString() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'I': -+ return String.valueOf(parseInt()); -+ case 'L': -+ return String.valueOf(parseLong()); -+ case 'D': -+ return String.valueOf(parseDouble()); -+ -+ case 'S': -+ case 's': -+ case 'X': -+ case 'x': -+ _isLastChunk = tag == 'S' || tag == 'X'; -+ _chunkLength = (read() << 8) + read(); -+ -+ _sbuf.setLength(0); -+ int ch; -+ -+ while ((ch = parseChar()) >= 0) -+ _sbuf.append((char) ch); -+ -+ return _sbuf.toString(); -+ -+ default: -+ throw expect("string", tag); -+ } -+ } -+ -+ /** -+ * Reads an XML node. -+ * -+ *
-+   * S b16 b8 string value
-+   * 
-+ */ -+ public org.w3c.dom.Node readNode() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'S': -+ case 's': -+ case 'X': -+ case 'x': -+ _isLastChunk = tag == 'S' || tag == 'X'; -+ _chunkLength = (read() << 8) + read(); -+ -+ throw error("Can't handle string in this context"); -+ -+ default: -+ throw expect("string", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte array -+ * -+ *
-+   * B b16 b8 data value
-+   * 
-+ */ -+ public byte []readBytes() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'B': -+ case 'b': -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ int data; -+ while ((data = parseByte()) >= 0) -+ bos.write(data); -+ -+ return bos.toByteArray(); -+ -+ default: -+ throw expect("bytes", tag); -+ } -+ } -+ -+ /** -+ * Reads a byte from the stream. -+ */ -+ public int readByte() -+ throws IOException -+ { -+ if (_chunkLength > 0) { -+ _chunkLength--; -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ return read(); -+ } -+ else if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'B': -+ case 'b': -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ -+ int value = parseByte(); -+ -+ // special code so successive read byte won't -+ // be read as a single object. -+ if (_chunkLength == 0 && _isLastChunk) -+ _chunkLength = END_OF_DATA; -+ -+ return value; -+ -+ default: -+ throw new IOException("expected 'B' at " + (char) tag); -+ } -+ } -+ -+ /** -+ * Reads a byte array from the stream. -+ */ -+ public int readBytes(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ int readLength = 0; -+ -+ if (_chunkLength == END_OF_DATA) { -+ _chunkLength = 0; -+ return -1; -+ } -+ else if (_chunkLength == 0) { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return -1; -+ -+ case 'B': -+ case 'b': -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw new IOException("expected 'B' at " + (char) tag); -+ } -+ } -+ -+ while (length > 0) { -+ if (_chunkLength > 0) { -+ buffer[offset++] = (byte) read(); -+ _chunkLength--; -+ length--; -+ readLength++; -+ } -+ else if (_isLastChunk) { -+ if (readLength == 0) -+ return -1; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ else { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'B': -+ case 'b': -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw new IOException("expected 'B' at " + (char) tag); -+ } -+ } -+ } -+ -+ if (readLength == 0) -+ return -1; -+ else if (_chunkLength > 0 || ! _isLastChunk) -+ return readLength; -+ else { -+ _chunkLength = END_OF_DATA; -+ return readLength; -+ } -+ } -+ -+ /** -+ * Reads a fault. -+ */ -+ private HashMap readFault() -+ throws IOException -+ { -+ HashMap map = new HashMap(); -+ -+ int code = read(); -+ for (; code > 0 && code != 'z'; code = read()) { -+ _peek = code; -+ -+ Object key = readObject(); -+ Object value = readObject(); -+ -+ if (key != null && value != null) -+ map.put(key, value); -+ } -+ -+ if (code != 'z') -+ throw expect("fault", code); -+ -+ return map; -+ } -+ -+ /** -+ * Reads an object from the input stream with an expected type. -+ */ -+ public Object readObject(Class cl) -+ throws IOException -+ { -+ if (cl == null || cl == Object.class) -+ return readObject(); -+ -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'M': -+ { -+ String type = readType(); -+ -+ // hessian/3386 -+ if ("".equals(type)) { -+ Deserializer reader; -+ reader = _serializerFactory.getDeserializer(cl); -+ -+ return reader.readMap(this); -+ } -+ else { -+ Deserializer reader; -+ reader = _serializerFactory.getObjectDeserializer(type); -+ -+ return reader.readMap(this); -+ } -+ } -+ -+ case 'V': -+ { -+ String type = readType(); -+ int length = readLength(); -+ -+ Deserializer reader; -+ reader = _serializerFactory.getObjectDeserializer(type); -+ -+ if (cl != reader.getType() && cl.isAssignableFrom(reader.getType())) -+ return reader.readList(this, length); -+ -+ reader = _serializerFactory.getDeserializer(cl); -+ -+ Object v = reader.readList(this, length); -+ -+ return v; -+ } -+ -+ case 'R': -+ { -+ int ref = parseInt(); -+ -+ return _refs.get(ref); -+ } -+ -+ case 'r': -+ { -+ String type = readType(); -+ String url = readString(); -+ -+ return resolveRemote(type, url); -+ } -+ } -+ -+ _peek = tag; -+ -+ // hessian/332i vs hessian/3406 -+ //return readObject(); -+ -+ Object value = _serializerFactory.getDeserializer(cl).readObject(this); -+ -+ return value; -+ } -+ -+ /** -+ * Reads an arbitrary object from the input stream when the type -+ * is unknown. -+ */ -+ public Object readObject() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'T': -+ return Boolean.valueOf(true); -+ -+ case 'F': -+ return Boolean.valueOf(false); -+ -+ case 'I': -+ return Integer.valueOf(parseInt()); -+ -+ case 'L': -+ return Long.valueOf(parseLong()); -+ -+ case 'D': -+ return Double.valueOf(parseDouble()); -+ -+ case 'd': -+ return new Date(parseLong()); -+ -+ case 'x': -+ case 'X': { -+ _isLastChunk = tag == 'X'; -+ _chunkLength = (read() << 8) + read(); -+ -+ return parseXML(); -+ } -+ -+ case 's': -+ case 'S': { -+ _isLastChunk = tag == 'S'; -+ _chunkLength = (read() << 8) + read(); -+ -+ int data; -+ _sbuf.setLength(0); -+ -+ while ((data = parseChar()) >= 0) -+ _sbuf.append((char) data); -+ -+ return _sbuf.toString(); -+ } -+ -+ case 'b': -+ case 'B': { -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ -+ int data; -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ while ((data = parseByte()) >= 0) -+ bos.write(data); -+ -+ return bos.toByteArray(); -+ } -+ -+ case 'V': { -+ String type = readType(); -+ int length = readLength(); -+ -+ return _serializerFactory.readList(this, length, type); -+ } -+ -+ case 'M': { -+ String type = readType(); -+ -+ return _serializerFactory.readMap(this, type); -+ } -+ -+ case 'R': { -+ int ref = parseInt(); -+ -+ return _refs.get(ref); -+ } -+ -+ case 'r': { -+ String type = readType(); -+ String url = readString(); -+ -+ return resolveRemote(type, url); -+ } -+ -+ default: -+ throw error("unknown code for readObject at " + codeName(tag)); -+ } -+ } -+ -+ /** -+ * Reads a remote object. -+ */ -+ public Object readRemote() -+ throws IOException -+ { -+ String type = readType(); -+ String url = readString(); -+ -+ return resolveRemote(type, url); -+ } -+ -+ /** -+ * Reads a reference. -+ */ -+ public Object readRef() -+ throws IOException -+ { -+ return _refs.get(parseInt()); -+ } -+ -+ /** -+ * Reads the start of a list. -+ */ -+ public int readListStart() -+ throws IOException -+ { -+ return read(); -+ } -+ -+ /** -+ * Reads the start of a list. -+ */ -+ public int readMapStart() -+ throws IOException -+ { -+ return read(); -+ } -+ -+ /** -+ * Returns true if this is the end of a list or a map. -+ */ -+ public boolean isEnd() -+ throws IOException -+ { -+ int code = read(); -+ -+ _peek = code; -+ -+ return (code < 0 || code == 'z'); -+ } -+ -+ /** -+ * Reads the end byte. -+ */ -+ public void readEnd() -+ throws IOException -+ { -+ int code = read(); -+ -+ if (code != 'z') -+ throw error("unknown code at " + codeName(code)); -+ } -+ -+ /** -+ * Reads the end byte. -+ */ -+ public void readMapEnd() -+ throws IOException -+ { -+ int code = read(); -+ -+ if (code != 'z') -+ throw error("expected end of map ('z') at " + codeName(code)); -+ } -+ -+ /** -+ * Reads the end byte. -+ */ -+ public void readListEnd() -+ throws IOException -+ { -+ int code = read(); -+ -+ if (code != 'z') -+ throw error("expected end of list ('z') at " + codeName(code)); -+ } -+ -+ /** -+ * Adds a list/map reference. -+ */ -+ public int addRef(Object ref) -+ { -+ if (_refs == null) -+ _refs = new ArrayList(); -+ -+ _refs.add(ref); -+ -+ return _refs.size() - 1; -+ } -+ -+ /** -+ * Adds a list/map reference. -+ */ -+ public void setRef(int i, Object ref) -+ { -+ _refs.set(i, ref); -+ } -+ -+ /** -+ * Resets the references for streaming. -+ */ -+ public void resetReferences() -+ { -+ if (_refs != null) -+ _refs.clear(); -+ } -+ -+ /** -+ * Resolves a remote object. -+ */ -+ public Object resolveRemote(String type, String url) -+ throws IOException -+ { -+ HessianRemoteResolver resolver = getRemoteResolver(); -+ -+ if (resolver != null) -+ return resolver.lookup(type, url); -+ else -+ return new HessianRemote(type, url); -+ } -+ -+ /** -+ * Parses a type from the stream. -+ * -+ *
-+   * t b16 b8
-+   * 
-+ */ -+ public String readType() -+ throws IOException -+ { -+ int code = read(); -+ -+ if (code != 't') { -+ _peek = code; -+ return ""; -+ } -+ -+ _isLastChunk = true; -+ _chunkLength = (read() << 8) + read(); -+ -+ _sbuf.setLength(0); -+ int ch; -+ while ((ch = parseChar()) >= 0) -+ _sbuf.append((char) ch); -+ -+ return _sbuf.toString(); -+ } -+ -+ /** -+ * Parses the length for an array -+ * -+ *
-+   * l b32 b24 b16 b8
-+   * 
-+ */ -+ public int readLength() -+ throws IOException -+ { -+ int code = read(); -+ -+ if (code != 'l') { -+ _peek = code; -+ return -1; -+ } -+ -+ return parseInt(); -+ } -+ -+ /** -+ * Parses a 32-bit integer value from the stream. -+ * -+ *
-+   * b32 b24 b16 b8
-+   * 
-+ */ -+ private int parseInt() -+ throws IOException -+ { -+ int b32 = read(); -+ int b24 = read(); -+ int b16 = read(); -+ int b8 = read(); -+ -+ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -+ } -+ -+ /** -+ * Parses a 64-bit long value from the stream. -+ * -+ *
-+   * b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ private long parseLong() -+ throws IOException -+ { -+ long b64 = read(); -+ long b56 = read(); -+ long b48 = read(); -+ long b40 = read(); -+ long b32 = read(); -+ long b24 = read(); -+ long b16 = read(); -+ long b8 = read(); -+ -+ return ((b64 << 56) + -+ (b56 << 48) + -+ (b48 << 40) + -+ (b40 << 32) + -+ (b32 << 24) + -+ (b24 << 16) + -+ (b16 << 8) + -+ b8); -+ } -+ -+ /** -+ * Parses a 64-bit double value from the stream. -+ * -+ *
-+   * b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ private double parseDouble() -+ throws IOException -+ { -+ long b64 = read(); -+ long b56 = read(); -+ long b48 = read(); -+ long b40 = read(); -+ long b32 = read(); -+ long b24 = read(); -+ long b16 = read(); -+ long b8 = read(); -+ -+ long bits = ((b64 << 56) + -+ (b56 << 48) + -+ (b48 << 40) + -+ (b40 << 32) + -+ (b32 << 24) + -+ (b24 << 16) + -+ (b16 << 8) + -+ b8); -+ -+ return Double.longBitsToDouble(bits); -+ } -+ -+ org.w3c.dom.Node parseXML() -+ throws IOException -+ { -+ throw new UnsupportedOperationException(); -+ } -+ -+ /** -+ * Reads a character from the underlying stream. -+ */ -+ private int parseChar() -+ throws IOException -+ { -+ while (_chunkLength <= 0) { -+ if (_isLastChunk) -+ return -1; -+ -+ int code = read(); -+ -+ switch (code) { -+ case 's': -+ case 'x': -+ _isLastChunk = false; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 'S': -+ case 'X': -+ _isLastChunk = true; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw expect("string", code); -+ } -+ -+ } -+ -+ _chunkLength--; -+ -+ return parseUTF8Char(); -+ } -+ -+ /** -+ * Parses a single UTF8 character. -+ */ -+ private int parseUTF8Char() -+ throws IOException -+ { -+ int ch = read(); -+ -+ if (ch < 0x80) -+ return ch; -+ else if ((ch & 0xe0) == 0xc0) { -+ int ch1 = read(); -+ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -+ -+ return v; -+ } -+ else if ((ch & 0xf0) == 0xe0) { -+ int ch1 = read(); -+ int ch2 = read(); -+ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -+ -+ return v; -+ } -+ else -+ throw error("bad utf-8 encoding at " + codeName(ch)); -+ } -+ -+ /** -+ * Reads a byte from the underlying stream. -+ */ -+ private int parseByte() -+ throws IOException -+ { -+ while (_chunkLength <= 0) { -+ if (_isLastChunk) { -+ return -1; -+ } -+ -+ int code = read(); -+ -+ switch (code) { -+ case 'b': -+ _isLastChunk = false; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 'B': -+ _isLastChunk = true; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw expect("byte[]", code); -+ } -+ } -+ -+ _chunkLength--; -+ -+ return read(); -+ } -+ -+ /** -+ * Reads bytes based on an input stream. -+ */ -+ public InputStream readInputStream() -+ throws IOException -+ { -+ int tag = read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'B': -+ case 'b': -+ _isLastChunk = tag == 'B'; -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw expect("inputStream", tag); -+ } -+ -+ return new InputStream() { -+ boolean _isClosed = false; -+ -+ public int read() -+ throws IOException -+ { -+ if (_isClosed || _is == null) -+ return -1; -+ -+ int ch = parseByte(); -+ if (ch < 0) -+ _isClosed = true; -+ -+ return ch; -+ } -+ -+ public int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (_isClosed || _is == null) -+ return -1; -+ -+ int len = HessianInput.this.read(buffer, offset, length); -+ if (len < 0) -+ _isClosed = true; -+ -+ return len; -+ } -+ -+ public void close() -+ throws IOException -+ { -+ while (read() >= 0) { -+ } -+ -+ _isClosed = true; -+ } -+ }; -+ } -+ -+ /** -+ * Reads bytes from the underlying stream. -+ */ -+ int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ int readLength = 0; -+ -+ while (length > 0) { -+ while (_chunkLength <= 0) { -+ if (_isLastChunk) -+ return readLength == 0 ? -1 : readLength; -+ -+ int code = read(); -+ -+ switch (code) { -+ case 'b': -+ _isLastChunk = false; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ case 'B': -+ _isLastChunk = true; -+ -+ _chunkLength = (read() << 8) + read(); -+ break; -+ -+ default: -+ throw expect("byte[]", code); -+ } -+ } -+ -+ int sublen = _chunkLength; -+ if (length < sublen) -+ sublen = length; -+ -+ sublen = _is.read(buffer, offset, sublen); -+ offset += sublen; -+ readLength += sublen; -+ length -= sublen; -+ _chunkLength -= sublen; -+ } -+ -+ return readLength; -+ } -+ -+ final int read() -+ throws IOException -+ { -+ if (_peek >= 0) { -+ int value = _peek; -+ _peek = -1; -+ return value; -+ } -+ -+ int ch = _is.read(); -+ -+ return ch; -+ } -+ -+ public void close() -+ { -+ _is = null; -+ } -+ -+ public Reader getReader() -+ { -+ return null; -+ } -+ -+ protected IOException expect(String expect, int ch) -+ { -+ return error("expected " + expect + " at " + codeName(ch)); -+ } -+ -+ protected String codeName(int ch) -+ { -+ if (ch < 0) -+ return "end of file"; -+ else -+ return "0x" + Integer.toHexString(ch & 0xff) + " (" + (char) + ch + ")"; -+ } -+ -+ protected IOException error(String message) -+ { -+ if (_method != null) -+ return new HessianProtocolException(_method + ": " + message); -+ else -+ return new HessianProtocolException(message); -+ } -+ -+ static { -+ try { -+ _detailMessageField = Throwable.class.getDeclaredField("detailMessage"); -+ _detailMessageField.setAccessible(true); -+ } catch (Throwable e) { -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianInputFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianInputFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianInputFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianInputFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,173 +1,173 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.logging.*; --import java.io.*; -- --public class HessianInputFactory --{ -- public static final Logger log -- = Logger.getLogger(HessianInputFactory.class.getName()); -- -- private HessianFactory _factory = new HessianFactory(); -- -- public void setSerializerFactory(SerializerFactory factory) -- { -- _factory.setSerializerFactory(factory); -- } -- -- public SerializerFactory getSerializerFactory() -- { -- return _factory.getSerializerFactory(); -- } -- -- public HeaderType readHeader(InputStream is) -- throws IOException -- { -- int code = is.read(); -- -- int major = is.read(); -- int minor = is.read(); -- -- switch (code) { -- case -1: -- throw new IOException("Unexpected end of file for Hessian message"); -- -- case 'c': -- if (major >= 2) -- return HeaderType.CALL_1_REPLY_2; -- else -- return HeaderType.CALL_1_REPLY_1; -- case 'r': -- return HeaderType.REPLY_1; -- -- case 'H': -- return HeaderType.HESSIAN_2; -- -- default: -- throw new IOException((char) code + " 0x" + Integer.toHexString(code) + " is an unknown Hessian message code."); -- } -- } -- -- public AbstractHessianInput open(InputStream is) -- throws IOException -- { -- int code = is.read(); -- -- int major = is.read(); -- int minor = is.read(); -- -- switch (code) { -- case 'c': -- case 'C': -- case 'r': -- case 'R': -- if (major >= 2) { -- return _factory.createHessian2Input(is); -- } -- else { -- return _factory.createHessianInput(is); -- } -- -- default: -- throw new IOException((char) code + " is an unknown Hessian message code."); -- } -- } -- -- public enum HeaderType { -- CALL_1_REPLY_1, -- CALL_1_REPLY_2, -- HESSIAN_2, -- REPLY_1, -- REPLY_2; -- -- public boolean isCall1() -- { -- switch (this) { -- case CALL_1_REPLY_1: -- case CALL_1_REPLY_2: -- return true; -- default: -- return false; -- } -- } -- -- public boolean isCall2() -- { -- switch (this) { -- case HESSIAN_2: -- return true; -- default: -- return false; -- } -- } -- -- public boolean isReply1() -- { -- switch (this) { -- case CALL_1_REPLY_1: -- return true; -- default: -- return false; -- } -- } -- -- public boolean isReply2() -- { -- switch (this) { -- case CALL_1_REPLY_2: -- case HESSIAN_2: -- return true; -- default: -- return false; -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.logging.*; -+import java.io.*; -+ -+public class HessianInputFactory -+{ -+ public static final Logger log -+ = Logger.getLogger(HessianInputFactory.class.getName()); -+ -+ private HessianFactory _factory = new HessianFactory(); -+ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _factory.setSerializerFactory(factory); -+ } -+ -+ public SerializerFactory getSerializerFactory() -+ { -+ return _factory.getSerializerFactory(); -+ } -+ -+ public HeaderType readHeader(InputStream is) -+ throws IOException -+ { -+ int code = is.read(); -+ -+ int major = is.read(); -+ int minor = is.read(); -+ -+ switch (code) { -+ case -1: -+ throw new IOException("Unexpected end of file for Hessian message"); -+ -+ case 'c': -+ if (major >= 2) -+ return HeaderType.CALL_1_REPLY_2; -+ else -+ return HeaderType.CALL_1_REPLY_1; -+ case 'r': -+ return HeaderType.REPLY_1; -+ -+ case 'H': -+ return HeaderType.HESSIAN_2; -+ -+ default: -+ throw new IOException((char) code + " 0x" + Integer.toHexString(code) + " is an unknown Hessian message code."); -+ } -+ } -+ -+ public AbstractHessianInput open(InputStream is) -+ throws IOException -+ { -+ int code = is.read(); -+ -+ int major = is.read(); -+ int minor = is.read(); -+ -+ switch (code) { -+ case 'c': -+ case 'C': -+ case 'r': -+ case 'R': -+ if (major >= 2) { -+ return _factory.createHessian2Input(is); -+ } -+ else { -+ return _factory.createHessianInput(is); -+ } -+ -+ default: -+ throw new IOException((char) code + " is an unknown Hessian message code."); -+ } -+ } -+ -+ public enum HeaderType { -+ CALL_1_REPLY_1, -+ CALL_1_REPLY_2, -+ HESSIAN_2, -+ REPLY_1, -+ REPLY_2; -+ -+ public boolean isCall1() -+ { -+ switch (this) { -+ case CALL_1_REPLY_1: -+ case CALL_1_REPLY_2: -+ return true; -+ default: -+ return false; -+ } -+ } -+ -+ public boolean isCall2() -+ { -+ switch (this) { -+ case HESSIAN_2: -+ return true; -+ default: -+ return false; -+ } -+ } -+ -+ public boolean isReply1() -+ { -+ switch (this) { -+ case CALL_1_REPLY_1: -+ return true; -+ default: -+ return false; -+ } -+ } -+ -+ public boolean isReply2() -+ { -+ switch (this) { -+ case CALL_1_REPLY_2: -+ case HESSIAN_2: -+ return true; -+ default: -+ return false; -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianMethodSerializationException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianMethodSerializationException.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianMethodSerializationException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianMethodSerializationException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,88 +1,88 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import com.caucho.hessian.HessianException; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroHessianInput. -- */ --public class HessianMethodSerializationException extends HessianException { -- /** -- * Zero-arg constructor. -- */ -- public HessianMethodSerializationException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public HessianMethodSerializationException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public HessianMethodSerializationException(String message, Throwable cause) -- { -- super(message, cause); -- } -- -- /** -- * Create the exception. -- */ -- public HessianMethodSerializationException(Throwable cause) -- { -- super(cause); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroHessianInput. -+ */ -+public class HessianMethodSerializationException extends HessianException { -+ /** -+ * Zero-arg constructor. -+ */ -+ public HessianMethodSerializationException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianMethodSerializationException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianMethodSerializationException(String message, Throwable cause) -+ { -+ super(message, cause); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianMethodSerializationException(Throwable cause) -+ { -+ super(cause); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianOutput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,973 +1,973 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.OutputStream; --import java.util.IdentityHashMap; -- --/** -- * Output stream for Hessian requests, compatible with microedition -- * Java. It only uses classes and types available in JDK. -- * -- *

Since HessianOutput does not depend on any classes other than -- * in the JDK, it can be extracted independently into a smaller package. -- * -- *

HessianOutput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * OutputStream os = ...; // from http connection
-- * HessianOutput out = new HessianOutput(os);
-- * String value;
-- *
-- * out.startCall("hello");  // start hello call
-- * out.writeString("arg1"); // write a string argument
-- * out.completeCall();      // complete the call
-- * 
-- */ --public class HessianOutput extends AbstractHessianOutput { -- // the output stream/ -- protected OutputStream os; -- // map of references -- private IdentityHashMap _refs; -- private int _version = 1; -- -- /** -- * Creates a new Hessian output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public HessianOutput(OutputStream os) -- { -- init(os); -- } -- -- /** -- * Creates an uninitialized Hessian output stream. -- */ -- public HessianOutput() -- { -- } -- -- /** -- * Initializes the output -- */ -- public void init(OutputStream os) -- { -- this.os = os; -- -- _refs = null; -- -- if (_serializerFactory == null) -- _serializerFactory = new SerializerFactory(); -- } -- -- /** -- * Sets the client's version. -- */ -- public void setVersion(int version) -- { -- _version = version; -- } -- -- /** -- * Writes a complete method call. -- */ -- public void call(String method, Object []args) -- throws IOException -- { -- int length = args != null ? args.length : 0; -- -- startCall(method, length); -- -- for (int i = 0; i < length; i++) -- writeObject(args[i]); -- -- completeCall(); -- } -- -- /** -- * Starts the method call. Clients would use startCall -- * instead of call if they wanted finer control over -- * writing the arguments, or needed to write headers. -- * -- *
--   * c major minor
--   * m b16 b8 method-name
--   * 
-- * -- * @param method the method name to call. -- */ -- public void startCall(String method, int length) -- throws IOException -- { -- os.write('c'); -- os.write(_version); -- os.write(0); -- -- os.write('m'); -- int len = method.length(); -- os.write(len >> 8); -- os.write(len); -- printString(method, 0, len); -- } -- -- /** -- * Writes the call tag. This would be followed by the -- * headers and the method tag. -- * -- *
--   * c major minor
--   * 
-- * -- * @param method the method name to call. -- */ -- public void startCall() -- throws IOException -- { -- os.write('c'); -- os.write(0); -- os.write(1); -- } -- -- /** -- * Writes the method tag. -- * -- *
--   * m b16 b8 method-name
--   * 
-- * -- * @param method the method name to call. -- */ -- public void writeMethod(String method) -- throws IOException -- { -- os.write('m'); -- int len = method.length(); -- os.write(len >> 8); -- os.write(len); -- printString(method, 0, len); -- } -- -- /** -- * Completes. -- * -- *
--   * z
--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- os.write('z'); -- } -- -- /** -- * Starts the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * r
--   * 
-- */ -- public void startReply() -- throws IOException -- { -- os.write('r'); -- os.write(1); -- os.write(0); -- } -- -- /** -- * Completes reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeReply() -- throws IOException -- { -- os.write('z'); -- } -- -- /** -- * Writes a header name. The header value must immediately follow. -- * -- *
--   * H b16 b8 foo value
--   * 
-- */ -- public void writeHeader(String name) -- throws IOException -- { -- int len = name.length(); -- -- os.write('H'); -- os.write(len >> 8); -- os.write(len); -- -- printString(name); -- } -- -- /** -- * Writes a fault. The fault will be written -- * as a descriptive string followed by an object: -- * -- *
--   * f
--   * <string>code
--   * <string>the fault code
--   *
--   * <string>message
--   * <string>the fault mesage
--   *
--   * <string>detail
--   * mt\x00\xnnjavax.ejb.FinderException
--   *     ...
--   * z
--   * z
--   * 
-- * -- * @param code the fault code, a three digit -- */ -- public void writeFault(String code, String message, Object detail) -- throws IOException -- { -- // hessian/3525 -- os.write('r'); -- os.write(1); -- os.write(0); -- -- os.write('f'); -- writeString("code"); -- writeString(code); -- -- writeString("message"); -- writeString(message); -- -- if (detail != null) { -- writeString("detail"); -- writeObject(detail); -- } -- os.write('z'); -- -- os.write('z'); -- } -- -- /** -- * Writes any object to the output stream. -- */ -- public void writeObject(Object object) -- throws IOException -- { -- if (object == null) { -- writeNull(); -- return; -- } -- -- Serializer serializer; -- -- serializer = _serializerFactory.getSerializer(object.getClass()); -- -- serializer.writeObject(object, this); -- } -- -- /** -- * Writes the list header to the stream. List writers will call -- * writeListBegin followed by the list contents and then -- * call writeListEnd. -- * -- *
--   * V
--   * t b16 b8 type
--   * l b32 b24 b16 b8
--   * 
-- */ -- public boolean writeListBegin(int length, String type) -- throws IOException -- { -- os.write('V'); -- -- if (type != null) { -- os.write('t'); -- printLenString(type); -- } -- -- if (length >= 0) { -- os.write('l'); -- os.write(length >> 24); -- os.write(length >> 16); -- os.write(length >> 8); -- os.write(length); -- } -- -- return true; -- } -- -- /** -- * Writes the tail of the list to the stream. -- */ -- public void writeListEnd() -- throws IOException -- { -- os.write('z'); -- } -- -- /** -- * Writes the map header to the stream. Map writers will call -- * writeMapBegin followed by the map contents and then -- * call writeMapEnd. -- * -- *
--   * Mt b16 b8 ( )z
--   * 
-- */ -- public void writeMapBegin(String type) -- throws IOException -- { -- os.write('M'); -- os.write('t'); -- printLenString(type); -- } -- -- /** -- * Writes the tail of the map to the stream. -- */ -- public void writeMapEnd() -- throws IOException -- { -- os.write('z'); -- } -- -- /** -- * Writes a remote object reference to the stream. The type is the -- * type of the remote interface. -- * -- *
--   * 'r' 't' b16 b8 type url
--   * 
-- */ -- public void writeRemote(String type, String url) -- throws IOException -- { -- os.write('r'); -- os.write('t'); -- printLenString(type); -- os.write('S'); -- printLenString(url); -- } -- -- /** -- * Writes a boolean value to the stream. The boolean will be written -- * with the following syntax: -- * -- *
--   * T
--   * F
--   * 
-- * -- * @param value the boolean value to write. -- */ -- public void writeBoolean(boolean value) -- throws IOException -- { -- if (value) -- os.write('T'); -- else -- os.write('F'); -- } -- -- /** -- * Writes an integer value to the stream. The integer will be written -- * with the following syntax: -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeInt(int value) -- throws IOException -- { -- os.write('I'); -- os.write(value >> 24); -- os.write(value >> 16); -- os.write(value >> 8); -- os.write(value); -- } -- -- /** -- * Writes a long value to the stream. The long will be written -- * with the following syntax: -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param value the long value to write. -- */ -- public void writeLong(long value) -- throws IOException -- { -- os.write('L'); -- os.write((byte) (value >> 56)); -- os.write((byte) (value >> 48)); -- os.write((byte) (value >> 40)); -- os.write((byte) (value >> 32)); -- os.write((byte) (value >> 24)); -- os.write((byte) (value >> 16)); -- os.write((byte) (value >> 8)); -- os.write((byte) (value)); -- } -- -- /** -- * Writes a double value to the stream. The double will be written -- * with the following syntax: -- * -- *
--   * D b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param value the double value to write. -- */ -- public void writeDouble(double value) -- throws IOException -- { -- long bits = Double.doubleToLongBits(value); -- -- os.write('D'); -- os.write((byte) (bits >> 56)); -- os.write((byte) (bits >> 48)); -- os.write((byte) (bits >> 40)); -- os.write((byte) (bits >> 32)); -- os.write((byte) (bits >> 24)); -- os.write((byte) (bits >> 16)); -- os.write((byte) (bits >> 8)); -- os.write((byte) (bits)); -- } -- -- /** -- * Writes a date to the stream. -- * -- *
--   * T  b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param time the date in milliseconds from the epoch in UTC -- */ -- public void writeUTCDate(long time) -- throws IOException -- { -- os.write('d'); -- os.write((byte) (time >> 56)); -- os.write((byte) (time >> 48)); -- os.write((byte) (time >> 40)); -- os.write((byte) (time >> 32)); -- os.write((byte) (time >> 24)); -- os.write((byte) (time >> 16)); -- os.write((byte) (time >> 8)); -- os.write((byte) (time)); -- } -- -- /** -- * Writes a null value to the stream. -- * The null will be written with the following syntax -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeNull() -- throws IOException -- { -- os.write('N'); -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(String value) -- throws IOException -- { -- if (value == null) { -- os.write('N'); -- } -- else { -- int length = value.length(); -- int offset = 0; -- -- while (length > 0x8000) { -- int sublen = 0x8000; -- -- // chunk can't end in high surrogate -- char tail = value.charAt(offset + sublen - 1); -- -- if (0xd800 <= tail && tail <= 0xdbff) -- sublen--; -- -- os.write('s'); -- os.write(sublen >> 8); -- os.write(sublen); -- -- printString(value, offset, sublen); -- -- length -= sublen; -- offset += sublen; -- } -- -- os.write('S'); -- os.write(length >> 8); -- os.write(length); -- -- printString(value, offset, length); -- } -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(char []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- os.write('N'); -- } -- else { -- while (length > 0x8000) { -- int sublen = 0x8000; -- -- // chunk can't end in high surrogate -- char tail = buffer[offset + sublen - 1]; -- -- if (0xd800 <= tail && tail <= 0xdbff) -- sublen--; -- -- os.write('s'); -- os.write(sublen >> 8); -- os.write(sublen); -- -- printString(buffer, offset, sublen); -- -- length -= sublen; -- offset += sublen; -- } -- -- os.write('S'); -- os.write(length >> 8); -- os.write(length); -- -- printString(buffer, offset, length); -- } -- } -- -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer) -- throws IOException -- { -- if (buffer == null) -- os.write('N'); -- else -- writeBytes(buffer, 0, buffer.length); -- } -- -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- os.write('N'); -- } -- else { -- while (length > 0x8000) { -- int sublen = 0x8000; -- -- os.write('b'); -- os.write(sublen >> 8); -- os.write(sublen); -- -- os.write(buffer, offset, sublen); -- -- length -= sublen; -- offset += sublen; -- } -- -- os.write('B'); -- os.write(length >> 8); -- os.write(length); -- os.write(buffer, offset, length); -- } -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * 
-- */ -- public void writeByteBufferStart() -- throws IOException -- { -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- */ -- public void writeByteBufferPart(byte []buffer, int offset, int length) -- throws IOException -- { -- while (length > 0) { -- int sublen = length; -- -- if (0x8000 < sublen) -- sublen = 0x8000; -- -- os.write('b'); -- os.write(sublen >> 8); -- os.write(sublen); -- -- os.write(buffer, offset, sublen); -- -- length -= sublen; -- offset += sublen; -- } -- } -- -- /** -- * Writes a byte buffer to the stream. -- * -- *
--   * b b16 b18 bytes
--   * 
-- */ -- public void writeByteBufferEnd(byte []buffer, int offset, int length) -- throws IOException -- { -- writeBytes(buffer, offset, length); -- } -- -- /** -- * Writes a reference. -- * -- *
--   * R b32 b24 b16 b8
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeRef(int value) -- throws IOException -- { -- os.write('R'); -- os.write(value >> 24); -- os.write(value >> 16); -- os.write(value >> 8); -- os.write(value); -- } -- -- /** -- * Writes a placeholder. -- * -- *
--   * P
--   * 
-- */ -- public void writePlaceholder() -- throws IOException -- { -- os.write('P'); -- } -- -- /** -- * If the object has already been written, just write its ref. -- * -- * @return true if we're writing a ref. -- */ -- public boolean addRef(Object object) -- throws IOException -- { -- if (_refs == null) -- _refs = new IdentityHashMap(); -- -- Integer ref = (Integer) _refs.get(object); -- -- if (ref != null) { -- int value = ref.intValue(); -- -- writeRef(value); -- return true; -- } -- else { -- _refs.put(object, new Integer(_refs.size())); -- -- return false; -- } -- } -- -- @Override -- public int getRef(Object obj) -- { -- Integer value; -- -- if (_refs == null) -- return -1; -- -- value = (Integer) _refs.get(obj); -- -- if (value == null) -- return -1; -- else -- return value; -- } -- -- /** -- * Resets the references for streaming. -- */ -- public void resetReferences() -- { -- if (_refs != null) -- _refs.clear(); -- } -- -- /** -- * Removes a reference. -- */ -- public boolean removeRef(Object obj) -- throws IOException -- { -- if (_refs != null) { -- _refs.remove(obj); -- -- return true; -- } -- else -- return false; -- } -- -- /** -- * Replaces a reference from one object to another. -- */ -- public boolean replaceRef(Object oldRef, Object newRef) -- throws IOException -- { -- Integer value = (Integer) _refs.remove(oldRef); -- -- if (value != null) { -- _refs.put(newRef, value); -- -- return true; -- } -- else -- return false; -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 with preceeding length -- * -- * @param v the string to print. -- */ -- public void printLenString(String v) -- throws IOException -- { -- if (v == null) { -- os.write(0); -- os.write(0); -- } -- else { -- int len = v.length(); -- os.write(len >> 8); -- os.write(len); -- -- printString(v, 0, len); -- } -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v) -- throws IOException -- { -- printString(v, 0, v.length()); -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v, int offset, int length) -- throws IOException -- { -- for (int i = 0; i < length; i++) { -- char ch = v.charAt(i + offset); -- -- if (ch < 0x80) -- os.write(ch); -- else if (ch < 0x800) { -- os.write(0xc0 + ((ch >> 6) & 0x1f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- else { -- os.write(0xe0 + ((ch >> 12) & 0xf)); -- os.write(0x80 + ((ch >> 6) & 0x3f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- } -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(char []v, int offset, int length) -- throws IOException -- { -- for (int i = 0; i < length; i++) { -- char ch = v[i + offset]; -- -- if (ch < 0x80) -- os.write(ch); -- else if (ch < 0x800) { -- os.write(0xc0 + ((ch >> 6) & 0x1f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- else { -- os.write(0xe0 + ((ch >> 12) & 0xf)); -- os.write(0x80 + ((ch >> 6) & 0x3f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- } -- } -- -- public void flush() -- throws IOException -- { -- if (this.os != null) -- this.os.flush(); -- } -- -- public void close() -- throws IOException -- { -- if (this.os != null) -- this.os.flush(); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+import java.util.IdentityHashMap; -+ -+/** -+ * Output stream for Hessian requests, compatible with microedition -+ * Java. It only uses classes and types available in JDK. -+ * -+ *

Since HessianOutput does not depend on any classes other than -+ * in the JDK, it can be extracted independently into a smaller package. -+ * -+ *

HessianOutput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * OutputStream os = ...; // from http connection
-+ * HessianOutput out = new HessianOutput(os);
-+ * String value;
-+ *
-+ * out.startCall("hello");  // start hello call
-+ * out.writeString("arg1"); // write a string argument
-+ * out.completeCall();      // complete the call
-+ * 
-+ */ -+public class HessianOutput extends AbstractHessianOutput { -+ // the output stream/ -+ protected OutputStream os; -+ // map of references -+ private IdentityHashMap _refs; -+ private int _version = 1; -+ -+ /** -+ * Creates a new Hessian output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public HessianOutput(OutputStream os) -+ { -+ init(os); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian output stream. -+ */ -+ public HessianOutput() -+ { -+ } -+ -+ /** -+ * Initializes the output -+ */ -+ public void init(OutputStream os) -+ { -+ this.os = os; -+ -+ _refs = null; -+ -+ if (_serializerFactory == null) -+ _serializerFactory = new SerializerFactory(); -+ } -+ -+ /** -+ * Sets the client's version. -+ */ -+ public void setVersion(int version) -+ { -+ _version = version; -+ } -+ -+ /** -+ * Writes a complete method call. -+ */ -+ public void call(String method, Object []args) -+ throws IOException -+ { -+ int length = args != null ? args.length : 0; -+ -+ startCall(method, length); -+ -+ for (int i = 0; i < length; i++) -+ writeObject(args[i]); -+ -+ completeCall(); -+ } -+ -+ /** -+ * Starts the method call. Clients would use startCall -+ * instead of call if they wanted finer control over -+ * writing the arguments, or needed to write headers. -+ * -+ *
-+   * c major minor
-+   * m b16 b8 method-name
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void startCall(String method, int length) -+ throws IOException -+ { -+ os.write('c'); -+ os.write(_version); -+ os.write(0); -+ -+ os.write('m'); -+ int len = method.length(); -+ os.write(len >> 8); -+ os.write(len); -+ printString(method, 0, len); -+ } -+ -+ /** -+ * Writes the call tag. This would be followed by the -+ * headers and the method tag. -+ * -+ *
-+   * c major minor
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void startCall() -+ throws IOException -+ { -+ os.write('c'); -+ os.write(0); -+ os.write(1); -+ } -+ -+ /** -+ * Writes the method tag. -+ * -+ *
-+   * m b16 b8 method-name
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void writeMethod(String method) -+ throws IOException -+ { -+ os.write('m'); -+ int len = method.length(); -+ os.write(len >> 8); -+ os.write(len); -+ printString(method, 0, len); -+ } -+ -+ /** -+ * Completes. -+ * -+ *
-+   * z
-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ os.write('z'); -+ } -+ -+ /** -+ * Starts the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * r
-+   * 
-+ */ -+ public void startReply() -+ throws IOException -+ { -+ os.write('r'); -+ os.write(1); -+ os.write(0); -+ } -+ -+ /** -+ * Completes reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeReply() -+ throws IOException -+ { -+ os.write('z'); -+ } -+ -+ /** -+ * Writes a header name. The header value must immediately follow. -+ * -+ *
-+   * H b16 b8 foo value
-+   * 
-+ */ -+ public void writeHeader(String name) -+ throws IOException -+ { -+ int len = name.length(); -+ -+ os.write('H'); -+ os.write(len >> 8); -+ os.write(len); -+ -+ printString(name); -+ } -+ -+ /** -+ * Writes a fault. The fault will be written -+ * as a descriptive string followed by an object: -+ * -+ *
-+   * f
-+   * <string>code
-+   * <string>the fault code
-+   *
-+   * <string>message
-+   * <string>the fault mesage
-+   *
-+   * <string>detail
-+   * mt\x00\xnnjavax.ejb.FinderException
-+   *     ...
-+   * z
-+   * z
-+   * 
-+ * -+ * @param code the fault code, a three digit -+ */ -+ public void writeFault(String code, String message, Object detail) -+ throws IOException -+ { -+ // hessian/3525 -+ os.write('r'); -+ os.write(1); -+ os.write(0); -+ -+ os.write('f'); -+ writeString("code"); -+ writeString(code); -+ -+ writeString("message"); -+ writeString(message); -+ -+ if (detail != null) { -+ writeString("detail"); -+ writeObject(detail); -+ } -+ os.write('z'); -+ -+ os.write('z'); -+ } -+ -+ /** -+ * Writes any object to the output stream. -+ */ -+ public void writeObject(Object object) -+ throws IOException -+ { -+ if (object == null) { -+ writeNull(); -+ return; -+ } -+ -+ Serializer serializer; -+ -+ serializer = _serializerFactory.getSerializer(object.getClass()); -+ -+ serializer.writeObject(object, this); -+ } -+ -+ /** -+ * Writes the list header to the stream. List writers will call -+ * writeListBegin followed by the list contents and then -+ * call writeListEnd. -+ * -+ *
-+   * V
-+   * t b16 b8 type
-+   * l b32 b24 b16 b8
-+   * 
-+ */ -+ public boolean writeListBegin(int length, String type) -+ throws IOException -+ { -+ os.write('V'); -+ -+ if (type != null) { -+ os.write('t'); -+ printLenString(type); -+ } -+ -+ if (length >= 0) { -+ os.write('l'); -+ os.write(length >> 24); -+ os.write(length >> 16); -+ os.write(length >> 8); -+ os.write(length); -+ } -+ -+ return true; -+ } -+ -+ /** -+ * Writes the tail of the list to the stream. -+ */ -+ public void writeListEnd() -+ throws IOException -+ { -+ os.write('z'); -+ } -+ -+ /** -+ * Writes the map header to the stream. Map writers will call -+ * writeMapBegin followed by the map contents and then -+ * call writeMapEnd. -+ * -+ *
-+   * Mt b16 b8 ( )z
-+   * 
-+ */ -+ public void writeMapBegin(String type) -+ throws IOException -+ { -+ os.write('M'); -+ os.write('t'); -+ printLenString(type); -+ } -+ -+ /** -+ * Writes the tail of the map to the stream. -+ */ -+ public void writeMapEnd() -+ throws IOException -+ { -+ os.write('z'); -+ } -+ -+ /** -+ * Writes a remote object reference to the stream. The type is the -+ * type of the remote interface. -+ * -+ *
-+   * 'r' 't' b16 b8 type url
-+   * 
-+ */ -+ public void writeRemote(String type, String url) -+ throws IOException -+ { -+ os.write('r'); -+ os.write('t'); -+ printLenString(type); -+ os.write('S'); -+ printLenString(url); -+ } -+ -+ /** -+ * Writes a boolean value to the stream. The boolean will be written -+ * with the following syntax: -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ * -+ * @param value the boolean value to write. -+ */ -+ public void writeBoolean(boolean value) -+ throws IOException -+ { -+ if (value) -+ os.write('T'); -+ else -+ os.write('F'); -+ } -+ -+ /** -+ * Writes an integer value to the stream. The integer will be written -+ * with the following syntax: -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeInt(int value) -+ throws IOException -+ { -+ os.write('I'); -+ os.write(value >> 24); -+ os.write(value >> 16); -+ os.write(value >> 8); -+ os.write(value); -+ } -+ -+ /** -+ * Writes a long value to the stream. The long will be written -+ * with the following syntax: -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the long value to write. -+ */ -+ public void writeLong(long value) -+ throws IOException -+ { -+ os.write('L'); -+ os.write((byte) (value >> 56)); -+ os.write((byte) (value >> 48)); -+ os.write((byte) (value >> 40)); -+ os.write((byte) (value >> 32)); -+ os.write((byte) (value >> 24)); -+ os.write((byte) (value >> 16)); -+ os.write((byte) (value >> 8)); -+ os.write((byte) (value)); -+ } -+ -+ /** -+ * Writes a double value to the stream. The double will be written -+ * with the following syntax: -+ * -+ *
-+   * D b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the double value to write. -+ */ -+ public void writeDouble(double value) -+ throws IOException -+ { -+ long bits = Double.doubleToLongBits(value); -+ -+ os.write('D'); -+ os.write((byte) (bits >> 56)); -+ os.write((byte) (bits >> 48)); -+ os.write((byte) (bits >> 40)); -+ os.write((byte) (bits >> 32)); -+ os.write((byte) (bits >> 24)); -+ os.write((byte) (bits >> 16)); -+ os.write((byte) (bits >> 8)); -+ os.write((byte) (bits)); -+ } -+ -+ /** -+ * Writes a date to the stream. -+ * -+ *
-+   * T  b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param time the date in milliseconds from the epoch in UTC -+ */ -+ public void writeUTCDate(long time) -+ throws IOException -+ { -+ os.write('d'); -+ os.write((byte) (time >> 56)); -+ os.write((byte) (time >> 48)); -+ os.write((byte) (time >> 40)); -+ os.write((byte) (time >> 32)); -+ os.write((byte) (time >> 24)); -+ os.write((byte) (time >> 16)); -+ os.write((byte) (time >> 8)); -+ os.write((byte) (time)); -+ } -+ -+ /** -+ * Writes a null value to the stream. -+ * The null will be written with the following syntax -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeNull() -+ throws IOException -+ { -+ os.write('N'); -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(String value) -+ throws IOException -+ { -+ if (value == null) { -+ os.write('N'); -+ } -+ else { -+ int length = value.length(); -+ int offset = 0; -+ -+ while (length > 0x8000) { -+ int sublen = 0x8000; -+ -+ // chunk can't end in high surrogate -+ char tail = value.charAt(offset + sublen - 1); -+ -+ if (0xd800 <= tail && tail <= 0xdbff) -+ sublen--; -+ -+ os.write('s'); -+ os.write(sublen >> 8); -+ os.write(sublen); -+ -+ printString(value, offset, sublen); -+ -+ length -= sublen; -+ offset += sublen; -+ } -+ -+ os.write('S'); -+ os.write(length >> 8); -+ os.write(length); -+ -+ printString(value, offset, length); -+ } -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(char []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ os.write('N'); -+ } -+ else { -+ while (length > 0x8000) { -+ int sublen = 0x8000; -+ -+ // chunk can't end in high surrogate -+ char tail = buffer[offset + sublen - 1]; -+ -+ if (0xd800 <= tail && tail <= 0xdbff) -+ sublen--; -+ -+ os.write('s'); -+ os.write(sublen >> 8); -+ os.write(sublen); -+ -+ printString(buffer, offset, sublen); -+ -+ length -= sublen; -+ offset += sublen; -+ } -+ -+ os.write('S'); -+ os.write(length >> 8); -+ os.write(length); -+ -+ printString(buffer, offset, length); -+ } -+ } -+ -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer) -+ throws IOException -+ { -+ if (buffer == null) -+ os.write('N'); -+ else -+ writeBytes(buffer, 0, buffer.length); -+ } -+ -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ os.write('N'); -+ } -+ else { -+ while (length > 0x8000) { -+ int sublen = 0x8000; -+ -+ os.write('b'); -+ os.write(sublen >> 8); -+ os.write(sublen); -+ -+ os.write(buffer, offset, sublen); -+ -+ length -= sublen; -+ offset += sublen; -+ } -+ -+ os.write('B'); -+ os.write(length >> 8); -+ os.write(length); -+ os.write(buffer, offset, length); -+ } -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * 
-+ */ -+ public void writeByteBufferStart() -+ throws IOException -+ { -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ */ -+ public void writeByteBufferPart(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ while (length > 0) { -+ int sublen = length; -+ -+ if (0x8000 < sublen) -+ sublen = 0x8000; -+ -+ os.write('b'); -+ os.write(sublen >> 8); -+ os.write(sublen); -+ -+ os.write(buffer, offset, sublen); -+ -+ length -= sublen; -+ offset += sublen; -+ } -+ } -+ -+ /** -+ * Writes a byte buffer to the stream. -+ * -+ *
-+   * b b16 b18 bytes
-+   * 
-+ */ -+ public void writeByteBufferEnd(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ writeBytes(buffer, offset, length); -+ } -+ -+ /** -+ * Writes a reference. -+ * -+ *
-+   * R b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeRef(int value) -+ throws IOException -+ { -+ os.write('R'); -+ os.write(value >> 24); -+ os.write(value >> 16); -+ os.write(value >> 8); -+ os.write(value); -+ } -+ -+ /** -+ * Writes a placeholder. -+ * -+ *
-+   * P
-+   * 
-+ */ -+ public void writePlaceholder() -+ throws IOException -+ { -+ os.write('P'); -+ } -+ -+ /** -+ * If the object has already been written, just write its ref. -+ * -+ * @return true if we're writing a ref. -+ */ -+ public boolean addRef(Object object) -+ throws IOException -+ { -+ if (_refs == null) -+ _refs = new IdentityHashMap(); -+ -+ Integer ref = (Integer) _refs.get(object); -+ -+ if (ref != null) { -+ int value = ref.intValue(); -+ -+ writeRef(value); -+ return true; -+ } -+ else { -+ _refs.put(object, new Integer(_refs.size())); -+ -+ return false; -+ } -+ } -+ -+ @Override -+ public int getRef(Object obj) -+ { -+ Integer value; -+ -+ if (_refs == null) -+ return -1; -+ -+ value = (Integer) _refs.get(obj); -+ -+ if (value == null) -+ return -1; -+ else -+ return value; -+ } -+ -+ /** -+ * Resets the references for streaming. -+ */ -+ public void resetReferences() -+ { -+ if (_refs != null) -+ _refs.clear(); -+ } -+ -+ /** -+ * Removes a reference. -+ */ -+ public boolean removeRef(Object obj) -+ throws IOException -+ { -+ if (_refs != null) { -+ _refs.remove(obj); -+ -+ return true; -+ } -+ else -+ return false; -+ } -+ -+ /** -+ * Replaces a reference from one object to another. -+ */ -+ public boolean replaceRef(Object oldRef, Object newRef) -+ throws IOException -+ { -+ Integer value = (Integer) _refs.remove(oldRef); -+ -+ if (value != null) { -+ _refs.put(newRef, value); -+ -+ return true; -+ } -+ else -+ return false; -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 with preceeding length -+ * -+ * @param v the string to print. -+ */ -+ public void printLenString(String v) -+ throws IOException -+ { -+ if (v == null) { -+ os.write(0); -+ os.write(0); -+ } -+ else { -+ int len = v.length(); -+ os.write(len >> 8); -+ os.write(len); -+ -+ printString(v, 0, len); -+ } -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v) -+ throws IOException -+ { -+ printString(v, 0, v.length()); -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v, int offset, int length) -+ throws IOException -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = v.charAt(i + offset); -+ -+ if (ch < 0x80) -+ os.write(ch); -+ else if (ch < 0x800) { -+ os.write(0xc0 + ((ch >> 6) & 0x1f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ else { -+ os.write(0xe0 + ((ch >> 12) & 0xf)); -+ os.write(0x80 + ((ch >> 6) & 0x3f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ } -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(char []v, int offset, int length) -+ throws IOException -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = v[i + offset]; -+ -+ if (ch < 0x80) -+ os.write(ch); -+ else if (ch < 0x800) { -+ os.write(0xc0 + ((ch >> 6) & 0x1f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ else { -+ os.write(0xe0 + ((ch >> 12) & 0xf)); -+ os.write(0x80 + ((ch >> 6) & 0x3f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ } -+ } -+ -+ public void flush() -+ throws IOException -+ { -+ if (this.os != null) -+ this.os.flush(); -+ } -+ -+ public void close() -+ throws IOException -+ { -+ if (this.os != null) -+ this.os.flush(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianProtocolException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianProtocolException.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianProtocolException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianProtocolException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,110 +1,110 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroHessianInput. -- */ --public class HessianProtocolException extends IOException { -- private Throwable rootCause; -- -- /** -- * Zero-arg constructor. -- */ -- public HessianProtocolException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public HessianProtocolException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public HessianProtocolException(String message, Throwable rootCause) -- { -- super(message); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Create the exception. -- */ -- public HessianProtocolException(Throwable rootCause) -- { -- super(String.valueOf(rootCause)); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getRootCause() -- { -- return rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getCause() -- { -- return getRootCause(); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroHessianInput. -+ */ -+public class HessianProtocolException extends IOException { -+ private Throwable rootCause; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public HessianProtocolException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianProtocolException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianProtocolException(String message, Throwable rootCause) -+ { -+ super(message); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianProtocolException(Throwable rootCause) -+ { -+ super(String.valueOf(rootCause)); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getRootCause() -+ { -+ return rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getCause() -+ { -+ return getRootCause(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianRemote.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemote.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianRemote.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemote.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,130 +1,130 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --/** -- * Encapsulates a remote address when no stub is available, e.g. for -- * Java MicroEdition. -- */ --public class HessianRemote implements java.io.Serializable { -- private String type; -- private String url; -- -- /** -- * Creates a new Hessian remote object. -- * -- * @param type the remote stub interface -- * @param url the remote url -- */ -- public HessianRemote(String type, String url) -- { -- this.type = type; -- this.url = url; -- } -- -- /** -- * Creates an uninitialized Hessian remote. -- */ -- public HessianRemote() -- { -- } -- -- /** -- * Returns the remote api class name. -- */ -- public String getType() -- { -- return type; -- } -- -- /** -- * Returns the remote URL. -- */ -- public String getURL() -- { -- return url; -- } -- -- /** -- * Sets the remote URL. -- */ -- public void setURL(String url) -- { -- this.url = url; -- } -- -- /** -- * Defines the hashcode. -- */ -- public int hashCode() -- { -- return url.hashCode(); -- } -- -- /** -- * Defines equality -- */ -- public boolean equals(Object obj) -- { -- if (! (obj instanceof HessianRemote)) -- return false; -- -- HessianRemote remote = (HessianRemote) obj; -- -- return url.equals(remote.url); -- } -- -- /** -- * Readable version of the remote. -- */ -- public String toString() -- { -- return "HessianRemote[" + url + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+/** -+ * Encapsulates a remote address when no stub is available, e.g. for -+ * Java MicroEdition. -+ */ -+public class HessianRemote implements java.io.Serializable { -+ private String type; -+ private String url; -+ -+ /** -+ * Creates a new Hessian remote object. -+ * -+ * @param type the remote stub interface -+ * @param url the remote url -+ */ -+ public HessianRemote(String type, String url) -+ { -+ this.type = type; -+ this.url = url; -+ } -+ -+ /** -+ * Creates an uninitialized Hessian remote. -+ */ -+ public HessianRemote() -+ { -+ } -+ -+ /** -+ * Returns the remote api class name. -+ */ -+ public String getType() -+ { -+ return type; -+ } -+ -+ /** -+ * Returns the remote URL. -+ */ -+ public String getURL() -+ { -+ return url; -+ } -+ -+ /** -+ * Sets the remote URL. -+ */ -+ public void setURL(String url) -+ { -+ this.url = url; -+ } -+ -+ /** -+ * Defines the hashcode. -+ */ -+ public int hashCode() -+ { -+ return url.hashCode(); -+ } -+ -+ /** -+ * Defines equality -+ */ -+ public boolean equals(Object obj) -+ { -+ if (! (obj instanceof HessianRemote)) -+ return false; -+ -+ HessianRemote remote = (HessianRemote) obj; -+ -+ return url.equals(remote.url); -+ } -+ -+ /** -+ * Readable version of the remote. -+ */ -+ public String toString() -+ { -+ return "HessianRemote[" + url + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteObject.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteObject.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteObject.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteObject.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,57 +1,57 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --/** -- * Interface for any hessian remote object. -- */ --public interface HessianRemoteObject { -- public String getHessianType(); -- public String getHessianURL(); --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+/** -+ * Interface for any hessian remote object. -+ */ -+public interface HessianRemoteObject { -+ public String getHessianType(); -+ public String getHessianURL(); -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteResolver.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteResolver.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianRemoteResolver.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianRemoteResolver.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,62 +1,62 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Looks up remote objects. The default just returns a HessianRemote object. -- */ --public interface HessianRemoteResolver { -- /** -- * Looks up a proxy object. -- */ -- public Object lookup(String type, String url) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Looks up remote objects. The default just returns a HessianRemote object. -+ */ -+public interface HessianRemoteResolver { -+ /** -+ * Looks up a proxy object. -+ */ -+ public Object lookup(String type, String url) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerInput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerInput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,184 +1,184 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; --import java.lang.reflect.Field; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.ArrayList; --import java.util.HashMap; -- --/** -- * Input stream for Hessian requests, deserializing objects using the -- * java.io.Serialization protocol. -- * -- *

HessianSerializerInput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

Serialization

-- * -- *
-- * InputStream is = new FileInputStream("test.xml");
-- * HessianOutput in = new HessianSerializerOutput(is);
-- *
-- * Object obj = in.readObject();
-- * is.close();
-- * 
-- * -- *

Parsing a Hessian reply

-- * -- *
-- * InputStream is = ...; // from http connection
-- * HessianInput in = new HessianSerializerInput(is);
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --public class HessianSerializerInput extends Hessian2Input { -- /** -- * Creates a new Hessian input stream, initialized with an -- * underlying input stream. -- * -- * @param is the underlying input stream. -- */ -- public HessianSerializerInput(InputStream is) -- { -- super(is); -- } -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public HessianSerializerInput() -- { -- super(null); -- } -- -- /** -- * Reads an object from the input stream. cl is known not to be -- * a Map. -- */ -- protected Object readObjectImpl(Class cl) -- throws IOException -- { -- try { -- Object obj = cl.newInstance(); -- -- if (_refs == null) -- _refs = new ArrayList(); -- _refs.add(obj); -- -- HashMap fieldMap = getFieldMap(cl); -- -- int code = read(); -- for (; code >= 0 && code != 'z'; code = read()) { -- unread(); -- -- Object key = readObject(); -- -- Field field = (Field) fieldMap.get(key); -- -- if (field != null) { -- Object value = readObject(field.getType()); -- field.set(obj, value); -- } -- else { -- Object value = readObject(); -- } -- } -- -- if (code != 'z') -- throw expect("map", code); -- -- // if there's a readResolve method, call it -- try { -- Method method = cl.getMethod("readResolve", new Class[0]); -- return method.invoke(obj, new Object[0]); -- } catch (Exception e) { -- } -- -- return obj; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- protected HashMap getFieldMap(Class cl) -- { -- HashMap fieldMap = new HashMap(); -- -- for (; cl != null; cl = cl.getSuperclass()) { -- Field []fields = cl.getDeclaredFields(); -- for (int i = 0; i < fields.length; i++) { -- Field field = fields[i]; -- -- if (Modifier.isTransient(field.getModifiers()) || -- Modifier.isStatic(field.getModifiers())) -- continue; -- -- // XXX: could parameterize the handler to only deal with public -- field.setAccessible(true); -- -- fieldMap.put(field.getName(), field); -- } -- } -- -- return fieldMap; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.lang.reflect.Field; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.ArrayList; -+import java.util.HashMap; -+ -+/** -+ * Input stream for Hessian requests, deserializing objects using the -+ * java.io.Serialization protocol. -+ * -+ *

HessianSerializerInput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

Serialization

-+ * -+ *
-+ * InputStream is = new FileInputStream("test.xml");
-+ * HessianOutput in = new HessianSerializerOutput(is);
-+ *
-+ * Object obj = in.readObject();
-+ * is.close();
-+ * 
-+ * -+ *

Parsing a Hessian reply

-+ * -+ *
-+ * InputStream is = ...; // from http connection
-+ * HessianInput in = new HessianSerializerInput(is);
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+public class HessianSerializerInput extends Hessian2Input { -+ /** -+ * Creates a new Hessian input stream, initialized with an -+ * underlying input stream. -+ * -+ * @param is the underlying input stream. -+ */ -+ public HessianSerializerInput(InputStream is) -+ { -+ super(is); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public HessianSerializerInput() -+ { -+ super(null); -+ } -+ -+ /** -+ * Reads an object from the input stream. cl is known not to be -+ * a Map. -+ */ -+ protected Object readObjectImpl(Class cl) -+ throws IOException -+ { -+ try { -+ Object obj = cl.newInstance(); -+ -+ if (_refs == null) -+ _refs = new ArrayList(); -+ _refs.add(obj); -+ -+ HashMap fieldMap = getFieldMap(cl); -+ -+ int code = read(); -+ for (; code >= 0 && code != 'z'; code = read()) { -+ unread(); -+ -+ Object key = readObject(); -+ -+ Field field = (Field) fieldMap.get(key); -+ -+ if (field != null) { -+ Object value = readObject(field.getType()); -+ field.set(obj, value); -+ } -+ else { -+ Object value = readObject(); -+ } -+ } -+ -+ if (code != 'z') -+ throw expect("map", code); -+ -+ // if there's a readResolve method, call it -+ try { -+ Method method = cl.getMethod("readResolve", new Class[0]); -+ return method.invoke(obj, new Object[0]); -+ } catch (Exception e) { -+ } -+ -+ return obj; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected HashMap getFieldMap(Class cl) -+ { -+ HashMap fieldMap = new HashMap(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isTransient(field.getModifiers()) || -+ Modifier.isStatic(field.getModifiers())) -+ continue; -+ -+ // XXX: could parameterize the handler to only deal with public -+ field.setAccessible(true); -+ -+ fieldMap.put(field.getName(), field); -+ } -+ } -+ -+ return fieldMap; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerOutput.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerOutput.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianSerializerOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianSerializerOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,147 +1,147 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.OutputStream; --import java.lang.reflect.Field; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; -- --/** -- * Output stream for Hessian requests. -- * -- *

HessianOutput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

Serialization

-- * -- *
-- * OutputStream os = new FileOutputStream("test.xml");
-- * HessianOutput out = new HessianSerializerOutput(os);
-- *
-- * out.writeObject(obj);
-- * os.close();
-- * 
-- * -- *

Writing an RPC Call

-- * -- *
-- * OutputStream os = ...; // from http connection
-- * HessianOutput out = new HessianSerializerOutput(os);
-- * String value;
-- *
-- * out.startCall("hello");  // start hello call
-- * out.writeString("arg1"); // write a string argument
-- * out.completeCall();      // complete the call
-- * 
-- */ --public class HessianSerializerOutput extends Hessian2Output { -- /** -- * Creates a new Hessian output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public HessianSerializerOutput(OutputStream os) -- { -- super(os); -- } -- -- /** -- * Creates an uninitialized Hessian output stream. -- */ -- public HessianSerializerOutput() -- { -- super(null); -- } -- -- /** -- * Applications which override this can do custom serialization. -- * -- * @param object the object to write. -- */ -- public void writeObjectImpl(Object obj) -- throws IOException -- { -- Class cl = obj.getClass(); -- -- try { -- Method method = cl.getMethod("writeReplace", new Class[0]); -- Object repl = method.invoke(obj, new Object[0]); -- -- writeObject(repl); -- return; -- } catch (Exception e) { -- } -- -- try { -- writeMapBegin(cl.getName()); -- for (; cl != null; cl = cl.getSuperclass()) { -- Field []fields = cl.getDeclaredFields(); -- for (int i = 0; i < fields.length; i++) { -- Field field = fields[i]; -- -- if (Modifier.isTransient(field.getModifiers()) || -- Modifier.isStatic(field.getModifiers())) -- continue; -- -- // XXX: could parameterize the handler to only deal with public -- field.setAccessible(true); -- -- writeString(field.getName()); -- writeObject(field.get(obj)); -- } -- } -- writeMapEnd(); -- } catch (IllegalAccessException e) { -- throw new IOExceptionWrapper(e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+import java.lang.reflect.Field; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+ -+/** -+ * Output stream for Hessian requests. -+ * -+ *

HessianOutput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

Serialization

-+ * -+ *
-+ * OutputStream os = new FileOutputStream("test.xml");
-+ * HessianOutput out = new HessianSerializerOutput(os);
-+ *
-+ * out.writeObject(obj);
-+ * os.close();
-+ * 
-+ * -+ *

Writing an RPC Call

-+ * -+ *
-+ * OutputStream os = ...; // from http connection
-+ * HessianOutput out = new HessianSerializerOutput(os);
-+ * String value;
-+ *
-+ * out.startCall("hello");  // start hello call
-+ * out.writeString("arg1"); // write a string argument
-+ * out.completeCall();      // complete the call
-+ * 
-+ */ -+public class HessianSerializerOutput extends Hessian2Output { -+ /** -+ * Creates a new Hessian output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public HessianSerializerOutput(OutputStream os) -+ { -+ super(os); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian output stream. -+ */ -+ public HessianSerializerOutput() -+ { -+ super(null); -+ } -+ -+ /** -+ * Applications which override this can do custom serialization. -+ * -+ * @param object the object to write. -+ */ -+ public void writeObjectImpl(Object obj) -+ throws IOException -+ { -+ Class cl = obj.getClass(); -+ -+ try { -+ Method method = cl.getMethod("writeReplace", new Class[0]); -+ Object repl = method.invoke(obj, new Object[0]); -+ -+ writeObject(repl); -+ return; -+ } catch (Exception e) { -+ } -+ -+ try { -+ writeMapBegin(cl.getName()); -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isTransient(field.getModifiers()) || -+ Modifier.isStatic(field.getModifiers())) -+ continue; -+ -+ // XXX: could parameterize the handler to only deal with public -+ field.setAccessible(true); -+ -+ writeString(field.getName()); -+ writeObject(field.get(obj)); -+ } -+ } -+ writeMapEnd(); -+ } catch (IllegalAccessException e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/HessianServiceException.java hessian-4.0.65-fix/com/caucho/hessian/io/HessianServiceException.java ---- hessian-4.0.65-src/com/caucho/hessian/io/HessianServiceException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/HessianServiceException.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,91 +1,91 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroHessianInput. -- */ --public class HessianServiceException extends Exception { -- private String code; -- private Object detail; -- -- /** -- * Zero-arg constructor. -- */ -- public HessianServiceException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public HessianServiceException(String message, String code, Object detail) -- { -- super(message); -- this.code = code; -- this.detail = detail; -- } -- -- /** -- * Returns the code. -- */ -- public String getCode() -- { -- return code; -- } -- -- /** -- * Returns the detail. -- */ -- public Object getDetail() -- { -- return detail; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroHessianInput. -+ */ -+public class HessianServiceException extends Exception { -+ private String code; -+ private Object detail; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public HessianServiceException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public HessianServiceException(String message, String code, Object detail) -+ { -+ super(message); -+ this.code = code; -+ this.detail = detail; -+ } -+ -+ /** -+ * Returns the code. -+ */ -+ public String getCode() -+ { -+ return code; -+ } -+ -+ /** -+ * Returns the detail. -+ */ -+ public Object getDetail() -+ { -+ return detail; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/IOExceptionWrapper.java hessian-4.0.65-fix/com/caucho/hessian/io/IOExceptionWrapper.java ---- hessian-4.0.65-src/com/caucho/hessian/io/IOExceptionWrapper.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/IOExceptionWrapper.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,77 +1,77 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Exception wrapper for IO. -- */ --public class IOExceptionWrapper extends IOException { -- private Throwable _cause; -- -- public IOExceptionWrapper(Throwable cause) -- { -- super(cause.toString()); -- -- _cause = cause; -- } -- -- public IOExceptionWrapper(String msg, Throwable cause) -- { -- super(msg); -- -- _cause = cause; -- } -- -- public Throwable getCause() -- { -- return _cause; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Exception wrapper for IO. -+ */ -+public class IOExceptionWrapper extends IOException { -+ private Throwable _cause; -+ -+ public IOExceptionWrapper(Throwable cause) -+ { -+ super(cause.toString()); -+ -+ _cause = cause; -+ } -+ -+ public IOExceptionWrapper(String msg, Throwable cause) -+ { -+ super(msg); -+ -+ _cause = cause; -+ } -+ -+ public Throwable getCause() -+ { -+ return _cause; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InetAddressHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressHandle.java ---- hessian-4.0.65-src/com/caucho/hessian/io/InetAddressHandle.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressHandle.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,81 +1,81 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.net.InetAddress; --import java.util.logging.Level; --import java.util.logging.Logger; -- --/** -- * Handle for an InetAddress object. -- */ --public class InetAddressHandle implements java.io.Serializable, HessianHandle --{ -- private static final Logger log = Logger.getLogger(InetAddressHandle.class.getName()); -- -- private String hostName; -- private byte []address; -- -- public InetAddressHandle(String hostName, byte []address) -- { -- this.hostName = hostName; -- this.address = address; -- } -- -- private Object readResolve() -- { -- try { -- return InetAddress.getByAddress(this.hostName, this.address); -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- -- return null; -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.net.InetAddress; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+/** -+ * Handle for an InetAddress object. -+ */ -+public class InetAddressHandle implements java.io.Serializable, HessianHandle -+{ -+ private static final Logger log = Logger.getLogger(InetAddressHandle.class.getName()); -+ -+ private String hostName; -+ private byte []address; -+ -+ public InetAddressHandle(String hostName, byte []address) -+ { -+ this.hostName = hostName; -+ this.address = address; -+ } -+ -+ private Object readResolve() -+ { -+ try { -+ return InetAddress.getByAddress(this.hostName, this.address); -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ -+ return null; -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InetAddressSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/InetAddressSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/InetAddressSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,77 +1,77 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.net.InetAddress; -- --/** -- * Serializing a locale. -- */ --public class InetAddressSerializer extends AbstractSerializer { -- private static InetAddressSerializer SERIALIZER = new InetAddressSerializer(); -- -- public static InetAddressSerializer create() -- { -- return SERIALIZER; -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (obj == null) -- out.writeNull(); -- else { -- InetAddress addr = (InetAddress) obj; -- out.writeObject(new InetAddressHandle(addr.getHostName(), -- addr.getAddress())); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.net.InetAddress; -+ -+/** -+ * Serializing a locale. -+ */ -+public class InetAddressSerializer extends AbstractSerializer { -+ private static InetAddressSerializer SERIALIZER = new InetAddressSerializer(); -+ -+ public static InetAddressSerializer create() -+ { -+ return SERIALIZER; -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (obj == null) -+ out.writeNull(); -+ else { -+ InetAddress addr = (InetAddress) obj; -+ out.writeObject(new InetAddressHandle(addr.getHostName(), -+ addr.getAddress())); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InputStreamDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/InputStreamDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,70 +1,70 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; -- --/** -- * Serializing a stream object. -- */ --public class InputStreamDeserializer extends AbstractDeserializer { -- public static final InputStreamDeserializer DESER -- = new InputStreamDeserializer(); -- -- public InputStreamDeserializer() -- { -- } -- -- public Object readObject(AbstractHessianInput in) -- throws IOException -- { -- return in.readInputStream(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+ -+/** -+ * Serializing a stream object. -+ */ -+public class InputStreamDeserializer extends AbstractDeserializer { -+ public static final InputStreamDeserializer DESER -+ = new InputStreamDeserializer(); -+ -+ public InputStreamDeserializer() -+ { -+ } -+ -+ public Object readObject(AbstractHessianInput in) -+ throws IOException -+ { -+ return in.readInputStream(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/InputStreamSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/InputStreamSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/InputStreamSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,73 +1,73 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; -- --/** -- * Serializing a stream object. -- */ --public class InputStreamSerializer extends AbstractSerializer { -- public InputStreamSerializer() -- { -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- InputStream is = (InputStream) obj; -- -- if (is == null) -- out.writeNull(); -- else { -- out.writeByteStream(is); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+ -+/** -+ * Serializing a stream object. -+ */ -+public class InputStreamSerializer extends AbstractSerializer { -+ public InputStreamSerializer() -+ { -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ InputStream is = (InputStream) obj; -+ -+ if (is == null) -+ out.writeNull(); -+ else { -+ out.writeByteStream(is); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/IteratorDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/IteratorDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/IteratorDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/IteratorDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,85 +1,85 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.ArrayList; -- --/** -- * Deserializing a JDK 1.2 Collection. -- */ --public class IteratorDeserializer extends AbstractListDeserializer { -- private static IteratorDeserializer _deserializer; -- -- public static IteratorDeserializer create() -- { -- if (_deserializer == null) -- _deserializer = new IteratorDeserializer(); -- -- return _deserializer; -- } -- -- @Override -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- ArrayList list = new ArrayList(); -- -- in.addRef(list); -- -- while (! in.isEnd()) -- list.add(in.readObject()); -- -- in.readEnd(); -- -- return list.iterator(); -- } --} -- -- -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.ArrayList; -+ -+/** -+ * Deserializing a JDK 1.2 Collection. -+ */ -+public class IteratorDeserializer extends AbstractListDeserializer { -+ private static IteratorDeserializer _deserializer; -+ -+ public static IteratorDeserializer create() -+ { -+ if (_deserializer == null) -+ _deserializer = new IteratorDeserializer(); -+ -+ return _deserializer; -+ } -+ -+ @Override -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ ArrayList list = new ArrayList(); -+ -+ in.addRef(list); -+ -+ while (! in.isEnd()) -+ list.add(in.readObject()); -+ -+ in.readEnd(); -+ -+ return list.iterator(); -+ } -+} -+ -+ -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/IteratorSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/IteratorSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/IteratorSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/IteratorSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,84 +1,84 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.Iterator; -- --/** -- * Serializing a JDK 1.2 Iterator. -- */ --public class IteratorSerializer extends AbstractSerializer { -- private static IteratorSerializer _serializer; -- -- public static IteratorSerializer create() -- { -- if (_serializer == null) -- _serializer = new IteratorSerializer(); -- -- return _serializer; -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- Iterator iter = (Iterator) obj; -- -- boolean hasEnd = out.writeListBegin(-1, null); -- -- while (iter.hasNext()) { -- Object value = iter.next(); -- -- out.writeObject(value); -- } -- -- if (hasEnd) -- out.writeListEnd(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.Iterator; -+ -+/** -+ * Serializing a JDK 1.2 Iterator. -+ */ -+public class IteratorSerializer extends AbstractSerializer { -+ private static IteratorSerializer _serializer; -+ -+ public static IteratorSerializer create() -+ { -+ if (_serializer == null) -+ _serializer = new IteratorSerializer(); -+ -+ return _serializer; -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ Iterator iter = (Iterator) obj; -+ -+ boolean hasEnd = out.writeListBegin(-1, null); -+ -+ while (iter.hasNext()) { -+ Object value = iter.next(); -+ -+ out.writeObject(value); -+ } -+ -+ if (hasEnd) -+ out.writeListEnd(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/JavaDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/JavaDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/JavaDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/JavaDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,448 +1,448 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Constructor; --import java.lang.reflect.Field; --import java.lang.reflect.InvocationTargetException; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.HashMap; -- --import com.caucho.hessian.io.FieldDeserializer2Factory.NullFieldDeserializer; -- --/** -- * Serializing an object for known object types. -- */ --public class JavaDeserializer extends AbstractMapDeserializer { -- private Class _type; -- private HashMap _fieldMap; -- private Method _readResolve; -- private Constructor _constructor; -- private Object []_constructorArgs; -- -- public JavaDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) -- { -- _type = cl; -- _fieldMap = getFieldMap(cl, fieldFactory); -- -- _readResolve = getReadResolve(cl); -- -- if (_readResolve != null) { -- _readResolve.setAccessible(true); -- } -- -- _constructor = getConstructor(cl); -- _constructorArgs = getConstructorArgs(_constructor); -- } -- -- protected Constructor getConstructor(Class cl) -- { -- Constructor []constructors = cl.getDeclaredConstructors(); -- long bestCost = Long.MAX_VALUE; -- -- Constructor constructor = null; -- -- for (int i = 0; i < constructors.length; i++) { -- Class []param = constructors[i].getParameterTypes(); -- long cost = 0; -- -- for (int j = 0; j < param.length; j++) { -- cost = 4 * cost; -- -- if (Object.class.equals(param[j])) -- cost += 1; -- else if (String.class.equals(param[j])) -- cost += 2; -- else if (int.class.equals(param[j])) -- cost += 3; -- else if (long.class.equals(param[j])) -- cost += 4; -- else if (param[j].isPrimitive()) -- cost += 5; -- else -- cost += 6; -- } -- -- if (cost < 0 || cost > (1 << 48)) -- cost = 1 << 48; -- -- cost += (long) param.length << 48; -- -- if (cost < bestCost) { -- constructor = constructors[i]; -- bestCost = cost; -- } -- } -- -- if (constructor != null) { -- constructor.setAccessible(true); -- } -- -- return constructor; -- } -- -- protected Object []getConstructorArgs(Constructor constructor) -- { -- Object []constructorArgs = null; -- -- if (constructor != null) { -- Class []params = constructor.getParameterTypes(); -- constructorArgs = new Object[params.length]; -- for (int i = 0; i < params.length; i++) { -- constructorArgs[i] = getParamArg(params[i]); -- } -- } -- -- return constructorArgs; -- } -- -- @Override -- public Class getType() -- { -- return _type; -- } -- -- @Override -- public boolean isReadResolve() -- { -- return _readResolve != null; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- try { -- Object obj = instantiate(); -- -- return readMap(in, obj); -- } catch (IOException e) { -- throw e; -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -- } -- } -- -- @Override -- public Object []createFields(int len) -- { -- return new FieldDeserializer2[len]; -- } -- -- @Override -- public Object createField(String name) -- { -- Object reader = _fieldMap.get(name); -- -- if (reader == null) -- reader = NullFieldDeserializer.DESER; -- -- return reader; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException -- { -- try { -- Object obj = instantiate(); -- -- return readObject(in, obj, (FieldDeserializer2 []) fields); -- } catch (IOException e) { -- throw e; -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -- } -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, -- String []fieldNames) -- throws IOException -- { -- try { -- Object obj = instantiate(); -- -- return readObject(in, obj, fieldNames); -- } catch (IOException e) { -- throw e; -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -- } -- } -- -- /** -- * Returns the readResolve method -- */ -- protected Method getReadResolve(Class cl) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (method.getName().equals("readResolve") -- && method.getParameterTypes().length == 0) -- return method; -- } -- } -- -- return null; -- } -- -- public Object readMap(AbstractHessianInput in, Object obj) -- throws IOException -- { -- try { -- int ref = in.addRef(obj); -- -- while (! in.isEnd()) { -- Object key = in.readObject(); -- -- FieldDeserializer2 deser = _fieldMap.get(key); -- -- if (deser != null) -- deser.deserialize(in, obj); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- Object resolve = resolve(in, obj); -- -- if (obj != resolve) -- in.setRef(ref, resolve); -- -- return resolve; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- private Object readObject(AbstractHessianInput in, -- Object obj, -- FieldDeserializer2 []fields) -- throws IOException -- { -- try { -- int ref = in.addRef(obj); -- -- for (FieldDeserializer2 reader : fields) { -- reader.deserialize(in, obj); -- } -- -- Object resolve = resolve(in, obj); -- -- if (obj != resolve) -- in.setRef(ref, resolve); -- -- return resolve; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -- } -- } -- -- public Object readObject(AbstractHessianInput in, -- Object obj, -- String []fieldNames) -- throws IOException -- { -- try { -- int ref = in.addRef(obj); -- -- for (String fieldName : fieldNames) { -- FieldDeserializer2 reader = _fieldMap.get(fieldName); -- -- if (reader != null) -- reader.deserialize(in, obj); -- else -- in.readObject(); -- } -- -- Object resolve = resolve(in, obj); -- -- if (obj != resolve) -- in.setRef(ref, resolve); -- -- return resolve; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -- } -- } -- -- protected Object resolve(AbstractHessianInput in, Object obj) -- throws Exception -- { -- // if there's a readResolve method, call it -- try { -- if (_readResolve != null) -- return _readResolve.invoke(obj, new Object[0]); -- } catch (InvocationTargetException e) { -- if (e.getCause() instanceof Exception) -- throw (Exception) e.getCause(); -- else -- throw e; -- } -- -- return obj; -- } -- -- protected Object instantiate() -- throws Exception -- { -- try { -- if (_constructor != null) -- return _constructor.newInstance(_constructorArgs); -- else -- return _type.newInstance(); -- } catch (Exception e) { -- throw new HessianProtocolException("'" + _type.getName() + "' could not be instantiated", e); -- } -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- protected HashMap -- getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) -- { -- HashMap fieldMap -- = new HashMap(); -- -- for (; cl != null; cl = cl.getSuperclass()) { -- Field []fields = cl.getDeclaredFields(); -- for (int i = 0; i < fields.length; i++) { -- Field field = fields[i]; -- -- if (Modifier.isTransient(field.getModifiers()) -- || Modifier.isStatic(field.getModifiers())) -- continue; -- else if (fieldMap.get(field.getName()) != null) -- continue; -- -- /* -- // XXX: could parameterize the handler to only deal with public -- try { -- field.setAccessible(true); -- } catch (Throwable e) { -- e.printStackTrace(); -- } -- */ -- -- FieldDeserializer2 deser = fieldFactory.create(field); -- -- fieldMap.put(field.getName(), deser); -- } -- } -- -- return fieldMap; -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- protected static Object getParamArg(Class cl) -- { -- if (! cl.isPrimitive()) -- return null; -- else if (boolean.class.equals(cl)) -- return Boolean.FALSE; -- else if (byte.class.equals(cl)) -- return new Byte((byte) 0); -- else if (short.class.equals(cl)) -- return new Short((short) 0); -- else if (char.class.equals(cl)) -- return new Character((char) 0); -- else if (int.class.equals(cl)) -- return Integer.valueOf(0); -- else if (long.class.equals(cl)) -- return Long.valueOf(0); -- else if (float.class.equals(cl)) -- return Float.valueOf(0); -- else if (double.class.equals(cl)) -- return Double.valueOf(0); -- else -- throw new UnsupportedOperationException(); -- } -- -- static void logDeserializeError(Field field, Object obj, Object value, -- Throwable e) -- throws IOException -- { -- String fieldName = (field.getDeclaringClass().getName() -- + "." + field.getName()); -- -- if (e instanceof HessianFieldException) -- throw (HessianFieldException) e; -- else if (e instanceof IOException) -- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -- -- if (value != null) -- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -- + " cannot be assigned to '" + field.getType().getName() + "'", e); -- else -- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Constructor; -+import java.lang.reflect.Field; -+import java.lang.reflect.InvocationTargetException; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.HashMap; -+ -+import com.caucho.hessian.io.FieldDeserializer2Factory.NullFieldDeserializer; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class JavaDeserializer extends AbstractMapDeserializer { -+ private Class _type; -+ private HashMap _fieldMap; -+ private Method _readResolve; -+ private Constructor _constructor; -+ private Object []_constructorArgs; -+ -+ public JavaDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) -+ { -+ _type = cl; -+ _fieldMap = getFieldMap(cl, fieldFactory); -+ -+ _readResolve = getReadResolve(cl); -+ -+ if (_readResolve != null) { -+ _readResolve.setAccessible(true); -+ } -+ -+ _constructor = getConstructor(cl); -+ _constructorArgs = getConstructorArgs(_constructor); -+ } -+ -+ protected Constructor getConstructor(Class cl) -+ { -+ Constructor []constructors = cl.getDeclaredConstructors(); -+ long bestCost = Long.MAX_VALUE; -+ -+ Constructor constructor = null; -+ -+ for (int i = 0; i < constructors.length; i++) { -+ Class []param = constructors[i].getParameterTypes(); -+ long cost = 0; -+ -+ for (int j = 0; j < param.length; j++) { -+ cost = 4 * cost; -+ -+ if (Object.class.equals(param[j])) -+ cost += 1; -+ else if (String.class.equals(param[j])) -+ cost += 2; -+ else if (int.class.equals(param[j])) -+ cost += 3; -+ else if (long.class.equals(param[j])) -+ cost += 4; -+ else if (param[j].isPrimitive()) -+ cost += 5; -+ else -+ cost += 6; -+ } -+ -+ if (cost < 0 || cost > (1 << 48)) -+ cost = 1 << 48; -+ -+ cost += (long) param.length << 48; -+ -+ if (cost < bestCost) { -+ constructor = constructors[i]; -+ bestCost = cost; -+ } -+ } -+ -+ if (constructor != null) { -+ constructor.setAccessible(true); -+ } -+ -+ return constructor; -+ } -+ -+ protected Object []getConstructorArgs(Constructor constructor) -+ { -+ Object []constructorArgs = null; -+ -+ if (constructor != null) { -+ Class []params = constructor.getParameterTypes(); -+ constructorArgs = new Object[params.length]; -+ for (int i = 0; i < params.length; i++) { -+ constructorArgs[i] = getParamArg(params[i]); -+ } -+ } -+ -+ return constructorArgs; -+ } -+ -+ @Override -+ public Class getType() -+ { -+ return _type; -+ } -+ -+ @Override -+ public boolean isReadResolve() -+ { -+ return _readResolve != null; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readMap(in, obj); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ @Override -+ public Object []createFields(int len) -+ { -+ return new FieldDeserializer2[len]; -+ } -+ -+ @Override -+ public Object createField(String name) -+ { -+ Object reader = _fieldMap.get(name); -+ -+ if (reader == null) -+ reader = NullFieldDeserializer.DESER; -+ -+ return reader; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readObject(in, obj, (FieldDeserializer2 []) fields); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ String []fieldNames) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readObject(in, obj, fieldNames); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ /** -+ * Returns the readResolve method -+ */ -+ protected Method getReadResolve(Class cl) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (method.getName().equals("readResolve") -+ && method.getParameterTypes().length == 0) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ public Object readMap(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ while (! in.isEnd()) { -+ Object key = in.readObject(); -+ -+ FieldDeserializer2 deser = _fieldMap.get(key); -+ -+ if (deser != null) -+ deser.deserialize(in, obj); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ private Object readObject(AbstractHessianInput in, -+ Object obj, -+ FieldDeserializer2 []fields) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ for (FieldDeserializer2 reader : fields) { -+ reader.deserialize(in, obj); -+ } -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -+ } -+ } -+ -+ public Object readObject(AbstractHessianInput in, -+ Object obj, -+ String []fieldNames) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ for (String fieldName : fieldNames) { -+ FieldDeserializer2 reader = _fieldMap.get(fieldName); -+ -+ if (reader != null) -+ reader.deserialize(in, obj); -+ else -+ in.readObject(); -+ } -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -+ } -+ } -+ -+ protected Object resolve(AbstractHessianInput in, Object obj) -+ throws Exception -+ { -+ // if there's a readResolve method, call it -+ try { -+ if (_readResolve != null) -+ return _readResolve.invoke(obj, new Object[0]); -+ } catch (InvocationTargetException e) { -+ if (e.getCause() instanceof Exception) -+ throw (Exception) e.getCause(); -+ else -+ throw e; -+ } -+ -+ return obj; -+ } -+ -+ protected Object instantiate() -+ throws Exception -+ { -+ try { -+ if (_constructor != null) -+ return _constructor.newInstance(_constructorArgs); -+ else -+ return _type.newInstance(); -+ } catch (Exception e) { -+ throw new HessianProtocolException("'" + _type.getName() + "' could not be instantiated", e); -+ } -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected HashMap -+ getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) -+ { -+ HashMap fieldMap -+ = new HashMap(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isTransient(field.getModifiers()) -+ || Modifier.isStatic(field.getModifiers())) -+ continue; -+ else if (fieldMap.get(field.getName()) != null) -+ continue; -+ -+ /* -+ // XXX: could parameterize the handler to only deal with public -+ try { -+ field.setAccessible(true); -+ } catch (Throwable e) { -+ e.printStackTrace(); -+ } -+ */ -+ -+ FieldDeserializer2 deser = fieldFactory.create(field); -+ -+ fieldMap.put(field.getName(), deser); -+ } -+ } -+ -+ return fieldMap; -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected static Object getParamArg(Class cl) -+ { -+ if (! cl.isPrimitive()) -+ return null; -+ else if (boolean.class.equals(cl)) -+ return Boolean.FALSE; -+ else if (byte.class.equals(cl)) -+ return new Byte((byte) 0); -+ else if (short.class.equals(cl)) -+ return new Short((short) 0); -+ else if (char.class.equals(cl)) -+ return new Character((char) 0); -+ else if (int.class.equals(cl)) -+ return Integer.valueOf(0); -+ else if (long.class.equals(cl)) -+ return Long.valueOf(0); -+ else if (float.class.equals(cl)) -+ return Float.valueOf(0); -+ else if (double.class.equals(cl)) -+ return Double.valueOf(0); -+ else -+ throw new UnsupportedOperationException(); -+ } -+ -+ static void logDeserializeError(Field field, Object obj, Object value, -+ Throwable e) -+ throws IOException -+ { -+ String fieldName = (field.getDeclaringClass().getName() -+ + "." + field.getName()); -+ -+ if (e instanceof HessianFieldException) -+ throw (HessianFieldException) e; -+ else if (e instanceof IOException) -+ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -+ -+ if (value != null) -+ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -+ + " cannot be assigned to '" + field.getType().getName() + "'", e); -+ else -+ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/JavaSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/JavaSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/JavaSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/JavaSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,477 +1,477 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.ref.SoftReference; --import java.lang.reflect.Field; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.ArrayList; --import java.util.WeakHashMap; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import com.caucho.hessian.HessianUnshared; -- --/** -- * Serializing an object for known object types. -- */ --public class JavaSerializer extends AbstractSerializer --{ -- private static final Logger log -- = Logger.getLogger(JavaSerializer.class.getName()); -- -- private static final WeakHashMap,SoftReference> _serializerMap -- = new WeakHashMap,SoftReference>(); -- -- private Field []_fields; -- private FieldSerializer []_fieldSerializers; -- -- private Object _writeReplaceFactory; -- private Method _writeReplace; -- -- public JavaSerializer(Class cl) -- { -- introspect(cl); -- -- _writeReplace = getWriteReplace(cl); -- -- if (_writeReplace != null) -- _writeReplace.setAccessible(true); -- } -- -- public static Serializer create(Class cl) -- { -- synchronized (_serializerMap) { -- SoftReference baseRef -- = _serializerMap.get(cl); -- -- JavaSerializer base = baseRef != null ? baseRef.get() : null; -- -- if (base == null) { -- if (cl.isAnnotationPresent(HessianUnshared.class)) -- base = new JavaUnsharedSerializer(cl); -- else -- base = new JavaSerializer(cl); -- -- baseRef = new SoftReference(base); -- _serializerMap.put(cl, baseRef); -- } -- -- return base; -- } -- } -- -- protected void introspect(Class cl) -- { -- if (_writeReplace != null) -- _writeReplace.setAccessible(true); -- -- ArrayList primitiveFields = new ArrayList(); -- ArrayList compoundFields = new ArrayList(); -- -- for (; cl != null; cl = cl.getSuperclass()) { -- Field []fields = cl.getDeclaredFields(); -- for (int i = 0; i < fields.length; i++) { -- Field field = fields[i]; -- -- if (Modifier.isTransient(field.getModifiers()) -- || Modifier.isStatic(field.getModifiers())) -- continue; -- -- // XXX: could parameterize the handler to only deal with public -- field.setAccessible(true); -- -- if (field.getType().isPrimitive() -- || (field.getType().getName().startsWith("java.lang.") -- && ! field.getType().equals(Object.class))) -- primitiveFields.add(field); -- else -- compoundFields.add(field); -- } -- } -- -- ArrayList fields = new ArrayList(); -- fields.addAll(primitiveFields); -- fields.addAll(compoundFields); -- -- _fields = new Field[fields.size()]; -- fields.toArray(_fields); -- -- _fieldSerializers = new FieldSerializer[_fields.length]; -- -- for (int i = 0; i < _fields.length; i++) { -- _fieldSerializers[i] = getFieldSerializer(_fields[i].getType()); -- } -- } -- -- /** -- * Returns the writeReplace method -- */ -- protected static Method getWriteReplace(Class cl) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (method.getName().equals("writeReplace") -- && method.getParameterTypes().length == 0) -- return method; -- } -- } -- -- return null; -- } -- -- /** -- * Returns the writeReplace method -- */ -- protected Method getWriteReplace(Class cl, Class param) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- for (Method method : cl.getDeclaredMethods()) { -- if (method.getName().equals("writeReplace") -- && method.getParameterTypes().length == 1 -- && param.equals(method.getParameterTypes()[0])) -- return method; -- } -- } -- -- return null; -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) { -- return; -- } -- -- Class cl = obj.getClass(); -- -- try { -- if (_writeReplace != null) { -- Object repl; -- -- if (_writeReplaceFactory != null) -- repl = _writeReplace.invoke(_writeReplaceFactory, obj); -- else -- repl = _writeReplace.invoke(obj); -- -- // out.removeRef(obj); -- -- /* -- out.writeObject(repl); -- -- out.replaceRef(repl, obj); -- */ -- -- //hessian/3a5a -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref < -1) { -- writeObject10(repl, out); -- } else { -- if (ref == -1) { -- writeDefinition20(out); -- out.writeObjectBegin(cl.getName()); -- } -- -- writeInstance(repl, out); -- } -- -- return; -- } -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- // log.log(Level.FINE, e.toString(), e); -- throw new RuntimeException(e); -- } -- -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref < -1) { -- writeObject10(obj, out); -- } -- else { -- if (ref == -1) { -- writeDefinition20(out); -- out.writeObjectBegin(cl.getName()); -- } -- -- writeInstance(obj, out); -- } -- } -- -- protected void writeObject10(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- for (int i = 0; i < _fields.length; i++) { -- Field field = _fields[i]; -- -- out.writeString(field.getName()); -- -- _fieldSerializers[i].serialize(out, obj, field); -- } -- -- out.writeMapEnd(); -- } -- -- private void writeDefinition20(AbstractHessianOutput out) -- throws IOException -- { -- out.writeClassFieldLength(_fields.length); -- -- for (int i = 0; i < _fields.length; i++) { -- Field field = _fields[i]; -- -- out.writeString(field.getName()); -- } -- } -- -- @Override -- public void writeInstance(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- try { -- for (int i = 0; i < _fields.length; i++) { -- Field field = _fields[i]; -- -- _fieldSerializers[i].serialize(out, obj, field); -- } -- } catch (RuntimeException e) { -- throw new RuntimeException(e.getMessage() + "\n class: " -- + obj.getClass().getName() -- + " (object=" + obj + ")", -- e); -- } catch (IOException e) { -- throw new IOExceptionWrapper(e.getMessage() + "\n class: " -- + obj.getClass().getName() -- + " (object=" + obj + ")", -- e); -- } -- } -- -- private static FieldSerializer getFieldSerializer(Class type) -- { -- if (int.class.equals(type) -- || byte.class.equals(type) -- || short.class.equals(type) -- || int.class.equals(type)) { -- return IntFieldSerializer.SER; -- } -- else if (long.class.equals(type)) { -- return LongFieldSerializer.SER; -- } -- else if (double.class.equals(type) || -- float.class.equals(type)) { -- return DoubleFieldSerializer.SER; -- } -- else if (boolean.class.equals(type)) { -- return BooleanFieldSerializer.SER; -- } -- else if (String.class.equals(type)) { -- return StringFieldSerializer.SER; -- } -- else if (java.util.Date.class.equals(type) -- || java.sql.Date.class.equals(type) -- || java.sql.Timestamp.class.equals(type) -- || java.sql.Time.class.equals(type)) { -- return DateFieldSerializer.SER; -- } -- else -- return FieldSerializer.SER; -- } -- -- static class FieldSerializer { -- static final FieldSerializer SER = new FieldSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Field field) -- throws IOException -- { -- Object value = null; -- -- try { -- value = field.get(obj); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- try { -- out.writeObject(value); -- } catch (RuntimeException e) { -- throw new RuntimeException(e.getMessage() + "\n field: " -- + field.getDeclaringClass().getName() -- + '.' + field.getName(), -- e); -- } catch (IOException e) { -- throw new IOExceptionWrapper(e.getMessage() + "\n field: " -- + field.getDeclaringClass().getName() -- + '.' + field.getName(), -- e); -- } -- } -- } -- -- static class BooleanFieldSerializer extends FieldSerializer { -- static final FieldSerializer SER = new BooleanFieldSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Field field) -- throws IOException -- { -- boolean value = false; -- -- try { -- value = field.getBoolean(obj); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeBoolean(value); -- } -- } -- -- static class IntFieldSerializer extends FieldSerializer { -- static final FieldSerializer SER = new IntFieldSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Field field) -- throws IOException -- { -- int value = 0; -- -- try { -- value = field.getInt(obj); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeInt(value); -- } -- } -- -- static class LongFieldSerializer extends FieldSerializer { -- static final FieldSerializer SER = new LongFieldSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Field field) -- throws IOException -- { -- long value = 0; -- -- try { -- value = field.getLong(obj); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeLong(value); -- } -- } -- -- static class DoubleFieldSerializer extends FieldSerializer { -- static final FieldSerializer SER = new DoubleFieldSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Field field) -- throws IOException -- { -- double value = 0; -- -- try { -- value = field.getDouble(obj); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeDouble(value); -- } -- } -- -- static class StringFieldSerializer extends FieldSerializer { -- static final FieldSerializer SER = new StringFieldSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Field field) -- throws IOException -- { -- String value = null; -- -- try { -- value = (String) field.get(obj); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- out.writeString(value); -- } -- } -- -- static class DateFieldSerializer extends FieldSerializer { -- static final FieldSerializer SER = new DateFieldSerializer(); -- -- void serialize(AbstractHessianOutput out, Object obj, Field field) -- throws IOException -- { -- java.util.Date value = null; -- -- try { -- value = (java.util.Date) field.get(obj); -- } catch (IllegalAccessException e) { -- log.log(Level.FINE, e.toString(), e); -- } -- -- if (value == null) -- out.writeNull(); -- else -- out.writeUTCDate(value.getTime()); -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.ref.SoftReference; -+import java.lang.reflect.Field; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.ArrayList; -+import java.util.WeakHashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import com.caucho.hessian.HessianUnshared; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class JavaSerializer extends AbstractSerializer -+{ -+ private static final Logger log -+ = Logger.getLogger(JavaSerializer.class.getName()); -+ -+ private static final WeakHashMap,SoftReference> _serializerMap -+ = new WeakHashMap,SoftReference>(); -+ -+ private Field []_fields; -+ private FieldSerializer []_fieldSerializers; -+ -+ private Object _writeReplaceFactory; -+ private Method _writeReplace; -+ -+ public JavaSerializer(Class cl) -+ { -+ introspect(cl); -+ -+ _writeReplace = getWriteReplace(cl); -+ -+ if (_writeReplace != null) -+ _writeReplace.setAccessible(true); -+ } -+ -+ public static Serializer create(Class cl) -+ { -+ synchronized (_serializerMap) { -+ SoftReference baseRef -+ = _serializerMap.get(cl); -+ -+ JavaSerializer base = baseRef != null ? baseRef.get() : null; -+ -+ if (base == null) { -+ if (cl.isAnnotationPresent(HessianUnshared.class)) -+ base = new JavaUnsharedSerializer(cl); -+ else -+ base = new JavaSerializer(cl); -+ -+ baseRef = new SoftReference(base); -+ _serializerMap.put(cl, baseRef); -+ } -+ -+ return base; -+ } -+ } -+ -+ protected void introspect(Class cl) -+ { -+ if (_writeReplace != null) -+ _writeReplace.setAccessible(true); -+ -+ ArrayList primitiveFields = new ArrayList(); -+ ArrayList compoundFields = new ArrayList(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isTransient(field.getModifiers()) -+ || Modifier.isStatic(field.getModifiers())) -+ continue; -+ -+ // XXX: could parameterize the handler to only deal with public -+ field.setAccessible(true); -+ -+ if (field.getType().isPrimitive() -+ || (field.getType().getName().startsWith("java.lang.") -+ && ! field.getType().equals(Object.class))) -+ primitiveFields.add(field); -+ else -+ compoundFields.add(field); -+ } -+ } -+ -+ ArrayList fields = new ArrayList(); -+ fields.addAll(primitiveFields); -+ fields.addAll(compoundFields); -+ -+ _fields = new Field[fields.size()]; -+ fields.toArray(_fields); -+ -+ _fieldSerializers = new FieldSerializer[_fields.length]; -+ -+ for (int i = 0; i < _fields.length; i++) { -+ _fieldSerializers[i] = getFieldSerializer(_fields[i].getType()); -+ } -+ } -+ -+ /** -+ * Returns the writeReplace method -+ */ -+ protected static Method getWriteReplace(Class cl) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (method.getName().equals("writeReplace") -+ && method.getParameterTypes().length == 0) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ /** -+ * Returns the writeReplace method -+ */ -+ protected Method getWriteReplace(Class cl, Class param) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ for (Method method : cl.getDeclaredMethods()) { -+ if (method.getName().equals("writeReplace") -+ && method.getParameterTypes().length == 1 -+ && param.equals(method.getParameterTypes()[0])) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) { -+ return; -+ } -+ -+ Class cl = obj.getClass(); -+ -+ try { -+ if (_writeReplace != null) { -+ Object repl; -+ -+ if (_writeReplaceFactory != null) -+ repl = _writeReplace.invoke(_writeReplaceFactory, obj); -+ else -+ repl = _writeReplace.invoke(obj); -+ -+ // out.removeRef(obj); -+ -+ /* -+ out.writeObject(repl); -+ -+ out.replaceRef(repl, obj); -+ */ -+ -+ //hessian/3a5a -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref < -1) { -+ writeObject10(repl, out); -+ } else { -+ if (ref == -1) { -+ writeDefinition20(out); -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ writeInstance(repl, out); -+ } -+ -+ return; -+ } -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ // log.log(Level.FINE, e.toString(), e); -+ throw new RuntimeException(e); -+ } -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref < -1) { -+ writeObject10(obj, out); -+ } -+ else { -+ if (ref == -1) { -+ writeDefinition20(out); -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ writeInstance(obj, out); -+ } -+ } -+ -+ protected void writeObject10(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ for (int i = 0; i < _fields.length; i++) { -+ Field field = _fields[i]; -+ -+ out.writeString(field.getName()); -+ -+ _fieldSerializers[i].serialize(out, obj, field); -+ } -+ -+ out.writeMapEnd(); -+ } -+ -+ private void writeDefinition20(AbstractHessianOutput out) -+ throws IOException -+ { -+ out.writeClassFieldLength(_fields.length); -+ -+ for (int i = 0; i < _fields.length; i++) { -+ Field field = _fields[i]; -+ -+ out.writeString(field.getName()); -+ } -+ } -+ -+ @Override -+ public void writeInstance(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ try { -+ for (int i = 0; i < _fields.length; i++) { -+ Field field = _fields[i]; -+ -+ _fieldSerializers[i].serialize(out, obj, field); -+ } -+ } catch (RuntimeException e) { -+ throw new RuntimeException(e.getMessage() + "\n class: " -+ + obj.getClass().getName() -+ + " (object=" + obj + ")", -+ e); -+ } catch (IOException e) { -+ throw new IOExceptionWrapper(e.getMessage() + "\n class: " -+ + obj.getClass().getName() -+ + " (object=" + obj + ")", -+ e); -+ } -+ } -+ -+ private static FieldSerializer getFieldSerializer(Class type) -+ { -+ if (int.class.equals(type) -+ || byte.class.equals(type) -+ || short.class.equals(type) -+ || int.class.equals(type)) { -+ return IntFieldSerializer.SER; -+ } -+ else if (long.class.equals(type)) { -+ return LongFieldSerializer.SER; -+ } -+ else if (double.class.equals(type) || -+ float.class.equals(type)) { -+ return DoubleFieldSerializer.SER; -+ } -+ else if (boolean.class.equals(type)) { -+ return BooleanFieldSerializer.SER; -+ } -+ else if (String.class.equals(type)) { -+ return StringFieldSerializer.SER; -+ } -+ else if (java.util.Date.class.equals(type) -+ || java.sql.Date.class.equals(type) -+ || java.sql.Timestamp.class.equals(type) -+ || java.sql.Time.class.equals(type)) { -+ return DateFieldSerializer.SER; -+ } -+ else -+ return FieldSerializer.SER; -+ } -+ -+ static class FieldSerializer { -+ static final FieldSerializer SER = new FieldSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Field field) -+ throws IOException -+ { -+ Object value = null; -+ -+ try { -+ value = field.get(obj); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ try { -+ out.writeObject(value); -+ } catch (RuntimeException e) { -+ throw new RuntimeException(e.getMessage() + "\n field: " -+ + field.getDeclaringClass().getName() -+ + '.' + field.getName(), -+ e); -+ } catch (IOException e) { -+ throw new IOExceptionWrapper(e.getMessage() + "\n field: " -+ + field.getDeclaringClass().getName() -+ + '.' + field.getName(), -+ e); -+ } -+ } -+ } -+ -+ static class BooleanFieldSerializer extends FieldSerializer { -+ static final FieldSerializer SER = new BooleanFieldSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Field field) -+ throws IOException -+ { -+ boolean value = false; -+ -+ try { -+ value = field.getBoolean(obj); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeBoolean(value); -+ } -+ } -+ -+ static class IntFieldSerializer extends FieldSerializer { -+ static final FieldSerializer SER = new IntFieldSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Field field) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = field.getInt(obj); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeInt(value); -+ } -+ } -+ -+ static class LongFieldSerializer extends FieldSerializer { -+ static final FieldSerializer SER = new LongFieldSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Field field) -+ throws IOException -+ { -+ long value = 0; -+ -+ try { -+ value = field.getLong(obj); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeLong(value); -+ } -+ } -+ -+ static class DoubleFieldSerializer extends FieldSerializer { -+ static final FieldSerializer SER = new DoubleFieldSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Field field) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = field.getDouble(obj); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeDouble(value); -+ } -+ } -+ -+ static class StringFieldSerializer extends FieldSerializer { -+ static final FieldSerializer SER = new StringFieldSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Field field) -+ throws IOException -+ { -+ String value = null; -+ -+ try { -+ value = (String) field.get(obj); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ out.writeString(value); -+ } -+ } -+ -+ static class DateFieldSerializer extends FieldSerializer { -+ static final FieldSerializer SER = new DateFieldSerializer(); -+ -+ void serialize(AbstractHessianOutput out, Object obj, Field field) -+ throws IOException -+ { -+ java.util.Date value = null; -+ -+ try { -+ value = (java.util.Date) field.get(obj); -+ } catch (IllegalAccessException e) { -+ log.log(Level.FINE, e.toString(), e); -+ } -+ -+ if (value == null) -+ out.writeNull(); -+ else -+ out.writeUTCDate(value.getTime()); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/JavaUnsharedSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/JavaUnsharedSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/JavaUnsharedSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/JavaUnsharedSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,86 +1,86 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.ref.SoftReference; --import java.lang.reflect.Field; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.ArrayList; --import java.util.WeakHashMap; --import java.util.logging.Level; --import java.util.logging.Logger; -- --/** -- * Serializing an object for known object types. -- */ --public class JavaUnsharedSerializer extends JavaSerializer --{ -- private static final Logger log -- = Logger.getLogger(JavaUnsharedSerializer.class.getName()); -- -- public JavaUnsharedSerializer(Class cl) -- { -- super(cl); -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- boolean oldUnshared = out.setUnshared(true); -- -- try { -- super.writeObject(obj, out); -- } finally { -- out.setUnshared(oldUnshared); -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.ref.SoftReference; -+import java.lang.reflect.Field; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.ArrayList; -+import java.util.WeakHashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class JavaUnsharedSerializer extends JavaSerializer -+{ -+ private static final Logger log -+ = Logger.getLogger(JavaUnsharedSerializer.class.getName()); -+ -+ public JavaUnsharedSerializer(Class cl) -+ { -+ super(cl); -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ boolean oldUnshared = out.setUnshared(true); -+ -+ try { -+ super.writeObject(obj, out); -+ } finally { -+ out.setUnshared(oldUnshared); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHandle.java ---- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHandle.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHandle.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,119 +1,119 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.Locale; -- --/** -- * Handle for a locale object. -- */ --public class LocaleHandle implements java.io.Serializable, HessianHandle { -- private String value; -- -- public LocaleHandle(String locale) -- { -- this.value = locale; -- } -- -- private Object readResolve() -- { -- String s = this.value; -- -- if (s == null) -- return null; -- -- int len = s.length(); -- char ch = ' '; -- -- int i = 0; -- for (; -- i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' -- || 'A' <= ch && ch <= 'Z' -- || '0' <= ch && ch <= '9'); -- i++) { -- } -- -- String language = s.substring(0, i); -- String country = null; -- String var = null; -- -- if (ch == '-' || ch == '_') { -- int head = ++i; -- -- for (; -- i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' -- || 'A' <= ch && ch <= 'Z' -- || '0' <= ch && ch <= '9'); -- i++) { -- } -- -- country = s.substring(head, i); -- } -- -- if (ch == '-' || ch == '_') { -- int head = ++i; -- -- for (; -- i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' -- || 'A' <= ch && ch <= 'Z' -- || '0' <= ch && ch <= '9'); -- i++) { -- } -- -- var = s.substring(head, i); -- } -- -- if (var != null) -- return new Locale(language, country, var); -- else if (country != null) -- return new Locale(language, country); -- else -- return new Locale(language); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.Locale; -+ -+/** -+ * Handle for a locale object. -+ */ -+public class LocaleHandle implements java.io.Serializable, HessianHandle { -+ private String value; -+ -+ public LocaleHandle(String locale) -+ { -+ this.value = locale; -+ } -+ -+ private Object readResolve() -+ { -+ String s = this.value; -+ -+ if (s == null) -+ return null; -+ -+ int len = s.length(); -+ char ch = ' '; -+ -+ int i = 0; -+ for (; -+ i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' -+ || 'A' <= ch && ch <= 'Z' -+ || '0' <= ch && ch <= '9'); -+ i++) { -+ } -+ -+ String language = s.substring(0, i); -+ String country = null; -+ String var = null; -+ -+ if (ch == '-' || ch == '_') { -+ int head = ++i; -+ -+ for (; -+ i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' -+ || 'A' <= ch && ch <= 'Z' -+ || '0' <= ch && ch <= '9'); -+ i++) { -+ } -+ -+ country = s.substring(head, i); -+ } -+ -+ if (ch == '-' || ch == '_') { -+ int head = ++i; -+ -+ for (; -+ i < len && ('a' <= (ch = s.charAt(i)) && ch <= 'z' -+ || 'A' <= ch && ch <= 'Z' -+ || '0' <= ch && ch <= '9'); -+ i++) { -+ } -+ -+ var = s.substring(head, i); -+ } -+ -+ if (var != null) -+ return new Locale(language, country, var); -+ else if (country != null) -+ return new Locale(language, country); -+ else -+ return new Locale(language); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianDeserializer.java 1970-01-01 08:00:00.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -0,0 +1,85 @@ -+package com.caucho.hessian.io; -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import java.io.IOException; -+import java.util.Locale; -+ -+public class LocaleHessianDeserializer extends AbstractDeserializer { -+ -+ public Class getType() { -+ return Locale.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException { -+ int ref = in.addRef(null); -+ -+ String languageValue = null; -+ String countryValue = null; -+ String variantValue = null; -+ -+ while (!in.isEnd()) { -+ String key = in.readString(); -+ -+ if (key.equals("language")) -+ languageValue = in.readString(); -+ else if (key.equals("country")) -+ countryValue = in.readString(); -+ else if (key.equals("variant")) -+ variantValue = in.readString(); -+ else -+ in.readString(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object value = getObject(languageValue, countryValue, variantValue); -+ -+ in.setRef(ref, value); -+ -+ return value; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, Object[] fields) throws IOException { -+ int ref = in.addRef(null); -+ -+ String languageValue = null; -+ String countryValue = null; -+ String variantValue = null; -+ -+ for (Object key : fields) { -+ if (key.equals("language")) -+ languageValue = in.readString(); -+ else if (key.equals("country")) -+ countryValue = in.readString(); -+ else if (key.equals("variant")) -+ variantValue = in.readString(); -+ else -+ in.readObject(); -+ -+ } -+ -+ Object value = getObject(languageValue, countryValue, variantValue); -+ -+ in.setRef(ref, value); -+ -+ return value; -+ } -+ -+ private Object getObject(String languageValue, String countryValue, String variantValue) { -+ Object value = null; -+ if (languageValue != null && countryValue != null && variantValue != null) { -+ value = new Locale(languageValue, countryValue, variantValue); -+ } else if (languageValue != null && countryValue != null) { -+ value = new Locale(languageValue, countryValue); -+ } else if (languageValue != null) { -+ value = new Locale(languageValue); -+ } else { -+ value = Locale.getDefault(); -+ } -+ return value; -+ } -+ -+} -\ No newline at end of file -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianSerializer.java 1970-01-01 08:00:00.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -0,0 +1,64 @@ -+package com.caucho.hessian.io; -+import com.caucho.hessian.io.AbstractHessianOutput; -+import com.caucho.hessian.io.AbstractSerializer; -+ -+import java.io.IOException; -+import java.util.Locale; -+ -+public class LocaleHessianSerializer extends AbstractSerializer -+{ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ -+ if (obj == null) -+ out.writeNull(); -+ else -+ { -+ Class cl = obj.getClass(); -+ -+ if (out.addRef(obj)) -+ return; -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ Locale loc = (Locale) obj; -+ -+ if (ref < -1) -+ { -+ if (loc.getLanguage() != null) -+ { -+ out.writeString("language"); -+ out.writeString(loc.getLanguage()); -+ } -+ if (loc.getCountry() != null) -+ { -+ out.writeString("country"); -+ out.writeString(loc.getCountry()); -+ } -+ if (loc.getVariant() != null) -+ { -+ out.writeString("variant"); -+ out.writeString(loc.getVariant()); -+ } -+ -+ out.writeMapEnd(); -+ } -+ else -+ { -+ if (ref == -1) -+ { -+ out.writeInt(3); -+ out.writeString("language"); -+ out.writeString("country"); -+ out.writeString("variant"); -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ out.writeString(loc.getLanguage()); -+ out.writeString(loc.getCountry()); -+ out.writeString(loc.getVariant()); -+ } -+ } -+ } -+} -\ No newline at end of file -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/LocaleSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/LocaleSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,76 +1,76 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.Locale; -- --/** -- * Serializing a locale. -- */ --public class LocaleSerializer extends AbstractSerializer { -- private static LocaleSerializer SERIALIZER = new LocaleSerializer(); -- -- public static LocaleSerializer create() -- { -- return SERIALIZER; -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (obj == null) -- out.writeNull(); -- else { -- Locale locale = (Locale) obj; -- -- out.writeObject(new LocaleHandle(locale.toString())); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.Locale; -+ -+/** -+ * Serializing a locale. -+ */ -+public class LocaleSerializer extends AbstractSerializer { -+ private static LocaleSerializer SERIALIZER = new LocaleSerializer(); -+ -+ public static LocaleSerializer create() -+ { -+ return SERIALIZER; -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (obj == null) -+ out.writeNull(); -+ else { -+ Locale locale = (Locale) obj; -+ -+ out.writeObject(new LocaleHandle(locale.toString())); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/MapDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/MapDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/MapDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/MapDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,159 +1,159 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.*; --import java.lang.reflect.*; -- --/** -- * Deserializing a JDK 1.2 Map. -- */ --public class MapDeserializer extends AbstractMapDeserializer { -- private Class _type; -- private Constructor _ctor; -- -- public MapDeserializer(Class type) -- { -- if (type == null) -- type = HashMap.class; -- -- _type = type; -- -- Constructor []ctors = type.getConstructors(); -- for (int i = 0; i < ctors.length; i++) { -- if (ctors[i].getParameterTypes().length == 0) -- _ctor = ctors[i]; -- } -- -- if (_ctor == null) { -- try { -- _ctor = HashMap.class.getConstructor(new Class[0]); -- } catch (Exception e) { -- throw new IllegalStateException(e); -- } -- } -- } -- -- public Class getType() -- { -- if (_type != null) -- return _type; -- else -- return HashMap.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- Map map; -- -- if (_type == null) -- map = new HashMap(); -- else if (_type.equals(Map.class)) -- map = new HashMap(); -- else if (_type.equals(SortedMap.class)) -- map = new TreeMap(); -- else { -- try { -- map = (Map) _ctor.newInstance(); -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- in.addRef(map); -- -- while (! in.isEnd()) { -- map.put(in.readObject(), in.readObject()); -- } -- -- in.readEnd(); -- -- return map; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException -- { -- String []fieldNames = (String []) fields; -- Map map = createMap(); -- -- int ref = in.addRef(map); -- -- for (int i = 0; i < fieldNames.length; i++) { -- String name = fieldNames[i]; -- -- map.put(name, in.readObject()); -- } -- -- return map; -- } -- -- private Map createMap() -- throws IOException -- { -- -- if (_type == null) -- return new HashMap(); -- else if (_type.equals(Map.class)) -- return new HashMap(); -- else if (_type.equals(SortedMap.class)) -- return new TreeMap(); -- else { -- try { -- return (Map) _ctor.newInstance(); -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.*; -+import java.lang.reflect.*; -+ -+/** -+ * Deserializing a JDK 1.2 Map. -+ */ -+public class MapDeserializer extends AbstractMapDeserializer { -+ private Class _type; -+ private Constructor _ctor; -+ -+ public MapDeserializer(Class type) -+ { -+ if (type == null) -+ type = HashMap.class; -+ -+ _type = type; -+ -+ Constructor []ctors = type.getConstructors(); -+ for (int i = 0; i < ctors.length; i++) { -+ if (ctors[i].getParameterTypes().length == 0) -+ _ctor = ctors[i]; -+ } -+ -+ if (_ctor == null) { -+ try { -+ _ctor = HashMap.class.getConstructor(new Class[0]); -+ } catch (Exception e) { -+ throw new IllegalStateException(e); -+ } -+ } -+ } -+ -+ public Class getType() -+ { -+ if (_type != null) -+ return _type; -+ else -+ return HashMap.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ Map map; -+ -+ if (_type == null) -+ map = new HashMap(); -+ else if (_type.equals(Map.class)) -+ map = new HashMap(); -+ else if (_type.equals(SortedMap.class)) -+ map = new TreeMap(); -+ else { -+ try { -+ map = (Map) _ctor.newInstance(); -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ in.addRef(map); -+ -+ while (! in.isEnd()) { -+ map.put(in.readObject(), in.readObject()); -+ } -+ -+ in.readEnd(); -+ -+ return map; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ String []fieldNames = (String []) fields; -+ Map map = createMap(); -+ -+ int ref = in.addRef(map); -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ String name = fieldNames[i]; -+ -+ map.put(name, in.readObject()); -+ } -+ -+ return map; -+ } -+ -+ private Map createMap() -+ throws IOException -+ { -+ -+ if (_type == null) -+ return new HashMap(); -+ else if (_type.equals(Map.class)) -+ return new HashMap(); -+ else if (_type.equals(SortedMap.class)) -+ return new TreeMap(); -+ else { -+ try { -+ return (Map) _ctor.newInstance(); -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/MapSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/MapSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/MapSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/MapSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,120 +1,120 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.HashMap; --import java.util.Iterator; --import java.util.Map; -- --/** -- * Serializing a JDK 1.2 java.util.Map. -- */ --public class MapSerializer extends AbstractSerializer { -- private boolean _isSendJavaType = true; -- -- /** -- * Set true if the java type of the collection should be sent. -- */ -- public void setSendJavaType(boolean sendJavaType) -- { -- _isSendJavaType = sendJavaType; -- } -- -- /** -- * Return true if the java type of the collection should be sent. -- */ -- public boolean getSendJavaType() -- { -- return _isSendJavaType; -- } -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) -- return; -- -- Map map = (Map) obj; -- -- Class cl = obj.getClass(); -- -- if (cl.equals(HashMap.class) -- || ! (obj instanceof java.io.Serializable)) -- out.writeMapBegin(null); -- else if (! _isSendJavaType) { -- // hessian/3a19 -- for (; cl != null; cl = cl.getSuperclass()) { -- if (cl.equals(HashMap.class)) { -- out.writeMapBegin(null); -- break; -- } -- else if (cl.getName().startsWith("java.")) { -- out.writeMapBegin(cl.getName()); -- break; -- } -- } -- -- if (cl == null) -- out.writeMapBegin(null); -- } -- else { -- out.writeMapBegin(cl.getName()); -- } -- -- Iterator iter = map.entrySet().iterator(); -- while (iter.hasNext()) { -- Map.Entry entry = (Map.Entry) iter.next(); -- -- out.writeObject(entry.getKey()); -- out.writeObject(entry.getValue()); -- } -- out.writeMapEnd(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.HashMap; -+import java.util.Iterator; -+import java.util.Map; -+ -+/** -+ * Serializing a JDK 1.2 java.util.Map. -+ */ -+public class MapSerializer extends AbstractSerializer { -+ private boolean _isSendJavaType = true; -+ -+ /** -+ * Set true if the java type of the collection should be sent. -+ */ -+ public void setSendJavaType(boolean sendJavaType) -+ { -+ _isSendJavaType = sendJavaType; -+ } -+ -+ /** -+ * Return true if the java type of the collection should be sent. -+ */ -+ public boolean getSendJavaType() -+ { -+ return _isSendJavaType; -+ } -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) -+ return; -+ -+ Map map = (Map) obj; -+ -+ Class cl = obj.getClass(); -+ -+ if (cl.equals(HashMap.class) -+ || ! (obj instanceof java.io.Serializable)) -+ out.writeMapBegin(null); -+ else if (! _isSendJavaType) { -+ // hessian/3a19 -+ for (; cl != null; cl = cl.getSuperclass()) { -+ if (cl.equals(HashMap.class)) { -+ out.writeMapBegin(null); -+ break; -+ } -+ else if (cl.getName().startsWith("java.")) { -+ out.writeMapBegin(cl.getName()); -+ break; -+ } -+ } -+ -+ if (cl == null) -+ out.writeMapBegin(null); -+ } -+ else { -+ out.writeMapBegin(cl.getName()); -+ } -+ -+ Iterator iter = map.entrySet().iterator(); -+ while (iter.hasNext()) { -+ Map.Entry entry = (Map.Entry) iter.next(); -+ -+ out.writeObject(entry.getKey()); -+ out.writeObject(entry.getValue()); -+ } -+ out.writeMapEnd(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java 1970-01-01 08:00:00.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -0,0 +1,755 @@ -+/** -+ * -+ */ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Field; -+import java.lang.reflect.InvocationTargetException; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.HashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import sun.misc.Unsafe; -+ -+/** -+ * @author l65882 -+ * -+ */ -+public class NonTransientUnsafeDeserializer extends AbstractMapDeserializer { -+ private static final Logger log -+ = Logger.getLogger(JavaDeserializer.class.getName()); -+ -+ private static boolean _isEnabled; -+ @SuppressWarnings("restriction") -+ private static Unsafe _unsafe; -+ -+ private Class _type; -+ private HashMap _fieldMap; -+ private Method _readResolve; -+ -+ public NonTransientUnsafeDeserializer(Class cl) -+ { -+ _type = cl; -+ _fieldMap = getFieldMap(cl); -+ -+ _readResolve = getReadResolve(cl); -+ -+ if (_readResolve != null) { -+ _readResolve.setAccessible(true); -+ } -+ } -+ -+ public static boolean isEnabled() -+ { -+ return _isEnabled; -+ } -+ -+ @Override -+ public Class getType() -+ { -+ return _type; -+ } -+ -+ @Override -+ public boolean isReadResolve() -+ { -+ return _readResolve != null; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readMap(in, obj); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ @Override -+ public Object []createFields(int len) -+ { -+ return new FieldDeserializer[len]; -+ } -+ -+ public Object createField(String name) -+ { -+ Object reader = _fieldMap.get(name); -+ -+ if (reader == null) -+ reader = NullFieldDeserializer.DESER; -+ -+ return reader; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readObject(in, obj, (FieldDeserializer []) fields); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ String []fieldNames) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readObject(in, obj, fieldNames); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ /** -+ * Returns the readResolve method -+ */ -+ protected Method getReadResolve(Class cl) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (method.getName().equals("readResolve") -+ && method.getParameterTypes().length == 0) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ public Object readMap(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ while (! in.isEnd()) { -+ Object key = in.readObject(); -+ -+ FieldDeserializer deser = (FieldDeserializer) _fieldMap.get(key); -+ -+ if (deser != null) -+ deser.deserialize(in, obj); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ public Object readObject(AbstractHessianInput in, -+ Object obj, -+ FieldDeserializer []fields) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ for (FieldDeserializer reader : fields) { -+ reader.deserialize(in, obj); -+ } -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -+ } -+ } -+ -+ public Object readObject(AbstractHessianInput in, -+ Object obj, -+ String []fieldNames) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ for (String fieldName : fieldNames) { -+ FieldDeserializer reader = _fieldMap.get(fieldName); -+ -+ if (reader != null) -+ reader.deserialize(in, obj); -+ else -+ in.readObject(); -+ } -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -+ } -+ } -+ -+ protected Object resolve(AbstractHessianInput in, Object obj) -+ throws Exception -+ { -+ // if there's a readResolve method, call it -+ try { -+ if (_readResolve != null) -+ return _readResolve.invoke(obj, new Object[0]); -+ } catch (InvocationTargetException e) { -+ if (e.getCause() instanceof Exception) -+ throw (Exception) e.getCause(); -+ else -+ throw e; -+ } -+ -+ return obj; -+ } -+ -+ @SuppressWarnings("restriction") -+ protected Object instantiate() -+ throws Exception -+ { -+ return _unsafe.allocateInstance(_type); -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected HashMap getFieldMap(Class cl) -+ { -+ HashMap fieldMap -+ = new HashMap(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isStatic(field.getModifiers())) -+ continue; -+ else if (fieldMap.get(field.getName()) != null) -+ continue; -+ // XXX: could parameterize the handler to only deal with public -+ try { -+ field.setAccessible(true); -+ } catch (Throwable e) { -+ e.printStackTrace(); -+ } -+ -+ Class type = field.getType(); -+ FieldDeserializer deser; -+ -+ if (String.class.equals(type)) { -+ deser = new StringFieldDeserializer(field); -+ } -+ else if (byte.class.equals(type)) { -+ deser = new ByteFieldDeserializer(field); -+ } -+ else if (char.class.equals(type)) { -+ deser = new CharFieldDeserializer(field); -+ } -+ else if (short.class.equals(type)) { -+ deser = new ShortFieldDeserializer(field); -+ } -+ else if (int.class.equals(type)) { -+ deser = new IntFieldDeserializer(field); -+ } -+ else if (long.class.equals(type)) { -+ deser = new LongFieldDeserializer(field); -+ } -+ else if (float.class.equals(type)) { -+ deser = new FloatFieldDeserializer(field); -+ } -+ else if (double.class.equals(type)) { -+ deser = new DoubleFieldDeserializer(field); -+ } -+ else if (boolean.class.equals(type)) { -+ deser = new BooleanFieldDeserializer(field); -+ } -+ else if (java.sql.Date.class.equals(type)) { -+ deser = new SqlDateFieldDeserializer(field); -+ } -+ else if (java.sql.Timestamp.class.equals(type)) { -+ deser = new SqlTimestampFieldDeserializer(field); -+ } -+ else if (java.sql.Time.class.equals(type)) { -+ deser = new SqlTimeFieldDeserializer(field); -+ } -+ else { -+ deser = new ObjectFieldDeserializer(field); -+ } -+ -+ fieldMap.put(field.getName(), deser); -+ } -+ } -+ -+ return fieldMap; -+ } -+ -+ abstract static class FieldDeserializer { -+ abstract void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException; -+ } -+ -+ static class NullFieldDeserializer extends FieldDeserializer { -+ static NullFieldDeserializer DESER = new NullFieldDeserializer(); -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ in.readObject(); -+ } -+ } -+ -+ static class ObjectFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ ObjectFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ Object value = null; -+ -+ try { -+ value = in.readObject(_field.getType()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class BooleanFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ BooleanFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ boolean value = false; -+ -+ try { -+ value = in.readBoolean(); -+ -+ _unsafe.putBoolean(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class ByteFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ ByteFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _unsafe.putByte(obj, _offset, (byte) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class CharFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ CharFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ String value = null; -+ -+ try { -+ value = in.readString(); -+ -+ char ch; -+ -+ if (value != null && value.length() > 0) -+ ch = value.charAt(0); -+ else -+ ch = 0; -+ -+ _unsafe.putChar(obj, _offset, ch); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class ShortFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ ShortFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _unsafe.putShort(obj, _offset, (short) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class IntFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ IntFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ int value = 0; -+ -+ try { -+ value = in.readInt(); -+ -+ _unsafe.putInt(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class LongFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ LongFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ long value = 0; -+ -+ try { -+ value = in.readLong(); -+ -+ _unsafe.putLong(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class FloatFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ FloatFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = in.readDouble(); -+ -+ _unsafe.putFloat(obj, _offset, (float) value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class DoubleFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ DoubleFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ double value = 0; -+ -+ try { -+ value = in.readDouble(); -+ -+ _unsafe.putDouble(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class StringFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ StringFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ String value = null; -+ -+ try { -+ value = in.readString(); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlDateFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ SqlDateFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Date value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ value = new java.sql.Date(date.getTime()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlTimestampFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ SqlTimestampFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Timestamp value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ value = new java.sql.Timestamp(date.getTime()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static class SqlTimeFieldDeserializer extends FieldDeserializer { -+ private final Field _field; -+ private final long _offset; -+ -+ @SuppressWarnings("restriction") -+ SqlTimeFieldDeserializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(_field); -+ } -+ -+ @SuppressWarnings("restriction") -+ void deserialize(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ java.sql.Time value = null; -+ -+ try { -+ java.util.Date date = (java.util.Date) in.readObject(); -+ value = new java.sql.Time(date.getTime()); -+ -+ _unsafe.putObject(obj, _offset, value); -+ } catch (Exception e) { -+ logDeserializeError(_field, obj, value, e); -+ } -+ } -+ } -+ -+ static void logDeserializeError(Field field, Object obj, Object value, -+ Throwable e) -+ throws IOException -+ { -+ String fieldName = (field.getDeclaringClass().getName() -+ + "." + field.getName()); -+ -+ if (e instanceof HessianFieldException) -+ throw (HessianFieldException) e; -+ else if (e instanceof IOException) -+ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -+ -+ if (value != null) -+ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -+ + " cannot be assigned to '" + field.getType().getName() + "'", e); -+ else -+ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -+ } -+ -+ static { -+ boolean isEnabled = false; -+ -+ try { -+ Class unsafe = Class.forName("sun.misc.Unsafe"); -+ Field theUnsafe = null; -+ for (Field field : unsafe.getDeclaredFields()) { -+ if (field.getName().equals("theUnsafe")) -+ theUnsafe = field; -+ } -+ -+ if (theUnsafe != null) { -+ theUnsafe.setAccessible(true); -+ _unsafe = (Unsafe) theUnsafe.get(null); -+ } -+ -+ isEnabled = _unsafe != null; -+ -+ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -+ -+ if ("false".equals(unsafeProp)) -+ isEnabled = false; -+ } catch (Throwable e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ _isEnabled = isEnabled; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeSerializer.java 1970-01-01 08:00:00.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -0,0 +1,518 @@ -+/** -+ * -+ */ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.ref.SoftReference; -+import java.lang.reflect.Field; -+import java.lang.reflect.Modifier; -+import java.util.ArrayList; -+import java.util.WeakHashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import sun.misc.Unsafe; -+ -+ -+ -+/** -+ * @author l65882 -+ * -+ */ -+public class NonTransientUnsafeSerializer extends AbstractSerializer { -+ -+ private static final Logger log -+ = Logger.getLogger(NonTransientUnsafeSerializer.class.getName()); -+ -+ private static boolean _isEnabled; -+ private static Unsafe _unsafe; -+ -+ private static final WeakHashMap,SoftReference> _serializerMap -+ = new WeakHashMap,SoftReference>(); -+ -+ private static Object []NULL_ARGS = new Object[0]; -+ -+ private Field []_fields; -+ private FieldSerializer []_fieldSerializers; -+ -+ public static boolean isEnabled() -+ { -+ return _isEnabled; -+ } -+ -+ public NonTransientUnsafeSerializer(Class cl) -+ { -+ introspect(cl); -+ } -+ -+ public static NonTransientUnsafeSerializer create(Class cl) -+ { -+ ClassLoader loader = cl.getClassLoader(); -+ -+ synchronized (_serializerMap) { -+ SoftReference baseRef -+ = _serializerMap.get(cl); -+ -+ NonTransientUnsafeSerializer base = baseRef != null ? baseRef.get() : null; -+ -+ if (base == null) { -+ base = new NonTransientUnsafeSerializer(cl); -+ baseRef = new SoftReference(base); -+ _serializerMap.put(cl, baseRef); -+ } -+ -+ return base; -+ } -+ } -+ -+ protected void introspect(Class cl) -+ { -+ ArrayList primitiveFields = new ArrayList(); -+ ArrayList compoundFields = new ArrayList(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isStatic(field.getModifiers())) -+ continue; -+ -+ // XXX: could parameterize the handler to only deal with public -+ field.setAccessible(true); -+ -+ if (field.getType().isPrimitive() -+ || (field.getType().getName().startsWith("java.lang.") -+ && ! field.getType().equals(Object.class))) -+ primitiveFields.add(field); -+ else -+ compoundFields.add(field); -+ } -+ } -+ -+ ArrayList fields = new ArrayList(); -+ fields.addAll(primitiveFields); -+ fields.addAll(compoundFields); -+ -+ _fields = new Field[fields.size()]; -+ fields.toArray(_fields); -+ -+ _fieldSerializers = new FieldSerializer[_fields.length]; -+ -+ for (int i = 0; i < _fields.length; i++) { -+ _fieldSerializers[i] = getFieldSerializer(_fields[i]); -+ } -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) { -+ return; -+ } -+ -+ Class cl = obj.getClass(); -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref >= 0) { -+ writeInstance(obj, out); -+ } -+ else if (ref == -1) { -+ writeDefinition20(out); -+ out.writeObjectBegin(cl.getName()); -+ writeInstance(obj, out); -+ } -+ else { -+ writeObject10(obj, out); -+ } -+ } -+ -+ protected void writeObject10(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ for (int i = 0; i < _fields.length; i++) { -+ Field field = _fields[i]; -+ -+ out.writeString(field.getName()); -+ -+ _fieldSerializers[i].serialize(out, obj); -+ } -+ -+ out.writeMapEnd(); -+ } -+ -+ private void writeDefinition20(AbstractHessianOutput out) -+ throws IOException -+ { -+ out.writeClassFieldLength(_fields.length); -+ -+ for (int i = 0; i < _fields.length; i++) { -+ Field field = _fields[i]; -+ -+ out.writeString(field.getName()); -+ } -+ } -+ -+ final public void writeInstance(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ try { -+ FieldSerializer []fieldSerializers = _fieldSerializers; -+ int length = fieldSerializers.length; -+ -+ for (int i = 0; i < length; i++) { -+ fieldSerializers[i].serialize(out, obj); -+ } -+ } catch (RuntimeException e) { -+ throw new RuntimeException(e.getMessage() + "\n class: " -+ + obj.getClass().getName() -+ + " (object=" + obj + ")", -+ e); -+ } catch (IOException e) { -+ throw new IOExceptionWrapper(e.getMessage() + "\n class: " -+ + obj.getClass().getName() -+ + " (object=" + obj + ")", -+ e); -+ } -+ } -+ -+ private static FieldSerializer getFieldSerializer(Field field) -+ { -+ Class type = field.getType(); -+ -+ if (boolean.class.equals(type)) { -+ return new BooleanFieldSerializer(field); -+ } -+ else if (byte.class.equals(type)) { -+ return new ByteFieldSerializer(field); -+ } -+ else if (char.class.equals(type)) { -+ return new CharFieldSerializer(field); -+ } -+ else if (short.class.equals(type)) { -+ return new ShortFieldSerializer(field); -+ } -+ else if (int.class.equals(type)) { -+ return new IntFieldSerializer(field); -+ } -+ else if (long.class.equals(type)) { -+ return new LongFieldSerializer(field); -+ } -+ else if (double.class.equals(type)) { -+ return new DoubleFieldSerializer(field); -+ } -+ else if (float.class.equals(type)) { -+ return new FloatFieldSerializer(field); -+ } -+ else if (String.class.equals(type)) { -+ return new StringFieldSerializer(field); -+ } -+ else if (java.util.Date.class.equals(type) -+ || java.sql.Date.class.equals(type) -+ || java.sql.Timestamp.class.equals(type) -+ || java.sql.Time.class.equals(type)) { -+ return new DateFieldSerializer(field); -+ } -+ else -+ return new ObjectFieldSerializer(field); -+ } -+ -+ abstract static class FieldSerializer { -+ abstract void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException; -+ } -+ -+ final static class ObjectFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ ObjectFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ @Override -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ try { -+ Object value = _unsafe.getObject(obj, _offset); -+ -+ out.writeObject(value); -+ } catch (RuntimeException e) { -+ throw new RuntimeException(e.getMessage() + "\n field: " -+ + _field.getDeclaringClass().getName() -+ + '.' + _field.getName(), -+ e); -+ } catch (IOException e) { -+ throw new IOExceptionWrapper(e.getMessage() + "\n field: " -+ + _field.getDeclaringClass().getName() -+ + '.' + _field.getName(), -+ e); -+ } -+ } -+ } -+ -+ final static class BooleanFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ BooleanFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ boolean value = _unsafe.getBoolean(obj, _offset); -+ -+ out.writeBoolean(value); -+ } -+ } -+ -+ final static class ByteFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ ByteFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ int value = _unsafe.getByte(obj, _offset); -+ -+ out.writeInt(value); -+ } -+ } -+ -+ final static class CharFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ CharFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ char value = _unsafe.getChar(obj, _offset); -+ -+ out.writeString(String.valueOf(value)); -+ } -+ } -+ -+ final static class ShortFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ ShortFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ int value = _unsafe.getShort(obj, _offset); -+ -+ out.writeInt(value); -+ } -+ } -+ -+ final static class IntFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ IntFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ int value = _unsafe.getInt(obj, _offset); -+ -+ out.writeInt(value); -+ } -+ } -+ -+ final static class LongFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ LongFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ long value = _unsafe.getLong(obj, _offset); -+ -+ out.writeLong(value); -+ } -+ } -+ -+ final static class FloatFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ FloatFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ double value = _unsafe.getFloat(obj, _offset); -+ -+ out.writeDouble(value); -+ } -+ } -+ -+ final static class DoubleFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ DoubleFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ double value = _unsafe.getDouble(obj, _offset); -+ -+ out.writeDouble(value); -+ } -+ } -+ -+ final static class StringFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ StringFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ @Override -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ String value = (String) _unsafe.getObject(obj, _offset); -+ -+ out.writeString(value); -+ } -+ } -+ -+ final static class DateFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ DateFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ @Override -+ void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ java.util.Date value -+ = (java.util.Date) _unsafe.getObject(obj, _offset); -+ -+ if (value == null) -+ out.writeNull(); -+ else -+ out.writeUTCDate(value.getTime()); -+ } -+ } -+ -+ static { -+ boolean isEnabled = false; -+ -+ try { -+ Class unsafe = Class.forName("sun.misc.Unsafe"); -+ Field theUnsafe = null; -+ for (Field field : unsafe.getDeclaredFields()) { -+ if (field.getName().equals("theUnsafe")) -+ theUnsafe = field; -+ } -+ -+ if (theUnsafe != null) { -+ theUnsafe.setAccessible(true); -+ _unsafe = (Unsafe) theUnsafe.get(null); -+ } -+ -+ isEnabled = _unsafe != null; -+ -+ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -+ -+ if ("false".equals(unsafeProp)) -+ isEnabled = false; -+ } catch (Throwable e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ _isEnabled = isEnabled; -+ } -+ -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ObjectDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,102 +1,102 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing an object for known object types. -- */ --public class ObjectDeserializer extends AbstractDeserializer { -- private Class _cl; -- -- public ObjectDeserializer(Class cl) -- { -- _cl = cl; -- } -- -- public Class getType() -- { -- return _cl; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in) -- throws IOException -- { -- return in.readObject(); -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, Object []fields) -- throws IOException -- { -- throw new UnsupportedOperationException(String.valueOf(this)); -- } -- -- @Override -- public Object readList(AbstractHessianInput in, int length) -- throws IOException -- { -- throw new UnsupportedOperationException(String.valueOf(this)); -- } -- -- @Override -- public Object readLengthList(AbstractHessianInput in, int length) -- throws IOException -- { -- throw new UnsupportedOperationException(String.valueOf(this)); -- } -- -- @Override -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _cl + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class ObjectDeserializer extends AbstractDeserializer { -+ private Class _cl; -+ -+ public ObjectDeserializer(Class cl) -+ { -+ _cl = cl; -+ } -+ -+ public Class getType() -+ { -+ return _cl; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in) -+ throws IOException -+ { -+ return in.readObject(); -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, Object []fields) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(String.valueOf(this)); -+ } -+ -+ @Override -+ public Object readList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(String.valueOf(this)); -+ } -+ -+ @Override -+ public Object readLengthList(AbstractHessianInput in, int length) -+ throws IOException -+ { -+ throw new UnsupportedOperationException(String.valueOf(this)); -+ } -+ -+ @Override -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _cl + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectHandleSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectHandleSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ObjectHandleSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectHandleSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,81 +1,81 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing a remote object. -- */ --public class ObjectHandleSerializer extends AbstractSerializer { -- public static final Serializer SER = new ObjectHandleSerializer(); -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (obj == null) -- out.writeNull(); -- else { -- if (out.addRef(obj)) -- return; -- -- int ref = out.writeObjectBegin("object"); -- -- if (ref < -1) { -- out.writeMapEnd(); -- } -- else { -- if (ref == -1) { -- out.writeInt(0); -- out.writeObjectBegin("object"); -- } -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing a remote object. -+ */ -+public class ObjectHandleSerializer extends AbstractSerializer { -+ public static final Serializer SER = new ObjectHandleSerializer(); -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (obj == null) -+ out.writeNull(); -+ else { -+ if (out.addRef(obj)) -+ return; -+ -+ int ref = out.writeObjectBegin("object"); -+ -+ if (ref < -1) { -+ out.writeMapEnd(); -+ } -+ else { -+ if (ref == -1) { -+ out.writeInt(0); -+ out.writeObjectBegin("object"); -+ } -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectNameDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectNameDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ObjectNameDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectNameDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,76 +1,76 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import javax.management.ObjectName; -- --import com.caucho.hessian.HessianException; -- --/** -- * Deserializing an ObjectName -- */ --public class ObjectNameDeserializer extends AbstractStringValueDeserializer { -- @Override -- public Class getType() -- { -- return ObjectName.class; -- } -- -- @Override -- protected Object create(String value) -- { -- try { -- return new ObjectName(value); -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new HessianException(e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import javax.management.ObjectName; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Deserializing an ObjectName -+ */ -+public class ObjectNameDeserializer extends AbstractStringValueDeserializer { -+ @Override -+ public Class getType() -+ { -+ return ObjectName.class; -+ } -+ -+ @Override -+ protected Object create(String value) -+ { -+ try { -+ return new ObjectName(value); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new HessianException(e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ObjectSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ObjectSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ObjectSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ObjectSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,58 +1,58 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing an object. -- */ --public interface ObjectSerializer { -- public Serializer getObjectSerializer(); --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing an object. -+ */ -+public interface ObjectSerializer { -+ public Serializer getObjectSerializer(); -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/RemoteDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/RemoteDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/RemoteDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/RemoteDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,88 +1,88 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.util.logging.Logger; -- --/** -- * Serializing an object for known object types. -- */ --public class RemoteDeserializer extends JavaDeserializer { -- private static final Logger log -- = Logger.getLogger(RemoteDeserializer.class.getName()); -- -- public static final Deserializer DESER = new RemoteDeserializer(); -- -- public RemoteDeserializer() -- { -- super(HessianRemote.class, FieldDeserializer2Factory.create()); -- } -- -- @Override -- public boolean isReadResolve() -- { -- return true; -- } -- -- @Override -- protected Object resolve(AbstractHessianInput in, Object obj) -- throws Exception -- { -- HessianRemote remote = (HessianRemote) obj; -- HessianRemoteResolver resolver = in.getRemoteResolver(); -- -- if (resolver != null) { -- Object proxy = resolver.lookup(remote.getType(), remote.getURL()); -- -- return proxy; -- } -- else -- return remote; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.util.logging.Logger; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class RemoteDeserializer extends JavaDeserializer { -+ private static final Logger log -+ = Logger.getLogger(RemoteDeserializer.class.getName()); -+ -+ public static final Deserializer DESER = new RemoteDeserializer(); -+ -+ public RemoteDeserializer() -+ { -+ super(HessianRemote.class, FieldDeserializer2Factory.create()); -+ } -+ -+ @Override -+ public boolean isReadResolve() -+ { -+ return true; -+ } -+ -+ @Override -+ protected Object resolve(AbstractHessianInput in, Object obj) -+ throws Exception -+ { -+ HessianRemote remote = (HessianRemote) obj; -+ HessianRemoteResolver resolver = in.getRemoteResolver(); -+ -+ if (resolver != null) { -+ Object proxy = resolver.lookup(remote.getType(), remote.getURL()); -+ -+ return proxy; -+ } -+ else -+ return remote; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/RemoteSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/RemoteSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/RemoteSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/RemoteSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,67 +1,67 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import com.caucho.burlap.io.BurlapRemoteObject; -- --import java.io.IOException; -- --/** -- * Serializing a remote object. -- */ --public class RemoteSerializer extends AbstractSerializer { -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- HessianRemoteObject remoteObject = (HessianRemoteObject) obj; -- -- out.writeObject(new HessianRemote(remoteObject.getHessianType(), -- remoteObject.getHessianURL())); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import com.caucho.burlap.io.BurlapRemoteObject; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing a remote object. -+ */ -+public class RemoteSerializer extends AbstractSerializer { -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ HessianRemoteObject remoteObject = (HessianRemoteObject) obj; -+ -+ out.writeObject(new HessianRemote(remoteObject.getHessianType(), -+ remoteObject.getHessianURL())); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/Serializer.java hessian-4.0.65-fix/com/caucho/hessian/io/Serializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/Serializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/Serializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,59 +1,59 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing an object. -- */ --public interface Serializer { -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing an object. -+ */ -+public interface Serializer { -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/SerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/io/SerializerFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/io/SerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/SerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,804 +1,810 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.io.InputStream; --import java.io.Serializable; --import java.lang.annotation.Annotation; --import java.lang.ref.SoftReference; --import java.lang.ref.WeakReference; --import java.net.InetAddress; --import java.util.ArrayList; --import java.util.Calendar; --import java.util.Collection; --import java.util.Enumeration; --import java.util.HashMap; --import java.util.Iterator; --import java.util.Map; --import java.util.WeakHashMap; --import java.util.concurrent.ConcurrentHashMap; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import com.caucho.burlap.io.BurlapRemoteObject; -- --/** -- * Factory for returning serialization methods. -- */ --public class SerializerFactory extends AbstractSerializerFactory --{ -- private static final Logger log -- = Logger.getLogger(SerializerFactory.class.getName()); -- -- private static final Deserializer OBJECT_DESERIALIZER -- = new BasicDeserializer(BasicDeserializer.OBJECT); -- -- private static final ClassLoader _systemClassLoader; -- -- private static final HashMap _staticTypeMap; -- -- private static final -- WeakHashMap> -- _defaultFactoryRefMap -- = new WeakHashMap>(); -- -- private ContextSerializerFactory _contextFactory; -- private WeakReference _loaderRef; -- -- protected Serializer _defaultSerializer; -- -- // Additional factories -- protected ArrayList _factories = new ArrayList(); -- -- protected CollectionSerializer _collectionSerializer; -- protected MapSerializer _mapSerializer; -- -- private Deserializer _hashMapDeserializer; -- private Deserializer _arrayListDeserializer; -- private Map _cachedSerializerMap; -- private Map _cachedDeserializerMap; -- private HashMap _cachedTypeDeserializerMap; -- -- private boolean _isAllowNonSerializable; -- private boolean _isEnableUnsafeSerializer -- = (UnsafeSerializer.isEnabled() -- && UnsafeDeserializer.isEnabled()); -- -- private FieldDeserializer2Factory _fieldDeserializerFactory; -- -- private ClassFactory _classFactory; -- -- public SerializerFactory() -- { -- this(Thread.currentThread().getContextClassLoader()); -- } -- -- public SerializerFactory(ClassLoader loader) -- { -- _loaderRef = new WeakReference(loader); -- -- _contextFactory = ContextSerializerFactory.create(loader); -- -- if (_isEnableUnsafeSerializer) { -- _fieldDeserializerFactory = new FieldDeserializer2FactoryUnsafe(); -- } -- else { -- _fieldDeserializerFactory = new FieldDeserializer2Factory(); -- } -- } -- -- public static SerializerFactory createDefault() -- { -- ClassLoader loader = Thread.currentThread().getContextClassLoader(); -- -- synchronized (_defaultFactoryRefMap) { -- SoftReference factoryRef -- = _defaultFactoryRefMap.get(loader); -- -- SerializerFactory factory = null; -- -- if (factoryRef != null) -- factory = factoryRef.get(); -- -- if (factory == null) { -- factory = new SerializerFactory(); -- -- factoryRef = new SoftReference(factory); -- -- _defaultFactoryRefMap.put(loader, factoryRef); -- } -- -- return factory; -- } -- } -- -- public ClassLoader getClassLoader() -- { -- return _loaderRef.get(); -- } -- -- /** -- * Set true if the collection serializer should send the java type. -- */ -- public void setSendCollectionType(boolean isSendType) -- { -- if (_collectionSerializer == null) -- _collectionSerializer = new CollectionSerializer(); -- -- _collectionSerializer.setSendJavaType(isSendType); -- -- if (_mapSerializer == null) -- _mapSerializer = new MapSerializer(); -- -- _mapSerializer.setSendJavaType(isSendType); -- } -- -- /** -- * Adds a factory. -- */ -- public void addFactory(AbstractSerializerFactory factory) -- { -- _factories.add(factory); -- } -- -- /** -- * If true, non-serializable objects are allowed. -- */ -- public void setAllowNonSerializable(boolean allow) -- { -- _isAllowNonSerializable = allow; -- } -- -- /** -- * If true, non-serializable objects are allowed. -- */ -- public boolean isAllowNonSerializable() -- { -- return _isAllowNonSerializable; -- } -- -- /** -- * Returns the serializer for a class. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- public Serializer getObjectSerializer(Class cl) -- throws HessianProtocolException -- { -- Serializer serializer = getSerializer(cl); -- -- if (serializer instanceof ObjectSerializer) -- return ((ObjectSerializer) serializer).getObjectSerializer(); -- else -- return serializer; -- } -- -- public Class loadSerializedClass(String className) -- throws ClassNotFoundException -- { -- return getClassFactory().load(className); -- } -- -- public ClassFactory getClassFactory() -- { -- synchronized (this) { -- if (_classFactory == null) { -- _classFactory = new ClassFactory(getClassLoader()); -- } -- -- return _classFactory; -- } -- } -- -- public FieldDeserializer2Factory getFieldDeserializerFactory() -- { -- return _fieldDeserializerFactory; -- } -- -- /** -- * Returns the serializer for a class. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- public Serializer getSerializer(Class cl) -- throws HessianProtocolException -- { -- Serializer serializer; -- -- if (_cachedSerializerMap != null) { -- serializer = (Serializer) _cachedSerializerMap.get(cl); -- -- if (serializer != null) { -- return serializer; -- } -- } -- -- serializer = loadSerializer(cl); -- -- if (_cachedSerializerMap == null) -- _cachedSerializerMap = new ConcurrentHashMap(8); -- -- _cachedSerializerMap.put(cl, serializer); -- -- return serializer; -- } -- -- protected Serializer loadSerializer(Class cl) -- throws HessianProtocolException -- { -- Serializer serializer = null; -- -- for (int i = 0; -- _factories != null && i < _factories.size(); -- i++) { -- AbstractSerializerFactory factory; -- -- factory = (AbstractSerializerFactory) _factories.get(i); -- -- serializer = factory.getSerializer(cl); -- -- if (serializer != null) -- return serializer; -- } -- -- serializer = _contextFactory.getSerializer(cl.getName()); -- -- if (serializer != null) -- return serializer; -- -- ClassLoader loader = cl.getClassLoader(); -- -- if (loader == null) -- loader = _systemClassLoader; -- -- ContextSerializerFactory factory = null; -- -- factory = ContextSerializerFactory.create(loader); -- -- serializer = factory.getCustomSerializer(cl); -- -- if (serializer != null) { -- return serializer; -- } -- -- if (HessianRemoteObject.class.isAssignableFrom(cl)) { -- return new RemoteSerializer(); -- } -- else if (BurlapRemoteObject.class.isAssignableFrom(cl)) { -- return new RemoteSerializer(); -- } -- else if (InetAddress.class.isAssignableFrom(cl)) { -- return InetAddressSerializer.create(); -- } -- else if (JavaSerializer.getWriteReplace(cl) != null) { -- Serializer baseSerializer = getDefaultSerializer(cl); -- -- return new WriteReplaceSerializer(cl, getClassLoader(), baseSerializer); -- } -- else if (Map.class.isAssignableFrom(cl)) { -- if (_mapSerializer == null) -- _mapSerializer = new MapSerializer(); -- -- return _mapSerializer; -- } -- else if (Collection.class.isAssignableFrom(cl)) { -- if (_collectionSerializer == null) { -- _collectionSerializer = new CollectionSerializer(); -- } -- -- return _collectionSerializer; -- } -- -- else if (cl.isArray()) { -- return new ArraySerializer(); -- } -- -- else if (Throwable.class.isAssignableFrom(cl)) -- return new ThrowableSerializer(getDefaultSerializer(cl)); -- -- else if (InputStream.class.isAssignableFrom(cl)) -- return new InputStreamSerializer(); -- -- else if (Iterator.class.isAssignableFrom(cl)) -- return IteratorSerializer.create(); -- -- else if (Calendar.class.isAssignableFrom(cl)) -- return CalendarSerializer.SER; -- -- else if (Enumeration.class.isAssignableFrom(cl)) -- return EnumerationSerializer.create(); -- -- else if (Enum.class.isAssignableFrom(cl)) -- return new EnumSerializer(cl); -- -- else if (Annotation.class.isAssignableFrom(cl)) -- return new AnnotationSerializer(cl); -- -- return getDefaultSerializer(cl); -- } -- -- /** -- * Returns the default serializer for a class that isn't matched -- * directly. Application can override this method to produce -- * bean-style serialization instead of field serialization. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- protected Serializer getDefaultSerializer(Class cl) -- { -- if (_defaultSerializer != null) -- return _defaultSerializer; -- -- if (! Serializable.class.isAssignableFrom(cl) -- && ! _isAllowNonSerializable) { -- throw new IllegalStateException("Serialized class " + cl.getName() + " must implement java.io.Serializable"); -- } -- -- if (_isEnableUnsafeSerializer -- && JavaSerializer.getWriteReplace(cl) == null) { -- return UnsafeSerializer.create(cl); -- } -- else -- return JavaSerializer.create(cl); -- } -- -- /** -- * Returns the deserializer for a class. -- * -- * @param cl the class of the object that needs to be deserialized. -- * -- * @return a deserializer object for the serialization. -- */ -- public Deserializer getDeserializer(Class cl) -- throws HessianProtocolException -- { -- Deserializer deserializer; -- -- if (_cachedDeserializerMap != null) { -- deserializer = (Deserializer) _cachedDeserializerMap.get(cl); -- -- if (deserializer != null) -- return deserializer; -- } -- -- deserializer = loadDeserializer(cl); -- -- if (_cachedDeserializerMap == null) -- _cachedDeserializerMap = new ConcurrentHashMap(8); -- -- _cachedDeserializerMap.put(cl, deserializer); -- -- return deserializer; -- } -- -- protected Deserializer loadDeserializer(Class cl) -- throws HessianProtocolException -- { -- Deserializer deserializer = null; -- -- for (int i = 0; -- deserializer == null && _factories != null && i < _factories.size(); -- i++) { -- AbstractSerializerFactory factory; -- factory = (AbstractSerializerFactory) _factories.get(i); -- -- deserializer = factory.getDeserializer(cl); -- } -- -- if (deserializer != null) -- return deserializer; -- -- // XXX: need test -- deserializer = _contextFactory.getDeserializer(cl.getName()); -- -- if (deserializer != null) -- return deserializer; -- -- ContextSerializerFactory factory = null; -- -- if (cl.getClassLoader() != null) -- factory = ContextSerializerFactory.create(cl.getClassLoader()); -- else -- factory = ContextSerializerFactory.create(_systemClassLoader); -- -- deserializer = factory.getDeserializer(cl.getName()); -- -- if (deserializer != null) -- return deserializer; -- -- deserializer = factory.getCustomDeserializer(cl); -- -- if (deserializer != null) -- return deserializer; -- -- if (Collection.class.isAssignableFrom(cl)) -- deserializer = new CollectionDeserializer(cl); -- -- else if (Map.class.isAssignableFrom(cl)) { -- deserializer = new MapDeserializer(cl); -- } -- else if (Iterator.class.isAssignableFrom(cl)) { -- deserializer = IteratorDeserializer.create(); -- } -- else if (Annotation.class.isAssignableFrom(cl)) { -- deserializer = new AnnotationDeserializer(cl); -- } -- else if (cl.isInterface()) { -- deserializer = new ObjectDeserializer(cl); -- } -- else if (cl.isArray()) { -- deserializer = new ArrayDeserializer(cl.getComponentType()); -- } -- else if (Enumeration.class.isAssignableFrom(cl)) { -- deserializer = EnumerationDeserializer.create(); -- } -- else if (Enum.class.isAssignableFrom(cl)) -- deserializer = new EnumDeserializer(cl); -- -- else if (Class.class.equals(cl)) -- deserializer = new ClassDeserializer(getClassLoader()); -- -- else -- deserializer = getDefaultDeserializer(cl); -- -- return deserializer; -- } -- -- /** -- * Returns a custom serializer the class -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- protected Deserializer getCustomDeserializer(Class cl) -- { -- try { -- Class serClass = Class.forName(cl.getName() + "HessianDeserializer", -- false, cl.getClassLoader()); -- -- Deserializer ser = (Deserializer) serClass.newInstance(); -- -- return ser; -- } catch (ClassNotFoundException e) { -- log.log(Level.FINEST, e.toString(), e); -- -- return null; -- } catch (Exception e) { -- log.log(Level.FINE, e.toString(), e); -- -- return null; -- } -- } -- -- /** -- * Returns the default serializer for a class that isn't matched -- * directly. Application can override this method to produce -- * bean-style serialization instead of field serialization. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- protected Deserializer getDefaultDeserializer(Class cl) -- { -- if (InputStream.class.equals(cl)) -- return InputStreamDeserializer.DESER; -- -- if (_isEnableUnsafeSerializer) { -- return new UnsafeDeserializer(cl, _fieldDeserializerFactory); -- } -- else -- return new JavaDeserializer(cl, _fieldDeserializerFactory); -- } -- -- /** -- * Reads the object as a list. -- */ -- public Object readList(AbstractHessianInput in, int length, String type) -- throws HessianProtocolException, IOException -- { -- Deserializer deserializer = getDeserializer(type); -- -- if (deserializer != null) -- return deserializer.readList(in, length); -- else -- return new CollectionDeserializer(ArrayList.class).readList(in, length); -- } -- -- /** -- * Reads the object as a map. -- */ -- public Object readMap(AbstractHessianInput in, String type) -- throws HessianProtocolException, IOException -- { -- Deserializer deserializer = getDeserializer(type); -- -- if (deserializer != null) -- return deserializer.readMap(in); -- else if (_hashMapDeserializer != null) -- return _hashMapDeserializer.readMap(in); -- else { -- _hashMapDeserializer = new MapDeserializer(HashMap.class); -- -- return _hashMapDeserializer.readMap(in); -- } -- } -- -- /** -- * Reads the object as a map. -- */ -- public Object readObject(AbstractHessianInput in, -- String type, -- String []fieldNames) -- throws HessianProtocolException, IOException -- { -- Deserializer deserializer = getDeserializer(type); -- -- if (deserializer != null) -- return deserializer.readObject(in, fieldNames); -- else if (_hashMapDeserializer != null) -- return _hashMapDeserializer.readObject(in, fieldNames); -- else { -- _hashMapDeserializer = new MapDeserializer(HashMap.class); -- -- return _hashMapDeserializer.readObject(in, fieldNames); -- } -- } -- -- /** -- * Reads the object as a map. -- */ -- public Deserializer getObjectDeserializer(String type, Class cl) -- throws HessianProtocolException -- { -- Deserializer reader = getObjectDeserializer(type); -- -- if (cl == null -- || cl.equals(reader.getType()) -- || cl.isAssignableFrom(reader.getType()) -- || reader.isReadResolve() -- || HessianHandle.class.isAssignableFrom(reader.getType())) { -- return reader; -- } -- -- if (log.isLoggable(Level.FINE)) { -- log.fine("hessian: expected deserializer '" + cl.getName() + "' at '" + type + "' (" -- + reader.getType().getName() + ")"); -- } -- -- return getDeserializer(cl); -- } -- -- /** -- * Reads the object as a map. -- */ -- public Deserializer getObjectDeserializer(String type) -- throws HessianProtocolException -- { -- Deserializer deserializer = getDeserializer(type); -- -- if (deserializer != null) -- return deserializer; -- else if (_hashMapDeserializer != null) -- return _hashMapDeserializer; -- else { -- _hashMapDeserializer = new MapDeserializer(HashMap.class); -- -- return _hashMapDeserializer; -- } -- } -- -- /** -- * Reads the object as a map. -- */ -- public Deserializer getListDeserializer(String type, Class cl) -- throws HessianProtocolException -- { -- Deserializer reader = getListDeserializer(type); -- -- if (cl == null -- || cl.equals(reader.getType()) -- || cl.isAssignableFrom(reader.getType())) { -- return reader; -- } -- -- if (log.isLoggable(Level.FINE)) { -- log.fine("hessian: expected '" + cl.getName() + "' at '" + type + "' (" -- + reader.getType().getName() + ")"); -- } -- -- return getDeserializer(cl); -- } -- -- /** -- * Reads the object as a map. -- */ -- public Deserializer getListDeserializer(String type) -- throws HessianProtocolException -- { -- Deserializer deserializer = getDeserializer(type); -- -- if (deserializer != null) -- return deserializer; -- else if (_arrayListDeserializer != null) -- return _arrayListDeserializer; -- else { -- _arrayListDeserializer = new CollectionDeserializer(ArrayList.class); -- -- return _arrayListDeserializer; -- } -- } -- -- /** -- * Returns a deserializer based on a string type. -- */ -- public Deserializer getDeserializer(String type) -- throws HessianProtocolException -- { -- if (type == null || type.equals("")) -- return null; -- -- Deserializer deserializer; -- -- if (_cachedTypeDeserializerMap != null) { -- synchronized (_cachedTypeDeserializerMap) { -- deserializer = (Deserializer) _cachedTypeDeserializerMap.get(type); -- } -- -- if (deserializer != null) -- return deserializer; -- } -- -- -- deserializer = (Deserializer) _staticTypeMap.get(type); -- if (deserializer != null) -- return deserializer; -- -- if (type.startsWith("[")) { -- Deserializer subDeserializer = getDeserializer(type.substring(1)); -- -- if (subDeserializer != null) -- deserializer = new ArrayDeserializer(subDeserializer.getType()); -- else -- deserializer = new ArrayDeserializer(Object.class); -- } -- else { -- try { -- //Class cl = Class.forName(type, false, getClassLoader()); -- -- Class cl = loadSerializedClass(type); -- -- deserializer = getDeserializer(cl); -- } catch (Exception e) { -- log.warning("Hessian/Burlap: '" + type + "' is an unknown class in " + getClassLoader() + ":\n" + e); -- -- log.log(Level.FINER, e.toString(), e); -- } -- } -- -- if (deserializer != null) { -- if (_cachedTypeDeserializerMap == null) -- _cachedTypeDeserializerMap = new HashMap(8); -- -- synchronized (_cachedTypeDeserializerMap) { -- _cachedTypeDeserializerMap.put(type, deserializer); -- } -- } -- -- return deserializer; -- } -- -- private static void addBasic(Class cl, String typeName, int type) -- { -- Deserializer deserializer = new BasicDeserializer(type); -- -- _staticTypeMap.put(typeName, deserializer); -- } -- -- static { -- _staticTypeMap = new HashMap(); -- -- addBasic(void.class, "void", BasicSerializer.NULL); -- -- addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); -- addBasic(Byte.class, "byte", BasicSerializer.BYTE); -- addBasic(Short.class, "short", BasicSerializer.SHORT); -- addBasic(Integer.class, "int", BasicSerializer.INTEGER); -- addBasic(Long.class, "long", BasicSerializer.LONG); -- addBasic(Float.class, "float", BasicSerializer.FLOAT); -- addBasic(Double.class, "double", BasicSerializer.DOUBLE); -- addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); -- addBasic(String.class, "string", BasicSerializer.STRING); -- addBasic(StringBuilder.class, "string", BasicSerializer.STRING_BUILDER); -- addBasic(Object.class, "object", BasicSerializer.OBJECT); -- addBasic(java.util.Date.class, "date", BasicSerializer.DATE); -- -- addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); -- addBasic(byte.class, "byte", BasicSerializer.BYTE); -- addBasic(short.class, "short", BasicSerializer.SHORT); -- addBasic(int.class, "int", BasicSerializer.INTEGER); -- addBasic(long.class, "long", BasicSerializer.LONG); -- addBasic(float.class, "float", BasicSerializer.FLOAT); -- addBasic(double.class, "double", BasicSerializer.DOUBLE); -- addBasic(char.class, "char", BasicSerializer.CHARACTER); -- -- addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); -- addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); -- addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); -- addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); -- addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); -- addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); -- addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); -- addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); -- addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); -- addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); -- -- Deserializer objectDeserializer = new JavaDeserializer(Object.class, new FieldDeserializer2Factory()); -- _staticTypeMap.put("object", objectDeserializer); -- _staticTypeMap.put(HessianRemote.class.getName(), -- RemoteDeserializer.DESER); -- -- -- ClassLoader systemClassLoader = null; -- try { -- systemClassLoader = ClassLoader.getSystemClassLoader(); -- } catch (Exception e) { -- } -- -- _systemClassLoader = systemClassLoader; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.Serializable; -+import java.lang.annotation.Annotation; -+import java.lang.ref.SoftReference; -+import java.lang.ref.WeakReference; -+import java.net.InetAddress; -+import java.math.BigDecimal; -+import java.util.ArrayList; -+import java.util.Calendar; -+import java.util.Collection; -+import java.util.Enumeration; -+import java.util.HashMap; -+import java.util.Iterator; -+import java.util.Map; -+import java.util.WeakHashMap; -+import java.util.concurrent.ConcurrentHashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import com.caucho.burlap.io.BurlapRemoteObject; -+ -+/** -+ * Factory for returning serialization methods. -+ */ -+public class SerializerFactory extends AbstractSerializerFactory -+{ -+ private static final Logger log -+ = Logger.getLogger(SerializerFactory.class.getName()); -+ -+ private static final Deserializer OBJECT_DESERIALIZER -+ = new BasicDeserializer(BasicDeserializer.OBJECT); -+ -+ private static final ClassLoader _systemClassLoader; -+ -+ private static final HashMap _staticTypeMap; -+ -+ private static final -+ WeakHashMap> -+ _defaultFactoryRefMap -+ = new WeakHashMap>(); -+ -+ private ContextSerializerFactory _contextFactory; -+ private WeakReference _loaderRef; -+ -+ protected Serializer _defaultSerializer; -+ -+ // Additional factories -+ protected ArrayList _factories = new ArrayList(); -+ -+ protected CollectionSerializer _collectionSerializer; -+ protected MapSerializer _mapSerializer; -+ -+ private Deserializer _hashMapDeserializer; -+ private Deserializer _arrayListDeserializer; -+ private Map _cachedSerializerMap; -+ private Map _cachedDeserializerMap; -+ private HashMap _cachedTypeDeserializerMap; -+ -+ private boolean _isAllowNonSerializable; -+ private boolean _isEnableUnsafeSerializer -+ = (UnsafeSerializer.isEnabled() -+ && UnsafeDeserializer.isEnabled()); -+ -+ private FieldDeserializer2Factory _fieldDeserializerFactory; -+ -+ private ClassFactory _classFactory; -+ -+ public SerializerFactory() -+ { -+ this(Thread.currentThread().getContextClassLoader()); -+ } -+ -+ public SerializerFactory(ClassLoader loader) -+ { -+ _loaderRef = new WeakReference(loader); -+ -+ _contextFactory = ContextSerializerFactory.create(loader); -+ -+ if (_isEnableUnsafeSerializer) { -+ _fieldDeserializerFactory = new FieldDeserializer2FactoryUnsafe(); -+ } -+ else { -+ _fieldDeserializerFactory = new FieldDeserializer2Factory(); -+ } -+ } -+ -+ public static SerializerFactory createDefault() -+ { -+ ClassLoader loader = Thread.currentThread().getContextClassLoader(); -+ -+ synchronized (_defaultFactoryRefMap) { -+ SoftReference factoryRef -+ = _defaultFactoryRefMap.get(loader); -+ -+ SerializerFactory factory = null; -+ -+ if (factoryRef != null) -+ factory = factoryRef.get(); -+ -+ if (factory == null) { -+ factory = new SerializerFactory(); -+ -+ factoryRef = new SoftReference(factory); -+ -+ _defaultFactoryRefMap.put(loader, factoryRef); -+ } -+ -+ return factory; -+ } -+ } -+ -+ public ClassLoader getClassLoader() -+ { -+ return _loaderRef.get(); -+ } -+ -+ /** -+ * Set true if the collection serializer should send the java type. -+ */ -+ public void setSendCollectionType(boolean isSendType) -+ { -+ if (_collectionSerializer == null) -+ _collectionSerializer = new CollectionSerializer(); -+ -+ _collectionSerializer.setSendJavaType(isSendType); -+ -+ if (_mapSerializer == null) -+ _mapSerializer = new MapSerializer(); -+ -+ _mapSerializer.setSendJavaType(isSendType); -+ } -+ -+ /** -+ * Adds a factory. -+ */ -+ public void addFactory(AbstractSerializerFactory factory) -+ { -+ _factories.add(factory); -+ } -+ -+ /** -+ * If true, non-serializable objects are allowed. -+ */ -+ public void setAllowNonSerializable(boolean allow) -+ { -+ _isAllowNonSerializable = allow; -+ } -+ -+ /** -+ * If true, non-serializable objects are allowed. -+ */ -+ public boolean isAllowNonSerializable() -+ { -+ return _isAllowNonSerializable; -+ } -+ -+ /** -+ * Returns the serializer for a class. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ public Serializer getObjectSerializer(Class cl) -+ throws HessianProtocolException -+ { -+ Serializer serializer = getSerializer(cl); -+ -+ if (serializer instanceof ObjectSerializer) -+ return ((ObjectSerializer) serializer).getObjectSerializer(); -+ else -+ return serializer; -+ } -+ -+ public Class loadSerializedClass(String className) -+ throws ClassNotFoundException -+ { -+ return getClassFactory().load(className); -+ } -+ -+ public ClassFactory getClassFactory() -+ { -+ synchronized (this) { -+ if (_classFactory == null) { -+ _classFactory = new ClassFactory(getClassLoader()); -+ } -+ -+ return _classFactory; -+ } -+ } -+ -+ public FieldDeserializer2Factory getFieldDeserializerFactory() -+ { -+ return _fieldDeserializerFactory; -+ } -+ -+ /** -+ * Returns the serializer for a class. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ public Serializer getSerializer(Class cl) -+ throws HessianProtocolException -+ { -+ Serializer serializer; -+ -+ if (_cachedSerializerMap != null) { -+ serializer = (Serializer) _cachedSerializerMap.get(cl); -+ -+ if (serializer != null) { -+ return serializer; -+ } -+ } -+ -+ serializer = loadSerializer(cl); -+ -+ if (_cachedSerializerMap == null) -+ _cachedSerializerMap = new ConcurrentHashMap(8); -+ -+ _cachedSerializerMap.put(cl, serializer); -+ -+ return serializer; -+ } -+ -+ protected Serializer loadSerializer(Class cl) -+ throws HessianProtocolException -+ { -+ Serializer serializer = null; -+ -+ for (int i = 0; -+ _factories != null && i < _factories.size(); -+ i++) { -+ AbstractSerializerFactory factory; -+ -+ factory = (AbstractSerializerFactory) _factories.get(i); -+ -+ serializer = factory.getSerializer(cl); -+ -+ if (serializer != null) -+ return serializer; -+ } -+ -+ serializer = _contextFactory.getSerializer(cl.getName()); -+ -+ if (serializer != null) -+ return serializer; -+ -+ ClassLoader loader = cl.getClassLoader(); -+ -+ if (loader == null) -+ loader = _systemClassLoader; -+ -+ ContextSerializerFactory factory = null; -+ -+ factory = ContextSerializerFactory.create(loader); -+ -+ serializer = factory.getCustomSerializer(cl); -+ -+ if (serializer != null) { -+ return serializer; -+ } -+ -+ if (HessianRemoteObject.class.isAssignableFrom(cl)) { -+ return new RemoteSerializer(); -+ } -+ else if (BurlapRemoteObject.class.isAssignableFrom(cl)) { -+ return new RemoteSerializer(); -+ } -+ else if (InetAddress.class.isAssignableFrom(cl)) { -+ return InetAddressSerializer.create(); -+ } -+ else if (JavaSerializer.getWriteReplace(cl) != null) { -+ Serializer baseSerializer = getDefaultSerializer(cl); -+ -+ return new WriteReplaceSerializer(cl, getClassLoader(), baseSerializer); -+ } -+ else if (Map.class.isAssignableFrom(cl)) { -+ if (_mapSerializer == null) -+ _mapSerializer = new MapSerializer(); -+ -+ return _mapSerializer; -+ } -+ else if (Collection.class.isAssignableFrom(cl)) { -+ if (_collectionSerializer == null) { -+ _collectionSerializer = new CollectionSerializer(); -+ } -+ -+ return _collectionSerializer; -+ } -+ -+ else if (cl.isArray()) { -+ return new ArraySerializer(); -+ } -+ -+ else if (Throwable.class.isAssignableFrom(cl)) -+ return new ThrowableSerializer(getDefaultSerializer(cl)); -+ -+ else if (InputStream.class.isAssignableFrom(cl)) -+ return new InputStreamSerializer(); -+ -+ else if (Iterator.class.isAssignableFrom(cl)) -+ return IteratorSerializer.create(); -+ -+ else if (Calendar.class.isAssignableFrom(cl)) -+ return CalendarSerializer.SER; -+ -+ else if (Enumeration.class.isAssignableFrom(cl)) -+ return EnumerationSerializer.create(); -+ -+ else if (Enum.class.isAssignableFrom(cl)) -+ return new EnumSerializer(cl); -+ -+ else if (Annotation.class.isAssignableFrom(cl)) -+ return new AnnotationSerializer(cl); -+ -+ else if (BigDecimal.class.isAssignableFrom(cl)) -+ return new NonTransientUnsafeSerializer(cl); -+ else -+ return getDefaultSerializer(cl); -+ } -+ -+ /** -+ * Returns the default serializer for a class that isn't matched -+ * directly. Application can override this method to produce -+ * bean-style serialization instead of field serialization. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ protected Serializer getDefaultSerializer(Class cl) -+ { -+ if (_defaultSerializer != null) -+ return _defaultSerializer; -+ -+ if (! Serializable.class.isAssignableFrom(cl) -+ && ! _isAllowNonSerializable) { -+ throw new IllegalStateException("Serialized class " + cl.getName() + " must implement java.io.Serializable"); -+ } -+ -+ if (_isEnableUnsafeSerializer -+ && JavaSerializer.getWriteReplace(cl) == null) { -+ return UnsafeSerializer.create(cl); -+ } -+ else -+ return JavaSerializer.create(cl); -+ } -+ -+ /** -+ * Returns the deserializer for a class. -+ * -+ * @param cl the class of the object that needs to be deserialized. -+ * -+ * @return a deserializer object for the serialization. -+ */ -+ public Deserializer getDeserializer(Class cl) -+ throws HessianProtocolException -+ { -+ Deserializer deserializer; -+ -+ if (_cachedDeserializerMap != null) { -+ deserializer = (Deserializer) _cachedDeserializerMap.get(cl); -+ -+ if (deserializer != null) -+ return deserializer; -+ } -+ -+ deserializer = loadDeserializer(cl); -+ -+ if (_cachedDeserializerMap == null) -+ _cachedDeserializerMap = new ConcurrentHashMap(8); -+ -+ _cachedDeserializerMap.put(cl, deserializer); -+ -+ return deserializer; -+ } -+ -+ protected Deserializer loadDeserializer(Class cl) -+ throws HessianProtocolException -+ { -+ Deserializer deserializer = null; -+ -+ for (int i = 0; -+ deserializer == null && _factories != null && i < _factories.size(); -+ i++) { -+ AbstractSerializerFactory factory; -+ factory = (AbstractSerializerFactory) _factories.get(i); -+ -+ deserializer = factory.getDeserializer(cl); -+ } -+ -+ if (deserializer != null) -+ return deserializer; -+ -+ // XXX: need test -+ deserializer = _contextFactory.getDeserializer(cl.getName()); -+ -+ if (deserializer != null) -+ return deserializer; -+ -+ ContextSerializerFactory factory = null; -+ -+ if (cl.getClassLoader() != null) -+ factory = ContextSerializerFactory.create(cl.getClassLoader()); -+ else -+ factory = ContextSerializerFactory.create(_systemClassLoader); -+ -+ deserializer = factory.getDeserializer(cl.getName()); -+ -+ if (deserializer != null) -+ return deserializer; -+ -+ deserializer = factory.getCustomDeserializer(cl); -+ -+ if (deserializer != null) -+ return deserializer; -+ -+ if (Collection.class.isAssignableFrom(cl)) -+ deserializer = new CollectionDeserializer(cl); -+ -+ else if (Map.class.isAssignableFrom(cl)) { -+ deserializer = new MapDeserializer(cl); -+ } -+ else if (Iterator.class.isAssignableFrom(cl)) { -+ deserializer = IteratorDeserializer.create(); -+ } -+ else if (Annotation.class.isAssignableFrom(cl)) { -+ deserializer = new AnnotationDeserializer(cl); -+ } -+ else if (cl.isInterface()) { -+ deserializer = new ObjectDeserializer(cl); -+ } -+ else if (cl.isArray()) { -+ deserializer = new ArrayDeserializer(cl.getComponentType()); -+ } -+ else if (Enumeration.class.isAssignableFrom(cl)) { -+ deserializer = EnumerationDeserializer.create(); -+ } -+ else if (Enum.class.isAssignableFrom(cl)){ -+ deserializer = new EnumDeserializer(cl); -+ } -+ else if (Class.class.equals(cl)) -+ deserializer = new ClassDeserializer(getClassLoader()); -+ -+ else if (BigDecimal.class.equals(cl)) -+ deserializer = new NonTransientUnsafeDeserializer(cl); -+ else -+ deserializer = getDefaultDeserializer(cl); -+ -+ return deserializer; -+ } -+ -+ /** -+ * Returns a custom serializer the class -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ protected Deserializer getCustomDeserializer(Class cl) -+ { -+ try { -+ Class serClass = Class.forName(cl.getName() + "HessianDeserializer", -+ false, cl.getClassLoader()); -+ -+ Deserializer ser = (Deserializer) serClass.newInstance(); -+ -+ return ser; -+ } catch (ClassNotFoundException e) { -+ log.log(Level.FINEST, e.toString(), e); -+ -+ return null; -+ } catch (Exception e) { -+ log.log(Level.FINE, e.toString(), e); -+ -+ return null; -+ } -+ } -+ -+ /** -+ * Returns the default serializer for a class that isn't matched -+ * directly. Application can override this method to produce -+ * bean-style serialization instead of field serialization. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ protected Deserializer getDefaultDeserializer(Class cl) -+ { -+ if (InputStream.class.equals(cl)) -+ return InputStreamDeserializer.DESER; -+ -+ if (_isEnableUnsafeSerializer) { -+ return new UnsafeDeserializer(cl, _fieldDeserializerFactory); -+ } -+ else -+ return new JavaDeserializer(cl, _fieldDeserializerFactory); -+ } -+ -+ /** -+ * Reads the object as a list. -+ */ -+ public Object readList(AbstractHessianInput in, int length, String type) -+ throws HessianProtocolException, IOException -+ { -+ Deserializer deserializer = getDeserializer(type); -+ -+ if (deserializer != null) -+ return deserializer.readList(in, length); -+ else -+ return new CollectionDeserializer(ArrayList.class).readList(in, length); -+ } -+ -+ /** -+ * Reads the object as a map. -+ */ -+ public Object readMap(AbstractHessianInput in, String type) -+ throws HessianProtocolException, IOException -+ { -+ Deserializer deserializer = getDeserializer(type); -+ -+ if (deserializer != null) -+ return deserializer.readMap(in); -+ else if (_hashMapDeserializer != null) -+ return _hashMapDeserializer.readMap(in); -+ else { -+ _hashMapDeserializer = new MapDeserializer(HashMap.class); -+ -+ return _hashMapDeserializer.readMap(in); -+ } -+ } -+ -+ /** -+ * Reads the object as a map. -+ */ -+ public Object readObject(AbstractHessianInput in, -+ String type, -+ String []fieldNames) -+ throws HessianProtocolException, IOException -+ { -+ Deserializer deserializer = getDeserializer(type); -+ -+ if (deserializer != null) -+ return deserializer.readObject(in, fieldNames); -+ else if (_hashMapDeserializer != null) -+ return _hashMapDeserializer.readObject(in, fieldNames); -+ else { -+ _hashMapDeserializer = new MapDeserializer(HashMap.class); -+ -+ return _hashMapDeserializer.readObject(in, fieldNames); -+ } -+ } -+ -+ /** -+ * Reads the object as a map. -+ */ -+ public Deserializer getObjectDeserializer(String type, Class cl) -+ throws HessianProtocolException -+ { -+ Deserializer reader = getObjectDeserializer(type); -+ -+ if (cl == null -+ || cl.equals(reader.getType()) -+ || cl.isAssignableFrom(reader.getType()) -+ || reader.isReadResolve() -+ || HessianHandle.class.isAssignableFrom(reader.getType())) { -+ return reader; -+ } -+ -+ if (log.isLoggable(Level.FINE)) { -+ log.fine("hessian: expected deserializer '" + cl.getName() + "' at '" + type + "' (" -+ + reader.getType().getName() + ")"); -+ } -+ -+ return getDeserializer(cl); -+ } -+ -+ /** -+ * Reads the object as a map. -+ */ -+ public Deserializer getObjectDeserializer(String type) -+ throws HessianProtocolException -+ { -+ Deserializer deserializer = getDeserializer(type); -+ -+ if (deserializer != null) -+ return deserializer; -+ else if (_hashMapDeserializer != null) -+ return _hashMapDeserializer; -+ else { -+ _hashMapDeserializer = new MapDeserializer(HashMap.class); -+ -+ return _hashMapDeserializer; -+ } -+ } -+ -+ /** -+ * Reads the object as a map. -+ */ -+ public Deserializer getListDeserializer(String type, Class cl) -+ throws HessianProtocolException -+ { -+ Deserializer reader = getListDeserializer(type); -+ -+ if (cl == null -+ || cl.equals(reader.getType()) -+ || cl.isAssignableFrom(reader.getType())) { -+ return reader; -+ } -+ -+ if (log.isLoggable(Level.FINE)) { -+ log.fine("hessian: expected '" + cl.getName() + "' at '" + type + "' (" -+ + reader.getType().getName() + ")"); -+ } -+ -+ return getDeserializer(cl); -+ } -+ -+ /** -+ * Reads the object as a map. -+ */ -+ public Deserializer getListDeserializer(String type) -+ throws HessianProtocolException -+ { -+ Deserializer deserializer = getDeserializer(type); -+ -+ if (deserializer != null) -+ return deserializer; -+ else if (_arrayListDeserializer != null) -+ return _arrayListDeserializer; -+ else { -+ _arrayListDeserializer = new CollectionDeserializer(ArrayList.class); -+ -+ return _arrayListDeserializer; -+ } -+ } -+ -+ /** -+ * Returns a deserializer based on a string type. -+ */ -+ public Deserializer getDeserializer(String type) -+ throws HessianProtocolException -+ { -+ if (type == null || type.equals("")) -+ return null; -+ -+ Deserializer deserializer; -+ -+ if (_cachedTypeDeserializerMap != null) { -+ synchronized (_cachedTypeDeserializerMap) { -+ deserializer = (Deserializer) _cachedTypeDeserializerMap.get(type); -+ } -+ -+ if (deserializer != null) -+ return deserializer; -+ } -+ -+ -+ deserializer = (Deserializer) _staticTypeMap.get(type); -+ if (deserializer != null) -+ return deserializer; -+ -+ if (type.startsWith("[")) { -+ Deserializer subDeserializer = getDeserializer(type.substring(1)); -+ -+ if (subDeserializer != null) -+ deserializer = new ArrayDeserializer(subDeserializer.getType()); -+ else -+ deserializer = new ArrayDeserializer(Object.class); -+ } -+ else { -+ try { -+ //Class cl = Class.forName(type, false, getClassLoader()); -+ -+ Class cl = loadSerializedClass(type); -+ -+ deserializer = getDeserializer(cl); -+ } catch (Exception e) { -+ log.warning("Hessian/Burlap: '" + type + "' is an unknown class in " + getClassLoader() + ":\n" + e); -+ -+ log.log(Level.FINER, e.toString(), e); -+ } -+ } -+ -+ if (deserializer != null) { -+ if (_cachedTypeDeserializerMap == null) -+ _cachedTypeDeserializerMap = new HashMap(8); -+ -+ synchronized (_cachedTypeDeserializerMap) { -+ _cachedTypeDeserializerMap.put(type, deserializer); -+ } -+ } -+ -+ return deserializer; -+ } -+ -+ private static void addBasic(Class cl, String typeName, int type) -+ { -+ Deserializer deserializer = new BasicDeserializer(type); -+ -+ _staticTypeMap.put(typeName, deserializer); -+ } -+ -+ static { -+ _staticTypeMap = new HashMap(); -+ -+ addBasic(void.class, "void", BasicSerializer.NULL); -+ -+ addBasic(Boolean.class, "boolean", BasicSerializer.BOOLEAN); -+ addBasic(Byte.class, "byte", BasicSerializer.BYTE); -+ addBasic(Short.class, "short", BasicSerializer.SHORT); -+ addBasic(Integer.class, "int", BasicSerializer.INTEGER); -+ addBasic(Long.class, "long", BasicSerializer.LONG); -+ addBasic(Float.class, "float", BasicSerializer.FLOAT); -+ addBasic(Double.class, "double", BasicSerializer.DOUBLE); -+ addBasic(Character.class, "char", BasicSerializer.CHARACTER_OBJECT); -+ addBasic(String.class, "string", BasicSerializer.STRING); -+ addBasic(StringBuilder.class, "string", BasicSerializer.STRING_BUILDER); -+ addBasic(Object.class, "object", BasicSerializer.OBJECT); -+ addBasic(java.util.Date.class, "date", BasicSerializer.DATE); -+ -+ addBasic(boolean.class, "boolean", BasicSerializer.BOOLEAN); -+ addBasic(byte.class, "byte", BasicSerializer.BYTE); -+ addBasic(short.class, "short", BasicSerializer.SHORT); -+ addBasic(int.class, "int", BasicSerializer.INTEGER); -+ addBasic(long.class, "long", BasicSerializer.LONG); -+ addBasic(float.class, "float", BasicSerializer.FLOAT); -+ addBasic(double.class, "double", BasicSerializer.DOUBLE); -+ addBasic(char.class, "char", BasicSerializer.CHARACTER); -+ -+ addBasic(boolean[].class, "[boolean", BasicSerializer.BOOLEAN_ARRAY); -+ addBasic(byte[].class, "[byte", BasicSerializer.BYTE_ARRAY); -+ addBasic(short[].class, "[short", BasicSerializer.SHORT_ARRAY); -+ addBasic(int[].class, "[int", BasicSerializer.INTEGER_ARRAY); -+ addBasic(long[].class, "[long", BasicSerializer.LONG_ARRAY); -+ addBasic(float[].class, "[float", BasicSerializer.FLOAT_ARRAY); -+ addBasic(double[].class, "[double", BasicSerializer.DOUBLE_ARRAY); -+ addBasic(char[].class, "[char", BasicSerializer.CHARACTER_ARRAY); -+ addBasic(String[].class, "[string", BasicSerializer.STRING_ARRAY); -+ addBasic(Object[].class, "[object", BasicSerializer.OBJECT_ARRAY); -+ -+ Deserializer objectDeserializer = new JavaDeserializer(Object.class, new FieldDeserializer2Factory()); -+ _staticTypeMap.put("object", objectDeserializer); -+ _staticTypeMap.put(HessianRemote.class.getName(), -+ RemoteDeserializer.DESER); -+ -+ -+ ClassLoader systemClassLoader = null; -+ try { -+ systemClassLoader = ClassLoader.getSystemClassLoader(); -+ } catch (Exception e) { -+ } -+ -+ _systemClassLoader = systemClassLoader; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ShortHandle.java hessian-4.0.65-fix/com/caucho/hessian/io/ShortHandle.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ShortHandle.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ShortHandle.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,83 +1,83 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.net.URL; --import java.io.Serializable; -- --/** -- * Handle for Java Short objects. -- */ --public class ShortHandle implements Serializable { -- private short _value; -- -- private ShortHandle() -- { -- } -- -- public ShortHandle(short value) -- { -- _value = value; -- } -- -- public short getValue() -- { -- return _value; -- } -- -- public Object readResolve() -- { -- return new Short(_value); -- } -- -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _value + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.net.URL; -+import java.io.Serializable; -+ -+/** -+ * Handle for Java Short objects. -+ */ -+public class ShortHandle implements Serializable { -+ private short _value; -+ -+ private ShortHandle() -+ { -+ } -+ -+ public ShortHandle(short value) -+ { -+ _value = value; -+ } -+ -+ public short getValue() -+ { -+ return _value; -+ } -+ -+ public Object readResolve() -+ { -+ return new Short(_value); -+ } -+ -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _value + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/SqlDateDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/SqlDateDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,141 +1,141 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Constructor; -- --import com.caucho.hessian.HessianException; -- --/** -- * Deserializing a string valued object -- */ --public class SqlDateDeserializer extends AbstractDeserializer { -- private Class _cl; -- private Constructor _constructor; -- -- public SqlDateDeserializer(Class cl) -- { -- try { -- _cl = cl; -- _constructor = cl.getConstructor(new Class[] { long.class }); -- } catch (NoSuchMethodException e) { -- throw new HessianException(e); -- } -- } -- -- public Class getType() -- { -- return _cl; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- int ref = in.addRef(null); -- -- long initValue = Long.MIN_VALUE; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if (key.equals("value")) -- initValue = in.readUTCDate(); -- else -- in.readString(); -- } -- -- in.readMapEnd(); -- -- Object value = create(initValue); -- -- in.setRef(ref, value); -- -- return value; -- } -- -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException -- { -- String []fieldNames = (String []) fields; -- -- int ref = in.addRef(null); -- -- long initValue = Long.MIN_VALUE; -- -- for (int i = 0; i < fieldNames.length; i++) { -- String key = fieldNames[i]; -- -- if (key.equals("value")) -- initValue = in.readUTCDate(); -- else -- in.readObject(); -- } -- -- Object value = create(initValue); -- -- in.setRef(ref, value); -- -- return value; -- } -- -- private Object create(long initValue) -- throws IOException -- { -- if (initValue == Long.MIN_VALUE) -- throw new IOException(_cl.getName() + " expects name."); -- -- try { -- return _constructor.newInstance(new Object[] { new Long(initValue) }); -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Constructor; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Deserializing a string valued object -+ */ -+public class SqlDateDeserializer extends AbstractDeserializer { -+ private Class _cl; -+ private Constructor _constructor; -+ -+ public SqlDateDeserializer(Class cl) -+ { -+ try { -+ _cl = cl; -+ _constructor = cl.getConstructor(new Class[] { long.class }); -+ } catch (NoSuchMethodException e) { -+ throw new HessianException(e); -+ } -+ } -+ -+ public Class getType() -+ { -+ return _cl; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ int ref = in.addRef(null); -+ -+ long initValue = Long.MIN_VALUE; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if (key.equals("value")) -+ initValue = in.readUTCDate(); -+ else -+ in.readString(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object value = create(initValue); -+ -+ in.setRef(ref, value); -+ -+ return value; -+ } -+ -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ String []fieldNames = (String []) fields; -+ -+ int ref = in.addRef(null); -+ -+ long initValue = Long.MIN_VALUE; -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ String key = fieldNames[i]; -+ -+ if (key.equals("value")) -+ initValue = in.readUTCDate(); -+ else -+ in.readObject(); -+ } -+ -+ Object value = create(initValue); -+ -+ in.setRef(ref, value); -+ -+ return value; -+ } -+ -+ private Object create(long initValue) -+ throws IOException -+ { -+ if (initValue == Long.MIN_VALUE) -+ throw new IOException(_cl.getName() + " expects name."); -+ -+ try { -+ return _constructor.newInstance(new Object[] { new Long(initValue) }); -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/SqlDateSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/SqlDateSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/SqlDateSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,88 +1,88 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.util.Date; -- --/** -- * Serializing a sql date object. -- */ --public class SqlDateSerializer extends AbstractSerializer --{ -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (obj == null) -- out.writeNull(); -- else { -- Class cl = obj.getClass(); -- -- if (out.addRef(obj)) -- return; -- -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref < -1) { -- out.writeString("value"); -- out.writeUTCDate(((Date) obj).getTime()); -- out.writeMapEnd(); -- } -- else { -- if (ref == -1) { -- out.writeInt(1); -- out.writeString("value"); -- out.writeObjectBegin(cl.getName()); -- } -- -- out.writeUTCDate(((Date) obj).getTime()); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.util.Date; -+ -+/** -+ * Serializing a sql date object. -+ */ -+public class SqlDateSerializer extends AbstractSerializer -+{ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (obj == null) -+ out.writeNull(); -+ else { -+ Class cl = obj.getClass(); -+ -+ if (out.addRef(obj)) -+ return; -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref < -1) { -+ out.writeString("value"); -+ out.writeUTCDate(((Date) obj).getTime()); -+ out.writeMapEnd(); -+ } -+ else { -+ if (ref == -1) { -+ out.writeInt(1); -+ out.writeString("value"); -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ out.writeUTCDate(((Date) obj).getTime()); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/StackTraceElementDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/StackTraceElementDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/StackTraceElementDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/StackTraceElementDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,74 +1,74 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.lang.reflect.Constructor; -- --/** -- * Deserializing a JDK 1.4 StackTraceElement -- */ --public class StackTraceElementDeserializer extends JavaDeserializer { -- public StackTraceElementDeserializer(FieldDeserializer2Factory fieldFactory) -- { -- super(StackTraceElement.class, fieldFactory); -- } -- -- @Override -- protected Constructor getConstructor(Class cl) -- { -- return null; -- } -- -- @Override -- protected Object instantiate() -- throws Exception -- { -- return new StackTraceElement("", "", "", 0); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.lang.reflect.Constructor; -+ -+/** -+ * Deserializing a JDK 1.4 StackTraceElement -+ */ -+public class StackTraceElementDeserializer extends JavaDeserializer { -+ public StackTraceElementDeserializer(FieldDeserializer2Factory fieldFactory) -+ { -+ super(StackTraceElement.class, fieldFactory); -+ } -+ -+ @Override -+ protected Constructor getConstructor(Class cl) -+ { -+ return null; -+ } -+ -+ @Override -+ protected Object instantiate() -+ throws Exception -+ { -+ return new StackTraceElement("", "", "", 0); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/StringValueDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/StringValueDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/StringValueDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/StringValueDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,93 +1,93 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Constructor; -- --import com.caucho.hessian.HessianException; -- --/** -- * Deserializing a string valued object -- */ --public class StringValueDeserializer extends AbstractStringValueDeserializer { -- private Class _cl; -- private Constructor _constructor; -- -- public StringValueDeserializer(Class cl) -- { -- try { -- _cl = cl; -- _constructor = cl.getConstructor(new Class[] { String.class }); -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- @Override -- public Class getType() -- { -- return _cl; -- } -- -- @Override -- protected Object create(String value) -- throws IOException -- { -- if (value == null) -- throw new IOException(_cl.getName() + " expects name."); -- -- try { -- return _constructor.newInstance(new Object[] { value }); -- } catch (Exception e) { -- throw new HessianException(_cl.getName() + ": value=" + value + "\n" + e, -- e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Constructor; -+ -+import com.caucho.hessian.HessianException; -+ -+/** -+ * Deserializing a string valued object -+ */ -+public class StringValueDeserializer extends AbstractStringValueDeserializer { -+ private Class _cl; -+ private Constructor _constructor; -+ -+ public StringValueDeserializer(Class cl) -+ { -+ try { -+ _cl = cl; -+ _constructor = cl.getConstructor(new Class[] { String.class }); -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ @Override -+ public Class getType() -+ { -+ return _cl; -+ } -+ -+ @Override -+ protected Object create(String value) -+ throws IOException -+ { -+ if (value == null) -+ throw new IOException(_cl.getName() + " expects name."); -+ -+ try { -+ return _constructor.newInstance(new Object[] { value }); -+ } catch (Exception e) { -+ throw new HessianException(_cl.getName() + ": value=" + value + "\n" + e, -+ e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/StringValueSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/StringValueSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/StringValueSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/StringValueSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,88 +1,88 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing a remote object. -- */ --public class StringValueSerializer extends AbstractSerializer { -- public static final Serializer SER = new StringValueSerializer(); -- -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (obj == null) -- out.writeNull(); -- else { -- if (out.addRef(obj)) -- return; -- -- Class cl = obj.getClass(); -- -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref < -1) { -- out.writeString("value"); -- out.writeString(obj.toString()); -- out.writeMapEnd(); -- } -- else { -- if (ref == -1) { -- out.writeInt(1); -- out.writeString("value"); -- out.writeObjectBegin(cl.getName()); -- } -- -- out.writeString(obj.toString()); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing a remote object. -+ */ -+public class StringValueSerializer extends AbstractSerializer { -+ public static final Serializer SER = new StringValueSerializer(); -+ -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (obj == null) -+ out.writeNull(); -+ else { -+ if (out.addRef(obj)) -+ return; -+ -+ Class cl = obj.getClass(); -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref < -1) { -+ out.writeString("value"); -+ out.writeString(obj.toString()); -+ out.writeMapEnd(); -+ } -+ else { -+ if (ref == -1) { -+ out.writeInt(1); -+ out.writeString("value"); -+ out.writeObjectBegin(cl.getName()); -+ } -+ -+ out.writeString(obj.toString()); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ThrowableSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ThrowableSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ThrowableSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ThrowableSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,80 +1,80 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Serializing an object for known object types. -- */ --public class ThrowableSerializer extends AbstractSerializerWrapper { -- private final Serializer _ser; -- -- public ThrowableSerializer(Serializer ser) -- { -- _ser = ser; -- } -- -- @Override -- protected Serializer getDelegate() -- { -- return _ser; -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- Throwable e = (Throwable) obj; -- -- e.getStackTrace(); -- -- _ser.writeObject(obj, out); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class ThrowableSerializer extends AbstractSerializerWrapper { -+ private final Serializer _ser; -+ -+ public ThrowableSerializer(Serializer ser) -+ { -+ _ser = ser; -+ } -+ -+ @Override -+ protected Serializer getDelegate() -+ { -+ return _ser; -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ Throwable e = (Throwable) obj; -+ -+ e.getStackTrace(); -+ -+ _ser.writeObject(obj, out); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/UnsafeDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/UnsafeDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,392 +1,392 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.Field; --import java.lang.reflect.InvocationTargetException; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.HashMap; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import com.caucho.hessian.io.FieldDeserializer2FactoryUnsafe.NullFieldDeserializer; -- --import sun.misc.Unsafe; -- --/** -- * Serializing an object for known object types. -- */ --public class UnsafeDeserializer extends AbstractMapDeserializer { -- private static final Logger log -- = Logger.getLogger(JavaDeserializer.class.getName()); -- -- private static boolean _isEnabled; -- @SuppressWarnings("restriction") -- private static Unsafe _unsafe; -- -- private Class _type; -- private HashMap _fieldMap; -- private Method _readResolve; -- -- public UnsafeDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) -- { -- _type = cl; -- _fieldMap = getFieldMap(cl, fieldFactory); -- -- _readResolve = getReadResolve(cl); -- -- if (_readResolve != null) { -- _readResolve.setAccessible(true); -- } -- } -- -- public static boolean isEnabled() -- { -- return _isEnabled; -- } -- -- @Override -- public Class getType() -- { -- return _type; -- } -- -- @Override -- public boolean isReadResolve() -- { -- return _readResolve != null; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- try { -- Object obj = instantiate(); -- -- return readMap(in, obj); -- } catch (IOException e) { -- throw e; -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -- } -- } -- -- @Override -- public Object []createFields(int len) -- { -- return new FieldDeserializer2[len]; -- } -- -- public Object createField(String name) -- { -- Object reader = _fieldMap.get(name); -- -- if (reader == null) -- reader = NullFieldDeserializer.DESER; -- -- return reader; -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, -- Object []fields) -- throws IOException -- { -- try { -- Object obj = instantiate(); -- -- return readObject(in, obj, (FieldDeserializer2 []) fields); -- } catch (IOException e) { -- throw e; -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -- } -- } -- -- @Override -- public Object readObject(AbstractHessianInput in, -- String []fieldNames) -- throws IOException -- { -- try { -- Object obj = instantiate(); -- -- return readObject(in, obj, fieldNames); -- } catch (IOException e) { -- throw e; -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -- } -- } -- -- /** -- * Returns the readResolve method -- */ -- protected Method getReadResolve(Class cl) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (method.getName().equals("readResolve") -- && method.getParameterTypes().length == 0) -- return method; -- } -- } -- -- return null; -- } -- -- public Object readMap(AbstractHessianInput in, Object obj) -- throws IOException -- { -- try { -- int ref = in.addRef(obj); -- -- while (! in.isEnd()) { -- Object key = in.readObject(); -- -- FieldDeserializer2 deser = (FieldDeserializer2) _fieldMap.get(key); -- -- if (deser != null) -- deser.deserialize(in, obj); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- Object resolve = resolve(in, obj); -- -- if (obj != resolve) -- in.setRef(ref, resolve); -- -- return resolve; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(e); -- } -- } -- -- public Object readObject(AbstractHessianInput in, -- Object obj, -- FieldDeserializer2 []fields) -- throws IOException -- { -- try { -- int ref = in.addRef(obj); -- -- for (FieldDeserializer2 reader : fields) { -- reader.deserialize(in, obj); -- } -- -- Object resolve = resolve(in, obj); -- -- if (obj != resolve) -- in.setRef(ref, resolve); -- -- return resolve; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -- } -- } -- -- public Object readObject(AbstractHessianInput in, -- Object obj, -- String []fieldNames) -- throws IOException -- { -- try { -- int ref = in.addRef(obj); -- -- for (String fieldName : fieldNames) { -- FieldDeserializer2 reader = _fieldMap.get(fieldName); -- -- if (reader != null) -- reader.deserialize(in, obj); -- else -- in.readObject(); -- } -- -- Object resolve = resolve(in, obj); -- -- if (obj != resolve) -- in.setRef(ref, resolve); -- -- return resolve; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -- } -- } -- -- protected Object resolve(AbstractHessianInput in, Object obj) -- throws Exception -- { -- // if there's a readResolve method, call it -- try { -- if (_readResolve != null) -- return _readResolve.invoke(obj, new Object[0]); -- } catch (InvocationTargetException e) { -- if (e.getCause() instanceof Exception) -- throw (Exception) e.getCause(); -- else -- throw e; -- } -- -- return obj; -- } -- -- @SuppressWarnings("restriction") -- protected Object instantiate() -- throws Exception -- { -- return _unsafe.allocateInstance(_type); -- } -- -- /** -- * Creates a map of the classes fields. -- */ -- protected HashMap -- getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) -- { -- HashMap fieldMap -- = new HashMap(); -- -- for (; cl != null; cl = cl.getSuperclass()) { -- Field []fields = cl.getDeclaredFields(); -- for (int i = 0; i < fields.length; i++) { -- Field field = fields[i]; -- -- if (Modifier.isTransient(field.getModifiers()) -- || Modifier.isStatic(field.getModifiers())) -- continue; -- else if (fieldMap.get(field.getName()) != null) -- continue; -- -- /* -- // XXX: could parameterize the handler to only deal with public -- try { -- field.setAccessible(true); -- } catch (Throwable e) { -- e.printStackTrace(); -- } -- */ -- -- FieldDeserializer2 deser = fieldFactory.create(field); -- -- fieldMap.put(field.getName(), deser); -- } -- } -- -- return fieldMap; -- } -- -- static void logDeserializeError(Field field, Object obj, Object value, -- Throwable e) -- throws IOException -- { -- String fieldName = (field.getDeclaringClass().getName() -- + "." + field.getName()); -- -- if (e instanceof HessianFieldException) -- throw (HessianFieldException) e; -- else if (e instanceof IOException) -- throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -- -- if (value != null) -- throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -- + " cannot be assigned to '" + field.getType().getName() + "'", e); -- else -- throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -- } -- -- static { -- boolean isEnabled = false; -- -- try { -- Class unsafe = Class.forName("sun.misc.Unsafe"); -- Field theUnsafe = null; -- for (Field field : unsafe.getDeclaredFields()) { -- if (field.getName().equals("theUnsafe")) -- theUnsafe = field; -- } -- -- if (theUnsafe != null) { -- theUnsafe.setAccessible(true); -- _unsafe = (Unsafe) theUnsafe.get(null); -- } -- -- isEnabled = _unsafe != null; -- -- String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -- -- if ("false".equals(unsafeProp)) -- isEnabled = false; -- } catch (Throwable e) { -- log.log(Level.FINER, e.toString(), e); -- } -- -- _isEnabled = isEnabled; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.Field; -+import java.lang.reflect.InvocationTargetException; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.HashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import com.caucho.hessian.io.FieldDeserializer2FactoryUnsafe.NullFieldDeserializer; -+ -+import sun.misc.Unsafe; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class UnsafeDeserializer extends AbstractMapDeserializer { -+ private static final Logger log -+ = Logger.getLogger(JavaDeserializer.class.getName()); -+ -+ private static boolean _isEnabled; -+ @SuppressWarnings("restriction") -+ private static Unsafe _unsafe; -+ -+ private Class _type; -+ private HashMap _fieldMap; -+ private Method _readResolve; -+ -+ public UnsafeDeserializer(Class cl, FieldDeserializer2Factory fieldFactory) -+ { -+ _type = cl; -+ _fieldMap = getFieldMap(cl, fieldFactory); -+ -+ _readResolve = getReadResolve(cl); -+ -+ if (_readResolve != null) { -+ _readResolve.setAccessible(true); -+ } -+ } -+ -+ public static boolean isEnabled() -+ { -+ return _isEnabled; -+ } -+ -+ @Override -+ public Class getType() -+ { -+ return _type; -+ } -+ -+ @Override -+ public boolean isReadResolve() -+ { -+ return _readResolve != null; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readMap(in, obj); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ @Override -+ public Object []createFields(int len) -+ { -+ return new FieldDeserializer2[len]; -+ } -+ -+ public Object createField(String name) -+ { -+ Object reader = _fieldMap.get(name); -+ -+ if (reader == null) -+ reader = NullFieldDeserializer.DESER; -+ -+ return reader; -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ Object []fields) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readObject(in, obj, (FieldDeserializer2 []) fields); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ @Override -+ public Object readObject(AbstractHessianInput in, -+ String []fieldNames) -+ throws IOException -+ { -+ try { -+ Object obj = instantiate(); -+ -+ return readObject(in, obj, fieldNames); -+ } catch (IOException e) { -+ throw e; -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); -+ } -+ } -+ -+ /** -+ * Returns the readResolve method -+ */ -+ protected Method getReadResolve(Class cl) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (method.getName().equals("readResolve") -+ && method.getParameterTypes().length == 0) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ public Object readMap(AbstractHessianInput in, Object obj) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ while (! in.isEnd()) { -+ Object key = in.readObject(); -+ -+ FieldDeserializer2 deser = (FieldDeserializer2) _fieldMap.get(key); -+ -+ if (deser != null) -+ deser.deserialize(in, obj); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(e); -+ } -+ } -+ -+ public Object readObject(AbstractHessianInput in, -+ Object obj, -+ FieldDeserializer2 []fields) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ for (FieldDeserializer2 reader : fields) { -+ reader.deserialize(in, obj); -+ } -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -+ } -+ } -+ -+ public Object readObject(AbstractHessianInput in, -+ Object obj, -+ String []fieldNames) -+ throws IOException -+ { -+ try { -+ int ref = in.addRef(obj); -+ -+ for (String fieldName : fieldNames) { -+ FieldDeserializer2 reader = _fieldMap.get(fieldName); -+ -+ if (reader != null) -+ reader.deserialize(in, obj); -+ else -+ in.readObject(); -+ } -+ -+ Object resolve = resolve(in, obj); -+ -+ if (obj != resolve) -+ in.setRef(ref, resolve); -+ -+ return resolve; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); -+ } -+ } -+ -+ protected Object resolve(AbstractHessianInput in, Object obj) -+ throws Exception -+ { -+ // if there's a readResolve method, call it -+ try { -+ if (_readResolve != null) -+ return _readResolve.invoke(obj, new Object[0]); -+ } catch (InvocationTargetException e) { -+ if (e.getCause() instanceof Exception) -+ throw (Exception) e.getCause(); -+ else -+ throw e; -+ } -+ -+ return obj; -+ } -+ -+ @SuppressWarnings("restriction") -+ protected Object instantiate() -+ throws Exception -+ { -+ return _unsafe.allocateInstance(_type); -+ } -+ -+ /** -+ * Creates a map of the classes fields. -+ */ -+ protected HashMap -+ getFieldMap(Class cl, FieldDeserializer2Factory fieldFactory) -+ { -+ HashMap fieldMap -+ = new HashMap(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isTransient(field.getModifiers()) -+ || Modifier.isStatic(field.getModifiers())) -+ continue; -+ else if (fieldMap.get(field.getName()) != null) -+ continue; -+ -+ /* -+ // XXX: could parameterize the handler to only deal with public -+ try { -+ field.setAccessible(true); -+ } catch (Throwable e) { -+ e.printStackTrace(); -+ } -+ */ -+ -+ FieldDeserializer2 deser = fieldFactory.create(field); -+ -+ fieldMap.put(field.getName(), deser); -+ } -+ } -+ -+ return fieldMap; -+ } -+ -+ static void logDeserializeError(Field field, Object obj, Object value, -+ Throwable e) -+ throws IOException -+ { -+ String fieldName = (field.getDeclaringClass().getName() -+ + "." + field.getName()); -+ -+ if (e instanceof HessianFieldException) -+ throw (HessianFieldException) e; -+ else if (e instanceof IOException) -+ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); -+ -+ if (value != null) -+ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" -+ + " cannot be assigned to '" + field.getType().getName() + "'", e); -+ else -+ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); -+ } -+ -+ static { -+ boolean isEnabled = false; -+ -+ try { -+ Class unsafe = Class.forName("sun.misc.Unsafe"); -+ Field theUnsafe = null; -+ for (Field field : unsafe.getDeclaredFields()) { -+ if (field.getName().equals("theUnsafe")) -+ theUnsafe = field; -+ } -+ -+ if (theUnsafe != null) { -+ theUnsafe.setAccessible(true); -+ _unsafe = (Unsafe) theUnsafe.get(null); -+ } -+ -+ isEnabled = _unsafe != null; -+ -+ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -+ -+ if ("false".equals(unsafeProp)) -+ isEnabled = false; -+ } catch (Throwable e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ _isEnabled = isEnabled; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/UnsafeSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/UnsafeSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,570 +1,570 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.ref.SoftReference; --import java.lang.reflect.Field; --import java.lang.reflect.Modifier; --import java.util.ArrayList; --import java.util.WeakHashMap; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import sun.misc.Unsafe; -- --import com.caucho.hessian.HessianUnshared; -- --/** -- * Serializing an object for known object types. -- */ --public class UnsafeSerializer extends AbstractSerializer --{ -- private static final Logger log -- = Logger.getLogger(UnsafeSerializer.class.getName()); -- -- private static boolean _isEnabled; -- private static final Unsafe _unsafe; -- -- private static final WeakHashMap,SoftReference> _serializerMap -- = new WeakHashMap,SoftReference>(); -- -- private Field []_fields; -- private FieldSerializer []_fieldSerializers; -- -- public static boolean isEnabled() -- { -- return _isEnabled; -- } -- -- public UnsafeSerializer(Class cl) -- { -- introspect(cl); -- } -- -- public static UnsafeSerializer create(Class cl) -- { -- synchronized (_serializerMap) { -- SoftReference baseRef -- = _serializerMap.get(cl); -- -- UnsafeSerializer base = baseRef != null ? baseRef.get() : null; -- -- if (base == null) { -- if (cl.isAnnotationPresent(HessianUnshared.class)) -- base = new UnsafeUnsharedSerializer(cl); -- else -- base = new UnsafeSerializer(cl); -- -- baseRef = new SoftReference(base); -- _serializerMap.put(cl, baseRef); -- } -- -- return base; -- } -- } -- -- protected void introspect(Class cl) -- { -- ArrayList primitiveFields = new ArrayList(); -- ArrayList compoundFields = new ArrayList(); -- -- for (; cl != null; cl = cl.getSuperclass()) { -- Field []fields = cl.getDeclaredFields(); -- -- for (int i = 0; i < fields.length; i++) { -- Field field = fields[i]; -- -- if (Modifier.isTransient(field.getModifiers()) -- || Modifier.isStatic(field.getModifiers())) { -- continue; -- } -- -- /* -- // XXX: could parameterize the handler to only deal with public -- field.setAccessible(true); -- */ -- -- if (field.getType().isPrimitive() -- || (field.getType().getName().startsWith("java.lang.") -- && ! field.getType().equals(Object.class))) { -- primitiveFields.add(field); -- } -- else { -- compoundFields.add(field); -- } -- } -- } -- -- ArrayList fields = new ArrayList(); -- fields.addAll(primitiveFields); -- fields.addAll(compoundFields); -- -- _fields = new Field[fields.size()]; -- fields.toArray(_fields); -- -- _fieldSerializers = new FieldSerializer[_fields.length]; -- -- for (int i = 0; i < _fields.length; i++) { -- _fieldSerializers[i] = getFieldSerializer(_fields[i]); -- } -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- if (out.addRef(obj)) { -- return; -- } -- -- Class cl = obj.getClass(); -- -- int ref = out.writeObjectBegin(cl.getName()); -- -- if (ref >= 0) { -- writeInstance(obj, out); -- } -- else if (ref == -1) { -- writeDefinition20(out); -- out.writeObjectBegin(cl.getName()); -- writeInstance(obj, out); -- } -- else { -- writeObject10(obj, out); -- } -- } -- -- protected void writeObject10(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- for (int i = 0; i < _fields.length; i++) { -- Field field = _fields[i]; -- -- out.writeString(field.getName()); -- -- _fieldSerializers[i].serialize(out, obj); -- } -- -- out.writeMapEnd(); -- } -- -- private void writeDefinition20(AbstractHessianOutput out) -- throws IOException -- { -- out.writeClassFieldLength(_fields.length); -- -- for (int i = 0; i < _fields.length; i++) { -- Field field = _fields[i]; -- -- out.writeString(field.getName()); -- } -- } -- -- final public void writeInstance(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- try { -- FieldSerializer []fieldSerializers = _fieldSerializers; -- int length = fieldSerializers.length; -- -- for (int i = 0; i < length; i++) { -- fieldSerializers[i].serialize(out, obj); -- } -- } catch (RuntimeException e) { -- throw new RuntimeException(e.getMessage() + "\n class: " -- + obj.getClass().getName() -- + " (object=" + obj + ")", -- e); -- } catch (IOException e) { -- throw new IOExceptionWrapper(e.getMessage() + "\n class: " -- + obj.getClass().getName() -- + " (object=" + obj + ")", -- e); -- } -- } -- -- private static FieldSerializer getFieldSerializer(Field field) -- { -- Class type = field.getType(); -- -- if (boolean.class.equals(type)) { -- return new BooleanFieldSerializer(field); -- } -- else if (byte.class.equals(type)) { -- return new ByteFieldSerializer(field); -- } -- else if (char.class.equals(type)) { -- return new CharFieldSerializer(field); -- } -- else if (short.class.equals(type)) { -- return new ShortFieldSerializer(field); -- } -- else if (int.class.equals(type)) { -- return new IntFieldSerializer(field); -- } -- else if (long.class.equals(type)) { -- return new LongFieldSerializer(field); -- } -- else if (double.class.equals(type)) { -- return new DoubleFieldSerializer(field); -- } -- else if (float.class.equals(type)) { -- return new FloatFieldSerializer(field); -- } -- else if (String.class.equals(type)) { -- return new StringFieldSerializer(field); -- } -- else if (java.util.Date.class.equals(type) -- || java.sql.Date.class.equals(type) -- || java.sql.Timestamp.class.equals(type) -- || java.sql.Time.class.equals(type)) { -- return new DateFieldSerializer(field); -- } -- else -- return new ObjectFieldSerializer(field); -- } -- -- abstract static class FieldSerializer { -- abstract void serialize(AbstractHessianOutput out, Object obj) -- throws IOException; -- } -- -- final static class ObjectFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- ObjectFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- @Override -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- try { -- Object value = _unsafe.getObject(obj, _offset); -- -- out.writeObject(value); -- } catch (RuntimeException e) { -- throw new RuntimeException(e.getMessage() + "\n field: " -- + _field.getDeclaringClass().getName() -- + '.' + _field.getName(), -- e); -- } catch (IOException e) { -- throw new IOExceptionWrapper(e.getMessage() + "\n field: " -- + _field.getDeclaringClass().getName() -- + '.' + _field.getName(), -- e); -- } -- } -- } -- -- final static class BooleanFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- BooleanFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- boolean value = _unsafe.getBoolean(obj, _offset); -- -- out.writeBoolean(value); -- } -- } -- -- final static class ByteFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- ByteFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- int value = _unsafe.getByte(obj, _offset); -- -- out.writeInt(value); -- } -- } -- -- final static class CharFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- CharFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- char value = _unsafe.getChar(obj, _offset); -- -- out.writeString(String.valueOf(value)); -- } -- } -- -- final static class ShortFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- ShortFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- int value = _unsafe.getShort(obj, _offset); -- -- out.writeInt(value); -- } -- } -- -- final static class IntFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- IntFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- int value = _unsafe.getInt(obj, _offset); -- -- out.writeInt(value); -- } -- } -- -- final static class LongFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- LongFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- long value = _unsafe.getLong(obj, _offset); -- -- out.writeLong(value); -- } -- } -- -- final static class FloatFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- FloatFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- double value = _unsafe.getFloat(obj, _offset); -- -- out.writeDouble(value); -- } -- } -- -- final static class DoubleFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- DoubleFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- double value = _unsafe.getDouble(obj, _offset); -- -- out.writeDouble(value); -- } -- } -- -- final static class StringFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- StringFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- @Override -- final void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- String value = (String) _unsafe.getObject(obj, _offset); -- -- out.writeString(value); -- } -- } -- -- final static class DateFieldSerializer extends FieldSerializer { -- private final Field _field; -- private final long _offset; -- -- DateFieldSerializer(Field field) -- { -- _field = field; -- _offset = _unsafe.objectFieldOffset(field); -- -- if (_offset == Unsafe.INVALID_FIELD_OFFSET) -- throw new IllegalStateException(); -- } -- -- @Override -- void serialize(AbstractHessianOutput out, Object obj) -- throws IOException -- { -- java.util.Date value -- = (java.util.Date) _unsafe.getObject(obj, _offset); -- -- if (value == null) -- out.writeNull(); -- else -- out.writeUTCDate(value.getTime()); -- } -- } -- -- static { -- boolean isEnabled = false; -- Unsafe unsafe = null; -- -- try { -- Class unsafeClass = Class.forName("sun.misc.Unsafe"); -- Field theUnsafe = null; -- for (Field field : unsafeClass.getDeclaredFields()) { -- if (field.getName().equals("theUnsafe")) -- theUnsafe = field; -- } -- -- if (theUnsafe != null) { -- theUnsafe.setAccessible(true); -- unsafe = (Unsafe) theUnsafe.get(null); -- } -- -- isEnabled = unsafe != null; -- -- String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -- -- if ("false".equals(unsafeProp)) -- isEnabled = false; -- } catch (Throwable e) { -- log.log(Level.ALL, e.toString(), e); -- } -- -- _unsafe = unsafe; -- _isEnabled = isEnabled; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.ref.SoftReference; -+import java.lang.reflect.Field; -+import java.lang.reflect.Modifier; -+import java.util.ArrayList; -+import java.util.WeakHashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import sun.misc.Unsafe; -+ -+import com.caucho.hessian.HessianUnshared; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class UnsafeSerializer extends AbstractSerializer -+{ -+ private static final Logger log -+ = Logger.getLogger(UnsafeSerializer.class.getName()); -+ -+ private static boolean _isEnabled; -+ private static final Unsafe _unsafe; -+ -+ private static final WeakHashMap,SoftReference> _serializerMap -+ = new WeakHashMap,SoftReference>(); -+ -+ private Field []_fields; -+ private FieldSerializer []_fieldSerializers; -+ -+ public static boolean isEnabled() -+ { -+ return _isEnabled; -+ } -+ -+ public UnsafeSerializer(Class cl) -+ { -+ introspect(cl); -+ } -+ -+ public static UnsafeSerializer create(Class cl) -+ { -+ synchronized (_serializerMap) { -+ SoftReference baseRef -+ = _serializerMap.get(cl); -+ -+ UnsafeSerializer base = baseRef != null ? baseRef.get() : null; -+ -+ if (base == null) { -+ if (cl.isAnnotationPresent(HessianUnshared.class)) -+ base = new UnsafeUnsharedSerializer(cl); -+ else -+ base = new UnsafeSerializer(cl); -+ -+ baseRef = new SoftReference(base); -+ _serializerMap.put(cl, baseRef); -+ } -+ -+ return base; -+ } -+ } -+ -+ protected void introspect(Class cl) -+ { -+ ArrayList primitiveFields = new ArrayList(); -+ ArrayList compoundFields = new ArrayList(); -+ -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Field []fields = cl.getDeclaredFields(); -+ -+ for (int i = 0; i < fields.length; i++) { -+ Field field = fields[i]; -+ -+ if (Modifier.isTransient(field.getModifiers()) -+ || Modifier.isStatic(field.getModifiers())) { -+ continue; -+ } -+ -+ /* -+ // XXX: could parameterize the handler to only deal with public -+ field.setAccessible(true); -+ */ -+ -+ if (field.getType().isPrimitive() -+ || (field.getType().getName().startsWith("java.lang.") -+ && ! field.getType().equals(Object.class))) { -+ primitiveFields.add(field); -+ } -+ else { -+ compoundFields.add(field); -+ } -+ } -+ } -+ -+ ArrayList fields = new ArrayList(); -+ fields.addAll(primitiveFields); -+ fields.addAll(compoundFields); -+ -+ _fields = new Field[fields.size()]; -+ fields.toArray(_fields); -+ -+ _fieldSerializers = new FieldSerializer[_fields.length]; -+ -+ for (int i = 0; i < _fields.length; i++) { -+ _fieldSerializers[i] = getFieldSerializer(_fields[i]); -+ } -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ if (out.addRef(obj)) { -+ return; -+ } -+ -+ Class cl = obj.getClass(); -+ -+ int ref = out.writeObjectBegin(cl.getName()); -+ -+ if (ref >= 0) { -+ writeInstance(obj, out); -+ } -+ else if (ref == -1) { -+ writeDefinition20(out); -+ out.writeObjectBegin(cl.getName()); -+ writeInstance(obj, out); -+ } -+ else { -+ writeObject10(obj, out); -+ } -+ } -+ -+ protected void writeObject10(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ for (int i = 0; i < _fields.length; i++) { -+ Field field = _fields[i]; -+ -+ out.writeString(field.getName()); -+ -+ _fieldSerializers[i].serialize(out, obj); -+ } -+ -+ out.writeMapEnd(); -+ } -+ -+ private void writeDefinition20(AbstractHessianOutput out) -+ throws IOException -+ { -+ out.writeClassFieldLength(_fields.length); -+ -+ for (int i = 0; i < _fields.length; i++) { -+ Field field = _fields[i]; -+ -+ out.writeString(field.getName()); -+ } -+ } -+ -+ final public void writeInstance(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ try { -+ FieldSerializer []fieldSerializers = _fieldSerializers; -+ int length = fieldSerializers.length; -+ -+ for (int i = 0; i < length; i++) { -+ fieldSerializers[i].serialize(out, obj); -+ } -+ } catch (RuntimeException e) { -+ throw new RuntimeException(e.getMessage() + "\n class: " -+ + obj.getClass().getName() -+ + " (object=" + obj + ")", -+ e); -+ } catch (IOException e) { -+ throw new IOExceptionWrapper(e.getMessage() + "\n class: " -+ + obj.getClass().getName() -+ + " (object=" + obj + ")", -+ e); -+ } -+ } -+ -+ private static FieldSerializer getFieldSerializer(Field field) -+ { -+ Class type = field.getType(); -+ -+ if (boolean.class.equals(type)) { -+ return new BooleanFieldSerializer(field); -+ } -+ else if (byte.class.equals(type)) { -+ return new ByteFieldSerializer(field); -+ } -+ else if (char.class.equals(type)) { -+ return new CharFieldSerializer(field); -+ } -+ else if (short.class.equals(type)) { -+ return new ShortFieldSerializer(field); -+ } -+ else if (int.class.equals(type)) { -+ return new IntFieldSerializer(field); -+ } -+ else if (long.class.equals(type)) { -+ return new LongFieldSerializer(field); -+ } -+ else if (double.class.equals(type)) { -+ return new DoubleFieldSerializer(field); -+ } -+ else if (float.class.equals(type)) { -+ return new FloatFieldSerializer(field); -+ } -+ else if (String.class.equals(type)) { -+ return new StringFieldSerializer(field); -+ } -+ else if (java.util.Date.class.equals(type) -+ || java.sql.Date.class.equals(type) -+ || java.sql.Timestamp.class.equals(type) -+ || java.sql.Time.class.equals(type)) { -+ return new DateFieldSerializer(field); -+ } -+ else -+ return new ObjectFieldSerializer(field); -+ } -+ -+ abstract static class FieldSerializer { -+ abstract void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException; -+ } -+ -+ final static class ObjectFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ ObjectFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ @Override -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ try { -+ Object value = _unsafe.getObject(obj, _offset); -+ -+ out.writeObject(value); -+ } catch (RuntimeException e) { -+ throw new RuntimeException(e.getMessage() + "\n field: " -+ + _field.getDeclaringClass().getName() -+ + '.' + _field.getName(), -+ e); -+ } catch (IOException e) { -+ throw new IOExceptionWrapper(e.getMessage() + "\n field: " -+ + _field.getDeclaringClass().getName() -+ + '.' + _field.getName(), -+ e); -+ } -+ } -+ } -+ -+ final static class BooleanFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ BooleanFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ boolean value = _unsafe.getBoolean(obj, _offset); -+ -+ out.writeBoolean(value); -+ } -+ } -+ -+ final static class ByteFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ ByteFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ int value = _unsafe.getByte(obj, _offset); -+ -+ out.writeInt(value); -+ } -+ } -+ -+ final static class CharFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ CharFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ char value = _unsafe.getChar(obj, _offset); -+ -+ out.writeString(String.valueOf(value)); -+ } -+ } -+ -+ final static class ShortFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ ShortFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ int value = _unsafe.getShort(obj, _offset); -+ -+ out.writeInt(value); -+ } -+ } -+ -+ final static class IntFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ IntFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ int value = _unsafe.getInt(obj, _offset); -+ -+ out.writeInt(value); -+ } -+ } -+ -+ final static class LongFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ LongFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ long value = _unsafe.getLong(obj, _offset); -+ -+ out.writeLong(value); -+ } -+ } -+ -+ final static class FloatFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ FloatFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ double value = _unsafe.getFloat(obj, _offset); -+ -+ out.writeDouble(value); -+ } -+ } -+ -+ final static class DoubleFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ DoubleFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ double value = _unsafe.getDouble(obj, _offset); -+ -+ out.writeDouble(value); -+ } -+ } -+ -+ final static class StringFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ StringFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ @Override -+ final void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ String value = (String) _unsafe.getObject(obj, _offset); -+ -+ out.writeString(value); -+ } -+ } -+ -+ final static class DateFieldSerializer extends FieldSerializer { -+ private final Field _field; -+ private final long _offset; -+ -+ DateFieldSerializer(Field field) -+ { -+ _field = field; -+ _offset = _unsafe.objectFieldOffset(field); -+ -+ if (_offset == Unsafe.INVALID_FIELD_OFFSET) -+ throw new IllegalStateException(); -+ } -+ -+ @Override -+ void serialize(AbstractHessianOutput out, Object obj) -+ throws IOException -+ { -+ java.util.Date value -+ = (java.util.Date) _unsafe.getObject(obj, _offset); -+ -+ if (value == null) -+ out.writeNull(); -+ else -+ out.writeUTCDate(value.getTime()); -+ } -+ } -+ -+ static { -+ boolean isEnabled = false; -+ Unsafe unsafe = null; -+ -+ try { -+ Class unsafeClass = Class.forName("sun.misc.Unsafe"); -+ Field theUnsafe = null; -+ for (Field field : unsafeClass.getDeclaredFields()) { -+ if (field.getName().equals("theUnsafe")) -+ theUnsafe = field; -+ } -+ -+ if (theUnsafe != null) { -+ theUnsafe.setAccessible(true); -+ unsafe = (Unsafe) theUnsafe.get(null); -+ } -+ -+ isEnabled = unsafe != null; -+ -+ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); -+ -+ if ("false".equals(unsafeProp)) -+ isEnabled = false; -+ } catch (Throwable e) { -+ log.log(Level.ALL, e.toString(), e); -+ } -+ -+ _unsafe = unsafe; -+ _isEnabled = isEnabled; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/UnsafeUnsharedSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeUnsharedSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/UnsafeUnsharedSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/UnsafeUnsharedSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,86 +1,86 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.ref.SoftReference; --import java.lang.reflect.Field; --import java.lang.reflect.Method; --import java.lang.reflect.Modifier; --import java.util.ArrayList; --import java.util.WeakHashMap; --import java.util.logging.Level; --import java.util.logging.Logger; -- --/** -- * Serializing an object for known object types. -- */ --public class UnsafeUnsharedSerializer extends UnsafeSerializer --{ -- private static final Logger log -- = Logger.getLogger(UnsafeUnsharedSerializer.class.getName()); -- -- public UnsafeUnsharedSerializer(Class cl) -- { -- super(cl); -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- boolean oldUnshared = out.setUnshared(true); -- -- try { -- super.writeObject(obj, out); -- } finally { -- out.setUnshared(oldUnshared); -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.ref.SoftReference; -+import java.lang.reflect.Field; -+import java.lang.reflect.Method; -+import java.lang.reflect.Modifier; -+import java.util.ArrayList; -+import java.util.WeakHashMap; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class UnsafeUnsharedSerializer extends UnsafeSerializer -+{ -+ private static final Logger log -+ = Logger.getLogger(UnsafeUnsharedSerializer.class.getName()); -+ -+ public UnsafeUnsharedSerializer(Class cl) -+ { -+ super(cl); -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ boolean oldUnshared = out.setUnshared(true); -+ -+ try { -+ super.writeObject(obj, out); -+ } finally { -+ out.setUnshared(oldUnshared); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/ValueDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/ValueDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/ValueDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/ValueDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,93 +1,93 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; -- --/** -- * Deserializing a string valued object -- */ --abstract public class ValueDeserializer extends AbstractDeserializer { -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String initValue = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if (key.equals("value")) -- initValue = in.readString(); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- return create(initValue); -- } -- -- public Object readObject(AbstractHessianInput in, String []fieldNames) -- throws IOException -- { -- String initValue = null; -- -- for (int i = 0; i < fieldNames.length; i++) { -- if ("value".equals(fieldNames[i])) -- initValue = in.readString(); -- else -- in.readObject(); -- } -- -- return create(initValue); -- } -- -- abstract Object create(String value) -- throws IOException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+ -+/** -+ * Deserializing a string valued object -+ */ -+abstract public class ValueDeserializer extends AbstractDeserializer { -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String initValue = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if (key.equals("value")) -+ initValue = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ return create(initValue); -+ } -+ -+ public Object readObject(AbstractHessianInput in, String []fieldNames) -+ throws IOException -+ { -+ String initValue = null; -+ -+ for (int i = 0; i < fieldNames.length; i++) { -+ if ("value".equals(fieldNames[i])) -+ initValue = in.readString(); -+ else -+ in.readObject(); -+ } -+ -+ return create(initValue); -+ } -+ -+ abstract Object create(String value) -+ throws IOException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/io/WriteReplaceSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/WriteReplaceSerializer.java ---- hessian-4.0.65-src/com/caucho/hessian/io/WriteReplaceSerializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/io/WriteReplaceSerializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,193 +1,193 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.io; -- --import java.io.IOException; --import java.lang.reflect.InvocationTargetException; --import java.lang.reflect.Method; --import java.util.logging.Level; --import java.util.logging.Logger; -- --/** -- * Serializing an object for known object types. -- */ --public class WriteReplaceSerializer extends AbstractSerializer --{ -- private static final Logger log -- = Logger.getLogger(WriteReplaceSerializer.class.getName()); -- -- private Object _writeReplaceFactory; -- private Method _writeReplace; -- private Serializer _baseSerializer; -- -- public WriteReplaceSerializer(Class cl, -- ClassLoader loader, -- Serializer baseSerializer) -- { -- introspectWriteReplace(cl, loader); -- -- _baseSerializer = baseSerializer; -- } -- -- private void introspectWriteReplace(Class cl, ClassLoader loader) -- { -- try { -- String className = cl.getName() + "HessianSerializer"; -- -- Class serializerClass = Class.forName(className, false, loader); -- -- Object serializerObject = serializerClass.newInstance(); -- -- Method writeReplace = getWriteReplace(serializerClass, cl); -- -- if (writeReplace != null) { -- _writeReplaceFactory = serializerObject; -- _writeReplace = writeReplace; -- } -- } catch (ClassNotFoundException e) { -- } catch (Exception e) { -- log.log(Level.FINER, e.toString(), e); -- } -- -- _writeReplace = getWriteReplace(cl); -- if (_writeReplace != null) -- _writeReplace.setAccessible(true); -- } -- -- /** -- * Returns the writeReplace method -- */ -- protected static Method getWriteReplace(Class cl, Class param) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- for (Method method : cl.getDeclaredMethods()) { -- if (method.getName().equals("writeReplace") -- && method.getParameterTypes().length == 1 -- && param.equals(method.getParameterTypes()[0])) -- return method; -- } -- } -- -- return null; -- } -- -- /** -- * Returns the writeReplace method -- */ -- protected static Method getWriteReplace(Class cl) -- { -- for (; cl != null; cl = cl.getSuperclass()) { -- Method []methods = cl.getDeclaredMethods(); -- -- for (int i = 0; i < methods.length; i++) { -- Method method = methods[i]; -- -- if (method.getName().equals("writeReplace") && -- method.getParameterTypes().length == 0) -- return method; -- } -- } -- -- return null; -- } -- -- @Override -- public void writeObject(Object obj, AbstractHessianOutput out) -- throws IOException -- { -- int ref = out.getRef(obj); -- -- if (ref >= 0) { -- out.writeRef(ref); -- -- return; -- } -- -- try { -- Object repl; -- -- repl = writeReplace(obj); -- -- if (obj == repl) { -- if (log.isLoggable(Level.FINE)) { -- log.fine(this + ": Hessian writeReplace error. The writeReplace method (" + _writeReplace + ") must not return the same object: " + obj); -- } -- -- _baseSerializer.writeObject(obj, out); -- -- return; -- } -- -- out.writeObject(repl); -- -- out.replaceRef(repl, obj); -- } catch (RuntimeException e) { -- throw e; -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- @Override -- protected Object writeReplace(Object obj) -- { -- try { -- if (_writeReplaceFactory != null) -- return _writeReplace.invoke(_writeReplaceFactory, obj); -- else -- return _writeReplace.invoke(obj); -- } catch (RuntimeException e) { -- throw e; -- } catch (InvocationTargetException e) { -- throw new RuntimeException(e.getCause()); -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.io; -+ -+import java.io.IOException; -+import java.lang.reflect.InvocationTargetException; -+import java.lang.reflect.Method; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+/** -+ * Serializing an object for known object types. -+ */ -+public class WriteReplaceSerializer extends AbstractSerializer -+{ -+ private static final Logger log -+ = Logger.getLogger(WriteReplaceSerializer.class.getName()); -+ -+ private Object _writeReplaceFactory; -+ private Method _writeReplace; -+ private Serializer _baseSerializer; -+ -+ public WriteReplaceSerializer(Class cl, -+ ClassLoader loader, -+ Serializer baseSerializer) -+ { -+ introspectWriteReplace(cl, loader); -+ -+ _baseSerializer = baseSerializer; -+ } -+ -+ private void introspectWriteReplace(Class cl, ClassLoader loader) -+ { -+ try { -+ String className = cl.getName() + "HessianSerializer"; -+ -+ Class serializerClass = Class.forName(className, false, loader); -+ -+ Object serializerObject = serializerClass.newInstance(); -+ -+ Method writeReplace = getWriteReplace(serializerClass, cl); -+ -+ if (writeReplace != null) { -+ _writeReplaceFactory = serializerObject; -+ _writeReplace = writeReplace; -+ } -+ } catch (ClassNotFoundException e) { -+ } catch (Exception e) { -+ log.log(Level.FINER, e.toString(), e); -+ } -+ -+ _writeReplace = getWriteReplace(cl); -+ if (_writeReplace != null) -+ _writeReplace.setAccessible(true); -+ } -+ -+ /** -+ * Returns the writeReplace method -+ */ -+ protected static Method getWriteReplace(Class cl, Class param) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ for (Method method : cl.getDeclaredMethods()) { -+ if (method.getName().equals("writeReplace") -+ && method.getParameterTypes().length == 1 -+ && param.equals(method.getParameterTypes()[0])) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ /** -+ * Returns the writeReplace method -+ */ -+ protected static Method getWriteReplace(Class cl) -+ { -+ for (; cl != null; cl = cl.getSuperclass()) { -+ Method []methods = cl.getDeclaredMethods(); -+ -+ for (int i = 0; i < methods.length; i++) { -+ Method method = methods[i]; -+ -+ if (method.getName().equals("writeReplace") && -+ method.getParameterTypes().length == 0) -+ return method; -+ } -+ } -+ -+ return null; -+ } -+ -+ @Override -+ public void writeObject(Object obj, AbstractHessianOutput out) -+ throws IOException -+ { -+ int ref = out.getRef(obj); -+ -+ if (ref >= 0) { -+ out.writeRef(ref); -+ -+ return; -+ } -+ -+ try { -+ Object repl; -+ -+ repl = writeReplace(obj); -+ -+ if (obj == repl) { -+ if (log.isLoggable(Level.FINE)) { -+ log.fine(this + ": Hessian writeReplace error. The writeReplace method (" + _writeReplace + ") must not return the same object: " + obj); -+ } -+ -+ _baseSerializer.writeObject(obj, out); -+ -+ return; -+ } -+ -+ out.writeObject(repl); -+ -+ out.replaceRef(repl, obj); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ @Override -+ protected Object writeReplace(Object obj) -+ { -+ try { -+ if (_writeReplaceFactory != null) -+ return _writeReplace.invoke(_writeReplaceFactory, obj); -+ else -+ return _writeReplace.invoke(obj); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (InvocationTargetException e) { -+ throw new RuntimeException(e.getCause()); -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/JMXSerializerFactory.java hessian-4.0.65-fix/com/caucho/hessian/jmx/JMXSerializerFactory.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/JMXSerializerFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/JMXSerializerFactory.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,120 +1,120 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractSerializerFactory; --import com.caucho.hessian.io.Deserializer; --import com.caucho.hessian.io.HessianProtocolException; --import com.caucho.hessian.io.Serializer; --import com.caucho.hessian.io.StringValueDeserializer; --import com.caucho.hessian.io.StringValueSerializer; -- --import javax.management.*; -- --/** -- * Serializers for JMX classes. -- */ --public class JMXSerializerFactory extends AbstractSerializerFactory { -- /** -- * Returns the serializer for a class. -- * -- * @param cl the class of the object that needs to be serialized. -- * -- * @return a serializer object for the serialization. -- */ -- public Serializer getSerializer(Class cl) -- throws HessianProtocolException -- { -- if (ObjectName.class.equals(cl)) { -- return new StringValueSerializer(); -- } -- -- return null; -- } -- -- /** -- * Returns the deserializer for a class. -- * -- * @param cl the class of the object that needs to be deserialized. -- * -- * @return a deserializer object for the serialization. -- */ -- public Deserializer getDeserializer(Class cl) -- throws HessianProtocolException -- { -- if (ObjectName.class.equals(cl)) { -- return new StringValueDeserializer(cl); -- } -- else if (ObjectInstance.class.equals(cl)) { -- return new ObjectInstanceDeserializer(); -- } -- else if (MBeanAttributeInfo.class.isAssignableFrom(cl)) { -- return new MBeanAttributeInfoDeserializer(); -- } -- else if (MBeanConstructorInfo.class.isAssignableFrom(cl)) { -- return new MBeanConstructorInfoDeserializer(); -- } -- else if (MBeanOperationInfo.class.isAssignableFrom(cl)) { -- return new MBeanOperationInfoDeserializer(); -- } -- else if (MBeanParameterInfo.class.isAssignableFrom(cl)) { -- return new MBeanParameterInfoDeserializer(); -- } -- else if (MBeanNotificationInfo.class.isAssignableFrom(cl)) { -- return new MBeanNotificationInfoDeserializer(); -- } -- /* -- else if (MBeanInfo.class.equals(cl)) { -- return new MBeanInfoDeserializer(); -- } -- */ -- -- return null; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractSerializerFactory; -+import com.caucho.hessian.io.Deserializer; -+import com.caucho.hessian.io.HessianProtocolException; -+import com.caucho.hessian.io.Serializer; -+import com.caucho.hessian.io.StringValueDeserializer; -+import com.caucho.hessian.io.StringValueSerializer; -+ -+import javax.management.*; -+ -+/** -+ * Serializers for JMX classes. -+ */ -+public class JMXSerializerFactory extends AbstractSerializerFactory { -+ /** -+ * Returns the serializer for a class. -+ * -+ * @param cl the class of the object that needs to be serialized. -+ * -+ * @return a serializer object for the serialization. -+ */ -+ public Serializer getSerializer(Class cl) -+ throws HessianProtocolException -+ { -+ if (ObjectName.class.equals(cl)) { -+ return new StringValueSerializer(); -+ } -+ -+ return null; -+ } -+ -+ /** -+ * Returns the deserializer for a class. -+ * -+ * @param cl the class of the object that needs to be deserialized. -+ * -+ * @return a deserializer object for the serialization. -+ */ -+ public Deserializer getDeserializer(Class cl) -+ throws HessianProtocolException -+ { -+ if (ObjectName.class.equals(cl)) { -+ return new StringValueDeserializer(cl); -+ } -+ else if (ObjectInstance.class.equals(cl)) { -+ return new ObjectInstanceDeserializer(); -+ } -+ else if (MBeanAttributeInfo.class.isAssignableFrom(cl)) { -+ return new MBeanAttributeInfoDeserializer(); -+ } -+ else if (MBeanConstructorInfo.class.isAssignableFrom(cl)) { -+ return new MBeanConstructorInfoDeserializer(); -+ } -+ else if (MBeanOperationInfo.class.isAssignableFrom(cl)) { -+ return new MBeanOperationInfoDeserializer(); -+ } -+ else if (MBeanParameterInfo.class.isAssignableFrom(cl)) { -+ return new MBeanParameterInfoDeserializer(); -+ } -+ else if (MBeanNotificationInfo.class.isAssignableFrom(cl)) { -+ return new MBeanNotificationInfoDeserializer(); -+ } -+ /* -+ else if (MBeanInfo.class.equals(cl)) { -+ return new MBeanInfoDeserializer(); -+ } -+ */ -+ -+ return null; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanAttributeInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,109 +1,109 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractDeserializer; --import com.caucho.hessian.io.AbstractHessianInput; -- --import javax.management.MBeanAttributeInfo; --import java.io.IOException; -- --/** -- * Deserializing an MBeanAttributeInfo valued object -- */ --public class MBeanAttributeInfoDeserializer extends AbstractDeserializer { -- public Class getType() -- { -- return MBeanAttributeInfo.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String name = null; -- String type = null; -- String description = null; -- boolean isRead = false; -- boolean isWrite = false; -- boolean isIs = false; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if ("name".equals(key)) -- name = in.readString(); -- else if ("attributeType".equals(key)) -- type = in.readString(); -- else if ("description".equals(key)) -- description = in.readString(); -- else if ("isRead".equals(key)) -- isRead = in.readBoolean(); -- else if ("isWrite".equals(key)) -- isWrite = in.readBoolean(); -- else if ("is".equals(key)) -- isIs = in.readBoolean(); -- else { -- in.readObject(); -- } -- } -- -- in.readMapEnd(); -- -- try { -- MBeanAttributeInfo info; -- -- info = new MBeanAttributeInfo(name, type, description, -- isRead, isWrite, isIs); -- -- return info; -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import javax.management.MBeanAttributeInfo; -+import java.io.IOException; -+ -+/** -+ * Deserializing an MBeanAttributeInfo valued object -+ */ -+public class MBeanAttributeInfoDeserializer extends AbstractDeserializer { -+ public Class getType() -+ { -+ return MBeanAttributeInfo.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String name = null; -+ String type = null; -+ String description = null; -+ boolean isRead = false; -+ boolean isWrite = false; -+ boolean isIs = false; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if ("name".equals(key)) -+ name = in.readString(); -+ else if ("attributeType".equals(key)) -+ type = in.readString(); -+ else if ("description".equals(key)) -+ description = in.readString(); -+ else if ("isRead".equals(key)) -+ isRead = in.readBoolean(); -+ else if ("isWrite".equals(key)) -+ isWrite = in.readBoolean(); -+ else if ("is".equals(key)) -+ isIs = in.readBoolean(); -+ else { -+ in.readObject(); -+ } -+ } -+ -+ in.readMapEnd(); -+ -+ try { -+ MBeanAttributeInfo info; -+ -+ info = new MBeanAttributeInfo(name, type, description, -+ isRead, isWrite, isIs); -+ -+ return info; -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanConstructorInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,100 +1,100 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractDeserializer; --import com.caucho.hessian.io.AbstractHessianInput; -- --import javax.management.MBeanConstructorInfo; --import javax.management.MBeanParameterInfo; --import java.io.IOException; -- --/** -- * Deserializing an MBeanConstructorInfo valued object -- */ --public class MBeanConstructorInfoDeserializer extends AbstractDeserializer { -- public Class getType() -- { -- return MBeanConstructorInfo.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String name = null; -- String description = null; -- MBeanParameterInfo []sig = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if ("name".equals(key)) -- name = in.readString(); -- else if ("description".equals(key)) -- description = in.readString(); -- else if ("signature".equals(key)) -- sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); -- else { -- in.readObject(); -- } -- } -- -- in.readMapEnd(); -- -- try { -- MBeanConstructorInfo info; -- -- info = new MBeanConstructorInfo(name, description, sig); -- -- return info; -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import javax.management.MBeanConstructorInfo; -+import javax.management.MBeanParameterInfo; -+import java.io.IOException; -+ -+/** -+ * Deserializing an MBeanConstructorInfo valued object -+ */ -+public class MBeanConstructorInfoDeserializer extends AbstractDeserializer { -+ public Class getType() -+ { -+ return MBeanConstructorInfo.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String name = null; -+ String description = null; -+ MBeanParameterInfo []sig = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if ("name".equals(key)) -+ name = in.readString(); -+ else if ("description".equals(key)) -+ description = in.readString(); -+ else if ("signature".equals(key)) -+ sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); -+ else { -+ in.readObject(); -+ } -+ } -+ -+ in.readMapEnd(); -+ -+ try { -+ MBeanConstructorInfo info; -+ -+ info = new MBeanConstructorInfo(name, description, sig); -+ -+ return info; -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanInfoDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,113 +1,113 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractDeserializer; --import com.caucho.hessian.io.AbstractHessianInput; -- --import javax.management.MBeanAttributeInfo; --import javax.management.MBeanConstructorInfo; --import javax.management.MBeanInfo; --import javax.management.MBeanNotificationInfo; --import javax.management.MBeanOperationInfo; --import java.io.IOException; -- --/** -- * Deserializing an MBeanInfo valued object -- */ --public class MBeanInfoDeserializer extends AbstractDeserializer { -- public Class getType() -- { -- return MBeanInfo.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String className = null; -- String description = null; -- MBeanAttributeInfo []attributes = null; -- MBeanConstructorInfo []constructors = null; -- MBeanOperationInfo []operations = null; -- MBeanNotificationInfo []notifications = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if ("className".equals(key)) -- className = in.readString(); -- else if ("description".equals(key)) -- description = in.readString(); -- else if ("attributes".equals(key)) { -- attributes = (MBeanAttributeInfo []) in.readObject(MBeanAttributeInfo[].class); -- } -- /* -- else if ("isWrite".equals(key)) -- isWrite = in.readBoolean(); -- else if ("isIs".equals(key)) -- isIs = in.readBoolean(); -- */ -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- try { -- MBeanInfo info; -- -- info = new MBeanInfo(className, description, attributes, -- constructors, operations, notifications); -- -- return info; -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import javax.management.MBeanAttributeInfo; -+import javax.management.MBeanConstructorInfo; -+import javax.management.MBeanInfo; -+import javax.management.MBeanNotificationInfo; -+import javax.management.MBeanOperationInfo; -+import java.io.IOException; -+ -+/** -+ * Deserializing an MBeanInfo valued object -+ */ -+public class MBeanInfoDeserializer extends AbstractDeserializer { -+ public Class getType() -+ { -+ return MBeanInfo.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String className = null; -+ String description = null; -+ MBeanAttributeInfo []attributes = null; -+ MBeanConstructorInfo []constructors = null; -+ MBeanOperationInfo []operations = null; -+ MBeanNotificationInfo []notifications = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if ("className".equals(key)) -+ className = in.readString(); -+ else if ("description".equals(key)) -+ description = in.readString(); -+ else if ("attributes".equals(key)) { -+ attributes = (MBeanAttributeInfo []) in.readObject(MBeanAttributeInfo[].class); -+ } -+ /* -+ else if ("isWrite".equals(key)) -+ isWrite = in.readBoolean(); -+ else if ("isIs".equals(key)) -+ isIs = in.readBoolean(); -+ */ -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ try { -+ MBeanInfo info; -+ -+ info = new MBeanInfo(className, description, attributes, -+ constructors, operations, notifications); -+ -+ return info; -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanNotificationInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,99 +1,99 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractDeserializer; --import com.caucho.hessian.io.AbstractHessianInput; -- --import javax.management.MBeanNotificationInfo; --import java.io.IOException; -- --/** -- * Deserializing an MBeanNotificationInfo valued object -- */ --public class MBeanNotificationInfoDeserializer extends AbstractDeserializer { -- public Class getType() -- { -- return MBeanNotificationInfo.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String name = null; -- String description = null; -- String []types = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if ("name".equals(key)) -- name = in.readString(); -- else if ("description".equals(key)) -- description = in.readString(); -- else if ("types".equals(key)) -- types = (String[]) in.readObject(String[].class); -- else { -- in.readObject(); -- } -- } -- -- in.readMapEnd(); -- -- try { -- MBeanNotificationInfo info; -- -- info = new MBeanNotificationInfo(types, name, description); -- -- return info; -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import javax.management.MBeanNotificationInfo; -+import java.io.IOException; -+ -+/** -+ * Deserializing an MBeanNotificationInfo valued object -+ */ -+public class MBeanNotificationInfoDeserializer extends AbstractDeserializer { -+ public Class getType() -+ { -+ return MBeanNotificationInfo.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String name = null; -+ String description = null; -+ String []types = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if ("name".equals(key)) -+ name = in.readString(); -+ else if ("description".equals(key)) -+ description = in.readString(); -+ else if ("types".equals(key)) -+ types = (String[]) in.readObject(String[].class); -+ else { -+ in.readObject(); -+ } -+ } -+ -+ in.readMapEnd(); -+ -+ try { -+ MBeanNotificationInfo info; -+ -+ info = new MBeanNotificationInfo(types, name, description); -+ -+ return info; -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanOperationInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,107 +1,107 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractDeserializer; --import com.caucho.hessian.io.AbstractHessianInput; -- --import javax.management.MBeanOperationInfo; --import javax.management.MBeanParameterInfo; --import java.io.IOException; -- --/** -- * Deserializing an MBeanOperationInfo valued object -- */ --public class MBeanOperationInfoDeserializer extends AbstractDeserializer { -- public Class getType() -- { -- return MBeanOperationInfo.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String name = null; -- String type = null; -- String description = null; -- MBeanParameterInfo []sig = null; -- int impact = 0; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if ("name".equals(key)) -- name = in.readString(); -- else if ("description".equals(key)) -- description = in.readString(); -- else if ("type".equals(key)) -- type = in.readString(); -- else if ("impact".equals(key)) -- impact = in.readInt(); -- else if ("signature".equals(key)) { -- sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); -- } -- else { -- in.readObject(); -- } -- } -- -- in.readMapEnd(); -- -- try { -- MBeanOperationInfo info; -- -- info = new MBeanOperationInfo(name, description, sig, type, impact); -- -- return info; -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import javax.management.MBeanOperationInfo; -+import javax.management.MBeanParameterInfo; -+import java.io.IOException; -+ -+/** -+ * Deserializing an MBeanOperationInfo valued object -+ */ -+public class MBeanOperationInfoDeserializer extends AbstractDeserializer { -+ public Class getType() -+ { -+ return MBeanOperationInfo.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String name = null; -+ String type = null; -+ String description = null; -+ MBeanParameterInfo []sig = null; -+ int impact = 0; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if ("name".equals(key)) -+ name = in.readString(); -+ else if ("description".equals(key)) -+ description = in.readString(); -+ else if ("type".equals(key)) -+ type = in.readString(); -+ else if ("impact".equals(key)) -+ impact = in.readInt(); -+ else if ("signature".equals(key)) { -+ sig = (MBeanParameterInfo[]) in.readObject(MBeanParameterInfo[].class); -+ } -+ else { -+ in.readObject(); -+ } -+ } -+ -+ in.readMapEnd(); -+ -+ try { -+ MBeanOperationInfo info; -+ -+ info = new MBeanOperationInfo(name, description, sig, type, impact); -+ -+ return info; -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/MBeanParameterInfoDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,102 +1,102 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractDeserializer; --import com.caucho.hessian.io.AbstractHessianInput; -- --import javax.management.MBeanParameterInfo; --import java.io.IOException; -- --/** -- * Deserializing an MBeanParameterInfo valued object -- */ --public class MBeanParameterInfoDeserializer extends AbstractDeserializer { -- public Class getType() -- { -- return MBeanParameterInfo.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String name = null; -- String type = null; -- String description = null; -- boolean isRead = false; -- boolean isWrite = false; -- boolean isIs = false; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if ("name".equals(key)) -- name = in.readString(); -- else if ("type".equals(key)) -- type = in.readString(); -- else if ("description".equals(key)) -- description = in.readString(); -- else { -- in.readObject(); -- } -- } -- -- in.readMapEnd(); -- -- try { -- MBeanParameterInfo info; -- -- info = new MBeanParameterInfo(name, type, description); -- -- return info; -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import javax.management.MBeanParameterInfo; -+import java.io.IOException; -+ -+/** -+ * Deserializing an MBeanParameterInfo valued object -+ */ -+public class MBeanParameterInfoDeserializer extends AbstractDeserializer { -+ public Class getType() -+ { -+ return MBeanParameterInfo.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String name = null; -+ String type = null; -+ String description = null; -+ boolean isRead = false; -+ boolean isWrite = false; -+ boolean isIs = false; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if ("name".equals(key)) -+ name = in.readString(); -+ else if ("type".equals(key)) -+ type = in.readString(); -+ else if ("description".equals(key)) -+ description = in.readString(); -+ else { -+ in.readObject(); -+ } -+ } -+ -+ in.readMapEnd(); -+ -+ try { -+ MBeanParameterInfo info; -+ -+ info = new MBeanParameterInfo(name, type, description); -+ -+ return info; -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java ---- hessian-4.0.65-src/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/jmx/ObjectInstanceDeserializer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,94 +1,94 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.jmx; -- --import com.caucho.hessian.io.AbstractDeserializer; --import com.caucho.hessian.io.AbstractHessianInput; -- --import javax.management.ObjectInstance; --import javax.management.ObjectName; --import java.io.IOException; -- --/** -- * Deserializing an ObjectInstance valued object -- */ --public class ObjectInstanceDeserializer extends AbstractDeserializer { -- public Class getType() -- { -- return ObjectInstance.class; -- } -- -- public Object readMap(AbstractHessianInput in) -- throws IOException -- { -- String className = null; -- ObjectName objectName = null; -- -- String initValue = null; -- -- while (! in.isEnd()) { -- String key = in.readString(); -- -- if ("className".equals(key)) -- className = in.readString(); -- else if ("name".equals(key)) -- objectName = (ObjectName) in.readObject(ObjectName.class); -- else -- in.readObject(); -- } -- -- in.readMapEnd(); -- -- try { -- return new ObjectInstance(objectName, className); -- } catch (Exception e) { -- throw new IOException(String.valueOf(e)); -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.jmx; -+ -+import com.caucho.hessian.io.AbstractDeserializer; -+import com.caucho.hessian.io.AbstractHessianInput; -+ -+import javax.management.ObjectInstance; -+import javax.management.ObjectName; -+import java.io.IOException; -+ -+/** -+ * Deserializing an ObjectInstance valued object -+ */ -+public class ObjectInstanceDeserializer extends AbstractDeserializer { -+ public Class getType() -+ { -+ return ObjectInstance.class; -+ } -+ -+ public Object readMap(AbstractHessianInput in) -+ throws IOException -+ { -+ String className = null; -+ ObjectName objectName = null; -+ -+ String initValue = null; -+ -+ while (! in.isEnd()) { -+ String key = in.readString(); -+ -+ if ("className".equals(key)) -+ className = in.readString(); -+ else if ("name".equals(key)) -+ objectName = (ObjectName) in.readObject(ObjectName.class); -+ else -+ in.readObject(); -+ } -+ -+ in.readMapEnd(); -+ -+ try { -+ return new ObjectInstance(objectName, className); -+ } catch (Exception e) { -+ throw new IOException(String.valueOf(e)); -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianInput.java hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianInput.java ---- hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianInput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianInput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,456 +1,456 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.micro; -- --import java.io.ByteArrayOutputStream; --import java.io.IOException; --import java.io.InputStream; --import java.util.Date; -- --/** -- * Input stream for Hessian requests, compatible with microedition -- * Java. It only uses classes and types available to J2ME. In -- * particular, it does not have any support for the <double> type. -- * -- *

MicroHessianInput does not depend on any classes other than -- * in J2ME, so it can be extracted independently into a smaller package. -- * -- *

MicroHessianInput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * InputStream is = ...; // from http connection
-- * MicroHessianInput in = new MicroHessianInput(is);
-- * String value;
-- *
-- * in.startReply();         // read reply header
-- * value = in.readString(); // read string value
-- * in.completeReply();      // read reply footer
-- * 
-- */ --public class MicroHessianInput { -- protected InputStream is; -- /** -- * Creates a new Hessian input stream, initialized with an -- * underlying input stream. -- * -- * @param is the underlying input stream. -- */ -- public MicroHessianInput(InputStream is) -- { -- init(is); -- } -- -- /** -- * Creates an uninitialized Hessian input stream. -- */ -- public MicroHessianInput() -- { -- } -- -- /** -- * Initialize the hessian stream with the underlying input stream. -- */ -- public void init(InputStream is) -- { -- this.is = is; -- } -- -- /** -- * Starts reading the reply -- * -- *

A successful completion will have a single value: -- * -- *

--   * r x01 x00
--   * 
-- */ -- public void startReply() -- throws IOException -- { -- int tag = is.read(); -- -- if (tag != 'r') -- protocolException("expected hessian reply"); -- -- int major = is.read(); -- int minor = is.read(); -- } -- -- /** -- * Completes reading the call -- * -- *

A successful completion will have a single value: -- * -- *

--   * z
--   * 
-- */ -- public void completeReply() -- throws IOException -- { -- int tag = is.read(); -- -- if (tag != 'z') -- protocolException("expected end of reply"); -- } -- -- /** -- * Reads a boolean -- * -- *
--   * T
--   * F
--   * 
-- */ -- public boolean readBoolean() -- throws IOException -- { -- int tag = is.read(); -- -- switch (tag) { -- case 'T': return true; -- case 'F': return false; -- default: -- throw expect("boolean", tag); -- } -- } -- -- /** -- * Reads an integer -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- */ -- public int readInt() -- throws IOException -- { -- int tag = is.read(); -- -- if (tag != 'I') -- throw expect("integer", tag); -- -- int b32 = is.read(); -- int b24 = is.read(); -- int b16 = is.read(); -- int b8 = is.read(); -- -- return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -- } -- -- /** -- * Reads a long -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public long readLong() -- throws IOException -- { -- int tag = is.read(); -- -- if (tag != 'L') -- throw protocolException("expected long"); -- -- long b64 = is.read(); -- long b56 = is.read(); -- long b48 = is.read(); -- long b40 = is.read(); -- long b32 = is.read(); -- long b24 = is.read(); -- long b16 = is.read(); -- long b8 = is.read(); -- -- return ((b64 << 56) + -- (b56 << 48) + -- (b48 << 40) + -- (b40 << 32) + -- (b32 << 24) + -- (b24 << 16) + -- (b16 << 8) + -- b8); -- } -- -- /** -- * Reads a date. -- * -- *
--   * T b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- */ -- public long readUTCDate() -- throws IOException -- { -- int tag = is.read(); -- -- if (tag != 'd') -- throw protocolException("expected date"); -- -- long b64 = is.read(); -- long b56 = is.read(); -- long b48 = is.read(); -- long b40 = is.read(); -- long b32 = is.read(); -- long b24 = is.read(); -- long b16 = is.read(); -- long b8 = is.read(); -- -- return ((b64 << 56) + -- (b56 << 48) + -- (b48 << 40) + -- (b40 << 32) + -- (b32 << 24) + -- (b24 << 16) + -- (b16 << 8) + -- b8); -- } -- -- /** -- * Reads a string -- * -- *
--   * S b16 b8 string value
--   * 
-- */ -- public String readString() -- throws IOException -- { -- int tag = is.read(); -- -- if (tag == 'N') -- return null; -- -- if (tag != 'S') -- throw expect("string", tag); -- -- int b16 = is.read(); -- int b8 = is.read(); -- -- int len = (b16 << 8) + b8; -- -- return readStringImpl(len); -- } -- -- /** -- * Reads a byte array -- * -- *
--   * B b16 b8 data value
--   * 
-- */ -- public byte []readBytes() -- throws IOException -- { -- int tag = is.read(); -- -- if (tag == 'N') -- return null; -- -- if (tag != 'B') -- throw expect("bytes", tag); -- -- int b16 = is.read(); -- int b8 = is.read(); -- -- int len = (b16 << 8) + b8; -- -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- for (int i = 0; i < len; i++) -- bos.write(is.read()); -- -- return bos.toByteArray(); -- } -- -- /** -- * Reads an arbitrary object the input stream. -- */ -- public Object readObject(Class expectedClass) -- throws IOException -- { -- int tag = is.read(); -- -- switch (tag) { -- case 'N': -- return null; -- -- case 'T': -- return new Boolean(true); -- -- case 'F': -- return new Boolean(false); -- -- case 'I': { -- int b32 = is.read(); -- int b24 = is.read(); -- int b16 = is.read(); -- int b8 = is.read(); -- -- return new Integer((b32 << 24) + (b24 << 16) + (b16 << 8) + b8); -- } -- -- case 'L': { -- long b64 = is.read(); -- long b56 = is.read(); -- long b48 = is.read(); -- long b40 = is.read(); -- long b32 = is.read(); -- long b24 = is.read(); -- long b16 = is.read(); -- long b8 = is.read(); -- -- return new Long((b64 << 56) + -- (b56 << 48) + -- (b48 << 40) + -- (b40 << 32) + -- (b32 << 24) + -- (b24 << 16) + -- (b16 << 8) + -- b8); -- } -- -- case 'd': { -- long b64 = is.read(); -- long b56 = is.read(); -- long b48 = is.read(); -- long b40 = is.read(); -- long b32 = is.read(); -- long b24 = is.read(); -- long b16 = is.read(); -- long b8 = is.read(); -- -- return new Date((b64 << 56) + -- (b56 << 48) + -- (b48 << 40) + -- (b40 << 32) + -- (b32 << 24) + -- (b24 << 16) + -- (b16 << 8) + -- b8); -- } -- -- case 'S': -- case 'X': { -- int b16 = is.read(); -- int b8 = is.read(); -- -- int len = (b16 << 8) + b8; -- -- return readStringImpl(len); -- } -- -- case 'B': { -- if (tag != 'B') -- throw expect("bytes", tag); -- -- int b16 = is.read(); -- int b8 = is.read(); -- -- int len = (b16 << 8) + b8; -- -- ByteArrayOutputStream bos = new ByteArrayOutputStream(); -- -- for (int i = 0; i < len; i++) -- bos.write(is.read()); -- -- return bos.toByteArray(); -- } -- default: -- throw new IOException("unknown code:" + (char) tag); -- } -- } -- -- /** -- * Reads a string from the underlying stream. -- */ -- protected String readStringImpl(int length) -- throws IOException -- { -- StringBuffer sb = new StringBuffer(); -- -- for (int i = 0; i < length; i++) { -- int ch = is.read(); -- -- if (ch < 0x80) -- sb.append((char) ch); -- else if ((ch & 0xe0) == 0xc0) { -- int ch1 = is.read(); -- int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -- -- sb.append((char) v); -- } -- else if ((ch & 0xf0) == 0xe0) { -- int ch1 = is.read(); -- int ch2 = is.read(); -- int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -- -- sb.append((char) v); -- } -- else -- throw new IOException("bad utf-8 encoding"); -- } -- -- return sb.toString(); -- } -- -- protected IOException expect(String expect, int ch) -- { -- if (ch < 0) -- return protocolException("expected " + expect + " at end of file"); -- else -- return protocolException("expected " + expect + " at " + (char) ch); -- } -- -- protected IOException protocolException(String message) -- { -- return new IOException(message); -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.micro; -+ -+import java.io.ByteArrayOutputStream; -+import java.io.IOException; -+import java.io.InputStream; -+import java.util.Date; -+ -+/** -+ * Input stream for Hessian requests, compatible with microedition -+ * Java. It only uses classes and types available to J2ME. In -+ * particular, it does not have any support for the <double> type. -+ * -+ *

MicroHessianInput does not depend on any classes other than -+ * in J2ME, so it can be extracted independently into a smaller package. -+ * -+ *

MicroHessianInput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * InputStream is = ...; // from http connection
-+ * MicroHessianInput in = new MicroHessianInput(is);
-+ * String value;
-+ *
-+ * in.startReply();         // read reply header
-+ * value = in.readString(); // read string value
-+ * in.completeReply();      // read reply footer
-+ * 
-+ */ -+public class MicroHessianInput { -+ protected InputStream is; -+ /** -+ * Creates a new Hessian input stream, initialized with an -+ * underlying input stream. -+ * -+ * @param is the underlying input stream. -+ */ -+ public MicroHessianInput(InputStream is) -+ { -+ init(is); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian input stream. -+ */ -+ public MicroHessianInput() -+ { -+ } -+ -+ /** -+ * Initialize the hessian stream with the underlying input stream. -+ */ -+ public void init(InputStream is) -+ { -+ this.is = is; -+ } -+ -+ /** -+ * Starts reading the reply -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * r x01 x00
-+   * 
-+ */ -+ public void startReply() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ if (tag != 'r') -+ protocolException("expected hessian reply"); -+ -+ int major = is.read(); -+ int minor = is.read(); -+ } -+ -+ /** -+ * Completes reading the call -+ * -+ *

A successful completion will have a single value: -+ * -+ *

-+   * z
-+   * 
-+ */ -+ public void completeReply() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ if (tag != 'z') -+ protocolException("expected end of reply"); -+ } -+ -+ /** -+ * Reads a boolean -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ */ -+ public boolean readBoolean() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ switch (tag) { -+ case 'T': return true; -+ case 'F': return false; -+ default: -+ throw expect("boolean", tag); -+ } -+ } -+ -+ /** -+ * Reads an integer -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ */ -+ public int readInt() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ if (tag != 'I') -+ throw expect("integer", tag); -+ -+ int b32 = is.read(); -+ int b24 = is.read(); -+ int b16 = is.read(); -+ int b8 = is.read(); -+ -+ return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8; -+ } -+ -+ /** -+ * Reads a long -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public long readLong() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ if (tag != 'L') -+ throw protocolException("expected long"); -+ -+ long b64 = is.read(); -+ long b56 = is.read(); -+ long b48 = is.read(); -+ long b40 = is.read(); -+ long b32 = is.read(); -+ long b24 = is.read(); -+ long b16 = is.read(); -+ long b8 = is.read(); -+ -+ return ((b64 << 56) + -+ (b56 << 48) + -+ (b48 << 40) + -+ (b40 << 32) + -+ (b32 << 24) + -+ (b24 << 16) + -+ (b16 << 8) + -+ b8); -+ } -+ -+ /** -+ * Reads a date. -+ * -+ *
-+   * T b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ */ -+ public long readUTCDate() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ if (tag != 'd') -+ throw protocolException("expected date"); -+ -+ long b64 = is.read(); -+ long b56 = is.read(); -+ long b48 = is.read(); -+ long b40 = is.read(); -+ long b32 = is.read(); -+ long b24 = is.read(); -+ long b16 = is.read(); -+ long b8 = is.read(); -+ -+ return ((b64 << 56) + -+ (b56 << 48) + -+ (b48 << 40) + -+ (b40 << 32) + -+ (b32 << 24) + -+ (b24 << 16) + -+ (b16 << 8) + -+ b8); -+ } -+ -+ /** -+ * Reads a string -+ * -+ *
-+   * S b16 b8 string value
-+   * 
-+ */ -+ public String readString() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ if (tag == 'N') -+ return null; -+ -+ if (tag != 'S') -+ throw expect("string", tag); -+ -+ int b16 = is.read(); -+ int b8 = is.read(); -+ -+ int len = (b16 << 8) + b8; -+ -+ return readStringImpl(len); -+ } -+ -+ /** -+ * Reads a byte array -+ * -+ *
-+   * B b16 b8 data value
-+   * 
-+ */ -+ public byte []readBytes() -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ if (tag == 'N') -+ return null; -+ -+ if (tag != 'B') -+ throw expect("bytes", tag); -+ -+ int b16 = is.read(); -+ int b8 = is.read(); -+ -+ int len = (b16 << 8) + b8; -+ -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ for (int i = 0; i < len; i++) -+ bos.write(is.read()); -+ -+ return bos.toByteArray(); -+ } -+ -+ /** -+ * Reads an arbitrary object the input stream. -+ */ -+ public Object readObject(Class expectedClass) -+ throws IOException -+ { -+ int tag = is.read(); -+ -+ switch (tag) { -+ case 'N': -+ return null; -+ -+ case 'T': -+ return new Boolean(true); -+ -+ case 'F': -+ return new Boolean(false); -+ -+ case 'I': { -+ int b32 = is.read(); -+ int b24 = is.read(); -+ int b16 = is.read(); -+ int b8 = is.read(); -+ -+ return new Integer((b32 << 24) + (b24 << 16) + (b16 << 8) + b8); -+ } -+ -+ case 'L': { -+ long b64 = is.read(); -+ long b56 = is.read(); -+ long b48 = is.read(); -+ long b40 = is.read(); -+ long b32 = is.read(); -+ long b24 = is.read(); -+ long b16 = is.read(); -+ long b8 = is.read(); -+ -+ return new Long((b64 << 56) + -+ (b56 << 48) + -+ (b48 << 40) + -+ (b40 << 32) + -+ (b32 << 24) + -+ (b24 << 16) + -+ (b16 << 8) + -+ b8); -+ } -+ -+ case 'd': { -+ long b64 = is.read(); -+ long b56 = is.read(); -+ long b48 = is.read(); -+ long b40 = is.read(); -+ long b32 = is.read(); -+ long b24 = is.read(); -+ long b16 = is.read(); -+ long b8 = is.read(); -+ -+ return new Date((b64 << 56) + -+ (b56 << 48) + -+ (b48 << 40) + -+ (b40 << 32) + -+ (b32 << 24) + -+ (b24 << 16) + -+ (b16 << 8) + -+ b8); -+ } -+ -+ case 'S': -+ case 'X': { -+ int b16 = is.read(); -+ int b8 = is.read(); -+ -+ int len = (b16 << 8) + b8; -+ -+ return readStringImpl(len); -+ } -+ -+ case 'B': { -+ if (tag != 'B') -+ throw expect("bytes", tag); -+ -+ int b16 = is.read(); -+ int b8 = is.read(); -+ -+ int len = (b16 << 8) + b8; -+ -+ ByteArrayOutputStream bos = new ByteArrayOutputStream(); -+ -+ for (int i = 0; i < len; i++) -+ bos.write(is.read()); -+ -+ return bos.toByteArray(); -+ } -+ default: -+ throw new IOException("unknown code:" + (char) tag); -+ } -+ } -+ -+ /** -+ * Reads a string from the underlying stream. -+ */ -+ protected String readStringImpl(int length) -+ throws IOException -+ { -+ StringBuffer sb = new StringBuffer(); -+ -+ for (int i = 0; i < length; i++) { -+ int ch = is.read(); -+ -+ if (ch < 0x80) -+ sb.append((char) ch); -+ else if ((ch & 0xe0) == 0xc0) { -+ int ch1 = is.read(); -+ int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); -+ -+ sb.append((char) v); -+ } -+ else if ((ch & 0xf0) == 0xe0) { -+ int ch1 = is.read(); -+ int ch2 = is.read(); -+ int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); -+ -+ sb.append((char) v); -+ } -+ else -+ throw new IOException("bad utf-8 encoding"); -+ } -+ -+ return sb.toString(); -+ } -+ -+ protected IOException expect(String expect, int ch) -+ { -+ if (ch < 0) -+ return protocolException("expected " + expect + " at end of file"); -+ else -+ return protocolException("expected " + expect + " at " + (char) ch); -+ } -+ -+ protected IOException protocolException(String message) -+ { -+ return new IOException(message); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianOutput.java hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianOutput.java ---- hessian-4.0.65-src/com/caucho/hessian/micro/MicroHessianOutput.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/micro/MicroHessianOutput.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,550 +1,550 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.micro; -- --import java.io.IOException; --import java.io.OutputStream; --import java.util.Date; --import java.util.Enumeration; --import java.util.Hashtable; --import java.util.Vector; -- --/** -- * Output stream for Hessian requests, compatible with microedition -- * Java. It only uses classes and types available to J2ME. In -- * particular, it does not have any support for the <double> type. -- * -- *

MicroHessianOutput does not depend on any classes other than -- * in J2ME, so it can be extracted independently into a smaller package. -- * -- *

MicroHessianOutput is unbuffered, so any client needs to provide -- * its own buffering. -- * -- *

-- * OutputStream os = ...; // from http connection
-- * MicroHessianOutput out = new MicroHessianOutput(os);
-- * String value;
-- *
-- * out.startCall("hello");  // start hello call
-- * out.writeString("arg1"); // write a string argument
-- * out.completeCall();      // complete the call
-- * 
-- */ --public class MicroHessianOutput { -- protected OutputStream os; -- -- /** -- * Creates a new Hessian output stream, initialized with an -- * underlying output stream. -- * -- * @param os the underlying output stream. -- */ -- public MicroHessianOutput(OutputStream os) -- { -- init(os); -- } -- -- /** -- * Creates an uninitialized Hessian output stream. -- */ -- public MicroHessianOutput() -- { -- } -- -- public void init(OutputStream os) -- { -- this.os = os; -- } -- -- /** -- * Writes the method call: -- * -- *
--   * c major minor
--   * m b16 b8 method-namek
--   * 
-- * -- * @param method the method name to call. -- */ -- public void startCall(String method) -- throws IOException -- { -- os.write('c'); -- os.write(0); -- os.write(1); -- -- os.write('m'); -- int len = method.length(); -- os.write(len >> 8); -- os.write(len); -- printString(method, 0, len); -- } -- -- /** -- * Writes the method call: -- * -- *
--   * z
--   * 
-- */ -- public void completeCall() -- throws IOException -- { -- os.write('z'); -- } -- -- /** -- * Writes a boolean value to the stream. The boolean will be written -- * with the following syntax: -- * -- *
--   * T
--   * F
--   * 
-- * -- * @param value the boolean value to write. -- */ -- public void writeBoolean(boolean value) -- throws IOException -- { -- if (value) -- os.write('T'); -- else -- os.write('F'); -- } -- -- /** -- * Writes an integer value to the stream. The integer will be written -- * with the following syntax: -- * -- *
--   * I b32 b24 b16 b8
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeInt(int value) -- throws IOException -- { -- os.write('I'); -- os.write(value >> 24); -- os.write(value >> 16); -- os.write(value >> 8); -- os.write(value); -- } -- -- /** -- * Writes a long value to the stream. The long will be written -- * with the following syntax: -- * -- *
--   * L b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param value the long value to write. -- */ -- public void writeLong(long value) -- throws IOException -- { -- os.write('L'); -- os.write((byte) (value >> 56)); -- os.write((byte) (value >> 48)); -- os.write((byte) (value >> 40)); -- os.write((byte) (value >> 32)); -- os.write((byte) (value >> 24)); -- os.write((byte) (value >> 16)); -- os.write((byte) (value >> 8)); -- os.write((byte) (value)); -- } -- -- /** -- * Writes a date to the stream. -- * -- *
--   * T  b64 b56 b48 b40 b32 b24 b16 b8
--   * 
-- * -- * @param time the date in milliseconds from the epoch in UTC -- */ -- public void writeUTCDate(long time) -- throws IOException -- { -- os.write('d'); -- os.write((byte) (time >> 56)); -- os.write((byte) (time >> 48)); -- os.write((byte) (time >> 40)); -- os.write((byte) (time >> 32)); -- os.write((byte) (time >> 24)); -- os.write((byte) (time >> 16)); -- os.write((byte) (time >> 8)); -- os.write((byte) (time)); -- } -- -- /** -- * Writes a null value to the stream. -- * The null will be written with the following syntax -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeNull() -- throws IOException -- { -- os.write('N'); -- } -- -- /** -- * Writes a string value to the stream using UTF-8 encoding. -- * The string will be written with the following syntax: -- * -- *
--   * S b16 b8 string-value
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeString(String value) -- throws IOException -- { -- if (value == null) { -- os.write('N'); -- } -- else { -- int len = value.length(); -- -- os.write('S'); -- os.write(len >> 8); -- os.write(len); -- -- printString(value); -- } -- } -- -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer) -- throws IOException -- { -- if (buffer == null) -- os.write('N'); -- else -- writeBytes(buffer, 0, buffer.length); -- } -- /** -- * Writes a byte array to the stream. -- * The array will be written with the following syntax: -- * -- *
--   * B b16 b18 bytes
--   * 
-- * -- * If the value is null, it will be written as -- * -- *
--   * N
--   * 
-- * -- * @param value the string value to write. -- */ -- public void writeBytes(byte []buffer, int offset, int length) -- throws IOException -- { -- if (buffer == null) { -- os.write('N'); -- } -- else { -- os.write('B'); -- os.write(length << 8); -- os.write(length); -- os.write(buffer, offset, length); -- } -- } -- -- /** -- * Writes a reference. -- * -- *
--   * R b32 b24 b16 b8
--   * 
-- * -- * @param value the integer value to write. -- */ -- public void writeRef(int value) -- throws IOException -- { -- os.write('R'); -- os.write(value << 24); -- os.write(value << 16); -- os.write(value << 8); -- os.write(value); -- } -- -- /** -- * Writes a generic object to the output stream. -- */ -- public void writeObject(Object object) -- throws IOException -- { -- if (object == null) -- writeNull(); -- else if (object instanceof String) -- writeString((String) object); -- else if (object instanceof Boolean) -- writeBoolean(((Boolean) object).booleanValue()); -- else if (object instanceof Integer) -- writeInt(((Integer) object).intValue()); -- else if (object instanceof Long) -- writeLong(((Long) object).longValue()); -- else if (object instanceof Date) -- writeUTCDate(((Date) object).getTime()); -- else if (object instanceof byte[]) { -- byte []data = (byte []) object; -- writeBytes(data, 0, data.length); -- } -- else if (object instanceof Vector) { -- Vector vector = (Vector) object; -- -- int size = vector.size(); -- writeListBegin(size, null); -- for (int i = 0; i < size; i++) -- writeObject(vector.elementAt(i)); -- -- writeListEnd(); -- } -- else if (object instanceof Hashtable) { -- Hashtable hashtable = (Hashtable) object; -- -- writeMapBegin(null); -- Enumeration e = hashtable.keys(); -- while (e.hasMoreElements()) { -- Object key = e.nextElement(); -- Object value = hashtable.get(key); -- -- writeObject(key); -- writeObject(value); -- } -- writeMapEnd(); -- } -- else -- writeCustomObject(object); -- } -- -- /** -- * Applications which override this can do custom serialization. -- * -- * @param object the object to write. -- */ -- public void writeCustomObject(Object object) -- throws IOException -- { -- throw new IOException("unexpected object: " + object); -- } -- -- /** -- * Writes the list header to the stream. List writers will call -- * writeListBegin followed by the list contents and then -- * call writeListEnd. -- * -- *
--   * <list>
--   *   <type>java.util.ArrayList</type>
--   *   <length>3</length>
--   *   <int>1</int>
--   *   <int>2</int>
--   *   <int>3</int>
--   * </list>
--   * 
-- */ -- public void writeListBegin(int length, String type) -- throws IOException -- { -- os.write('V'); -- os.write('t'); -- printLenString(type); -- -- os.write('l'); -- os.write(length >> 24); -- os.write(length >> 16); -- os.write(length >> 8); -- os.write(length); -- } -- -- /** -- * Writes the tail of the list to the stream. -- */ -- public void writeListEnd() -- throws IOException -- { -- os.write('z'); -- } -- -- /** -- * Writes the map header to the stream. Map writers will call -- * writeMapBegin followed by the map contents and then -- * call writeMapEnd. -- * -- *
--   * Mt b16 b8 type ( )z
--   * 
-- */ -- public void writeMapBegin(String type) -- throws IOException -- { -- os.write('M'); -- os.write('t'); -- printLenString(type); -- } -- -- /** -- * Writes the tail of the map to the stream. -- */ -- public void writeMapEnd() -- throws IOException -- { -- os.write('z'); -- } -- -- /** -- * Writes a remote object reference to the stream. The type is the -- * type of the remote interface. -- * -- *
--   * 'r' 't' b16 b8 type url
--   * 
-- */ -- public void writeRemote(String type, String url) -- throws IOException -- { -- os.write('r'); -- os.write('t'); -- printLenString(type); -- os.write('S'); -- printLenString(url); -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 with preceeding length -- * -- * @param v the string to print. -- */ -- public void printLenString(String v) -- throws IOException -- { -- if (v == null) { -- os.write(0); -- os.write(0); -- } -- else { -- int len = v.length(); -- os.write(len >> 8); -- os.write(len); -- -- printString(v, 0, len); -- } -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v) -- throws IOException -- { -- printString(v, 0, v.length()); -- } -- -- /** -- * Prints a string to the stream, encoded as UTF-8 -- * -- * @param v the string to print. -- */ -- public void printString(String v, int offset, int length) -- throws IOException -- { -- for (int i = 0; i < length; i++) { -- char ch = v.charAt(i + offset); -- -- if (ch < 0x80) -- os.write(ch); -- else if (ch < 0x800) { -- os.write(0xc0 + ((ch >> 6) & 0x1f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- else { -- os.write(0xe0 + ((ch >> 12) & 0xf)); -- os.write(0x80 + ((ch >> 6) & 0x3f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.micro; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+import java.util.Date; -+import java.util.Enumeration; -+import java.util.Hashtable; -+import java.util.Vector; -+ -+/** -+ * Output stream for Hessian requests, compatible with microedition -+ * Java. It only uses classes and types available to J2ME. In -+ * particular, it does not have any support for the <double> type. -+ * -+ *

MicroHessianOutput does not depend on any classes other than -+ * in J2ME, so it can be extracted independently into a smaller package. -+ * -+ *

MicroHessianOutput is unbuffered, so any client needs to provide -+ * its own buffering. -+ * -+ *

-+ * OutputStream os = ...; // from http connection
-+ * MicroHessianOutput out = new MicroHessianOutput(os);
-+ * String value;
-+ *
-+ * out.startCall("hello");  // start hello call
-+ * out.writeString("arg1"); // write a string argument
-+ * out.completeCall();      // complete the call
-+ * 
-+ */ -+public class MicroHessianOutput { -+ protected OutputStream os; -+ -+ /** -+ * Creates a new Hessian output stream, initialized with an -+ * underlying output stream. -+ * -+ * @param os the underlying output stream. -+ */ -+ public MicroHessianOutput(OutputStream os) -+ { -+ init(os); -+ } -+ -+ /** -+ * Creates an uninitialized Hessian output stream. -+ */ -+ public MicroHessianOutput() -+ { -+ } -+ -+ public void init(OutputStream os) -+ { -+ this.os = os; -+ } -+ -+ /** -+ * Writes the method call: -+ * -+ *
-+   * c major minor
-+   * m b16 b8 method-namek
-+   * 
-+ * -+ * @param method the method name to call. -+ */ -+ public void startCall(String method) -+ throws IOException -+ { -+ os.write('c'); -+ os.write(0); -+ os.write(1); -+ -+ os.write('m'); -+ int len = method.length(); -+ os.write(len >> 8); -+ os.write(len); -+ printString(method, 0, len); -+ } -+ -+ /** -+ * Writes the method call: -+ * -+ *
-+   * z
-+   * 
-+ */ -+ public void completeCall() -+ throws IOException -+ { -+ os.write('z'); -+ } -+ -+ /** -+ * Writes a boolean value to the stream. The boolean will be written -+ * with the following syntax: -+ * -+ *
-+   * T
-+   * F
-+   * 
-+ * -+ * @param value the boolean value to write. -+ */ -+ public void writeBoolean(boolean value) -+ throws IOException -+ { -+ if (value) -+ os.write('T'); -+ else -+ os.write('F'); -+ } -+ -+ /** -+ * Writes an integer value to the stream. The integer will be written -+ * with the following syntax: -+ * -+ *
-+   * I b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeInt(int value) -+ throws IOException -+ { -+ os.write('I'); -+ os.write(value >> 24); -+ os.write(value >> 16); -+ os.write(value >> 8); -+ os.write(value); -+ } -+ -+ /** -+ * Writes a long value to the stream. The long will be written -+ * with the following syntax: -+ * -+ *
-+   * L b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the long value to write. -+ */ -+ public void writeLong(long value) -+ throws IOException -+ { -+ os.write('L'); -+ os.write((byte) (value >> 56)); -+ os.write((byte) (value >> 48)); -+ os.write((byte) (value >> 40)); -+ os.write((byte) (value >> 32)); -+ os.write((byte) (value >> 24)); -+ os.write((byte) (value >> 16)); -+ os.write((byte) (value >> 8)); -+ os.write((byte) (value)); -+ } -+ -+ /** -+ * Writes a date to the stream. -+ * -+ *
-+   * T  b64 b56 b48 b40 b32 b24 b16 b8
-+   * 
-+ * -+ * @param time the date in milliseconds from the epoch in UTC -+ */ -+ public void writeUTCDate(long time) -+ throws IOException -+ { -+ os.write('d'); -+ os.write((byte) (time >> 56)); -+ os.write((byte) (time >> 48)); -+ os.write((byte) (time >> 40)); -+ os.write((byte) (time >> 32)); -+ os.write((byte) (time >> 24)); -+ os.write((byte) (time >> 16)); -+ os.write((byte) (time >> 8)); -+ os.write((byte) (time)); -+ } -+ -+ /** -+ * Writes a null value to the stream. -+ * The null will be written with the following syntax -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeNull() -+ throws IOException -+ { -+ os.write('N'); -+ } -+ -+ /** -+ * Writes a string value to the stream using UTF-8 encoding. -+ * The string will be written with the following syntax: -+ * -+ *
-+   * S b16 b8 string-value
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeString(String value) -+ throws IOException -+ { -+ if (value == null) { -+ os.write('N'); -+ } -+ else { -+ int len = value.length(); -+ -+ os.write('S'); -+ os.write(len >> 8); -+ os.write(len); -+ -+ printString(value); -+ } -+ } -+ -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer) -+ throws IOException -+ { -+ if (buffer == null) -+ os.write('N'); -+ else -+ writeBytes(buffer, 0, buffer.length); -+ } -+ /** -+ * Writes a byte array to the stream. -+ * The array will be written with the following syntax: -+ * -+ *
-+   * B b16 b18 bytes
-+   * 
-+ * -+ * If the value is null, it will be written as -+ * -+ *
-+   * N
-+   * 
-+ * -+ * @param value the string value to write. -+ */ -+ public void writeBytes(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ if (buffer == null) { -+ os.write('N'); -+ } -+ else { -+ os.write('B'); -+ os.write(length << 8); -+ os.write(length); -+ os.write(buffer, offset, length); -+ } -+ } -+ -+ /** -+ * Writes a reference. -+ * -+ *
-+   * R b32 b24 b16 b8
-+   * 
-+ * -+ * @param value the integer value to write. -+ */ -+ public void writeRef(int value) -+ throws IOException -+ { -+ os.write('R'); -+ os.write(value << 24); -+ os.write(value << 16); -+ os.write(value << 8); -+ os.write(value); -+ } -+ -+ /** -+ * Writes a generic object to the output stream. -+ */ -+ public void writeObject(Object object) -+ throws IOException -+ { -+ if (object == null) -+ writeNull(); -+ else if (object instanceof String) -+ writeString((String) object); -+ else if (object instanceof Boolean) -+ writeBoolean(((Boolean) object).booleanValue()); -+ else if (object instanceof Integer) -+ writeInt(((Integer) object).intValue()); -+ else if (object instanceof Long) -+ writeLong(((Long) object).longValue()); -+ else if (object instanceof Date) -+ writeUTCDate(((Date) object).getTime()); -+ else if (object instanceof byte[]) { -+ byte []data = (byte []) object; -+ writeBytes(data, 0, data.length); -+ } -+ else if (object instanceof Vector) { -+ Vector vector = (Vector) object; -+ -+ int size = vector.size(); -+ writeListBegin(size, null); -+ for (int i = 0; i < size; i++) -+ writeObject(vector.elementAt(i)); -+ -+ writeListEnd(); -+ } -+ else if (object instanceof Hashtable) { -+ Hashtable hashtable = (Hashtable) object; -+ -+ writeMapBegin(null); -+ Enumeration e = hashtable.keys(); -+ while (e.hasMoreElements()) { -+ Object key = e.nextElement(); -+ Object value = hashtable.get(key); -+ -+ writeObject(key); -+ writeObject(value); -+ } -+ writeMapEnd(); -+ } -+ else -+ writeCustomObject(object); -+ } -+ -+ /** -+ * Applications which override this can do custom serialization. -+ * -+ * @param object the object to write. -+ */ -+ public void writeCustomObject(Object object) -+ throws IOException -+ { -+ throw new IOException("unexpected object: " + object); -+ } -+ -+ /** -+ * Writes the list header to the stream. List writers will call -+ * writeListBegin followed by the list contents and then -+ * call writeListEnd. -+ * -+ *
-+   * <list>
-+   *   <type>java.util.ArrayList</type>
-+   *   <length>3</length>
-+   *   <int>1</int>
-+   *   <int>2</int>
-+   *   <int>3</int>
-+   * </list>
-+   * 
-+ */ -+ public void writeListBegin(int length, String type) -+ throws IOException -+ { -+ os.write('V'); -+ os.write('t'); -+ printLenString(type); -+ -+ os.write('l'); -+ os.write(length >> 24); -+ os.write(length >> 16); -+ os.write(length >> 8); -+ os.write(length); -+ } -+ -+ /** -+ * Writes the tail of the list to the stream. -+ */ -+ public void writeListEnd() -+ throws IOException -+ { -+ os.write('z'); -+ } -+ -+ /** -+ * Writes the map header to the stream. Map writers will call -+ * writeMapBegin followed by the map contents and then -+ * call writeMapEnd. -+ * -+ *
-+   * Mt b16 b8 type ( )z
-+   * 
-+ */ -+ public void writeMapBegin(String type) -+ throws IOException -+ { -+ os.write('M'); -+ os.write('t'); -+ printLenString(type); -+ } -+ -+ /** -+ * Writes the tail of the map to the stream. -+ */ -+ public void writeMapEnd() -+ throws IOException -+ { -+ os.write('z'); -+ } -+ -+ /** -+ * Writes a remote object reference to the stream. The type is the -+ * type of the remote interface. -+ * -+ *
-+   * 'r' 't' b16 b8 type url
-+   * 
-+ */ -+ public void writeRemote(String type, String url) -+ throws IOException -+ { -+ os.write('r'); -+ os.write('t'); -+ printLenString(type); -+ os.write('S'); -+ printLenString(url); -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 with preceeding length -+ * -+ * @param v the string to print. -+ */ -+ public void printLenString(String v) -+ throws IOException -+ { -+ if (v == null) { -+ os.write(0); -+ os.write(0); -+ } -+ else { -+ int len = v.length(); -+ os.write(len >> 8); -+ os.write(len); -+ -+ printString(v, 0, len); -+ } -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v) -+ throws IOException -+ { -+ printString(v, 0, v.length()); -+ } -+ -+ /** -+ * Prints a string to the stream, encoded as UTF-8 -+ * -+ * @param v the string to print. -+ */ -+ public void printString(String v, int offset, int length) -+ throws IOException -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = v.charAt(i + offset); -+ -+ if (ch < 0x80) -+ os.write(ch); -+ else if (ch < 0x800) { -+ os.write(0xc0 + ((ch >> 6) & 0x1f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ else { -+ os.write(0xe0 + ((ch >> 12) & 0xf)); -+ os.write(0x80 + ((ch >> 6) & 0x3f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/mux/MuxInputStream.java hessian-4.0.65-fix/com/caucho/hessian/mux/MuxInputStream.java ---- hessian-4.0.65-src/com/caucho/hessian/mux/MuxInputStream.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/mux/MuxInputStream.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,280 +1,280 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.mux; -- --import java.io.IOException; --import java.io.InputStream; -- --/** -- * Input stream to a specific channel. -- */ --public class MuxInputStream extends InputStream { -- private MuxServer server; -- protected InputStream is; -- private int channel; -- -- private String url; -- -- private int chunkLength; -- -- /** -- * Null argument constructor. -- */ -- public MuxInputStream() -- { -- } -- -- /** -- * Initialize the multiplexor with input and output streams. -- */ -- protected void init(MuxServer server, int channel) -- throws IOException -- { -- this.server = server; -- this.channel = channel; -- -- this.url = null; -- -- chunkLength = 0; -- } -- -- /** -- * Gets the raw input stream. Clients will normally not call -- * this. -- */ -- protected InputStream getInputStream() -- throws IOException -- { -- if (is == null && server != null) -- is = server.readChannel(channel); -- -- return is; -- } -- -- void setInputStream(InputStream is) -- { -- this.is = is; -- } -- -- /** -- * Gets the channel of the connection. -- */ -- public int getChannel() -- { -- return channel; -- } -- -- /** -- * Returns the request's URL -- */ -- public String getURL() -- { -- return url; -- } -- -- /** -- * Writes a data byte to the output stream. -- */ -- public int read() -- throws IOException -- { -- if (chunkLength <= 0) { -- readToData(false); -- -- if (chunkLength <= 0) -- return -1; -- } -- -- chunkLength--; -- return is.read(); -- } -- -- /** -- * Complete writing to the stream, closing the channel. -- */ -- public void close() -- throws IOException -- { -- skipToEnd(); -- } -- -- /** -- * Skips data until the end of the channel. -- */ -- private void skipToEnd() -- throws IOException -- { -- InputStream is = getInputStream(); -- -- if (is == null) -- return; -- -- if (chunkLength > 0) -- is.skip(chunkLength); -- -- for (int tag = is.read(); tag >= 0; tag = is.read()) { -- switch (tag) { -- case 'Y': -- server.freeReadLock(); -- this.is = is = server.readChannel(channel); -- if (is == null) { -- this.server = null; -- return; -- } -- break; -- -- case 'Q': -- server.freeReadLock(); -- this.is = null; -- this.server = null; -- return; -- -- case -1: -- server.freeReadLock(); -- this.is = null; -- this.server = null; -- return; -- -- default: -- int length = (is.read() << 8) + is.read(); -- is.skip(length); -- break; -- } -- } -- } -- -- /** -- * Reads tags, until getting data. -- */ -- void readToData(boolean returnOnYield) -- throws IOException -- { -- InputStream is = getInputStream(); -- -- if (is == null) -- return; -- -- for (int tag = is.read(); tag >= 0; tag = is.read()) { -- switch (tag) { -- case 'Y': -- server.freeReadLock(); -- if (returnOnYield) -- return; -- server.readChannel(channel); -- break; -- -- case 'Q': -- server.freeReadLock(); -- this.is = null; -- this.server = null; -- return; -- -- case 'U': -- this.url = readUTF(); -- break; -- -- case 'D': -- chunkLength = (is.read() << 8) + is.read(); -- return; -- -- default: -- readTag(tag); -- break; -- } -- } -- } -- -- /** -- * Subclasses will extend this to read values. -- */ -- protected void readTag(int tag) -- throws IOException -- { -- int length = (is.read() << 8) + is.read(); -- is.skip(length); -- } -- -- /** -- * Reads a UTF-8 string. -- * -- * @return the utf-8 encoded string -- */ -- protected String readUTF() -- throws IOException -- { -- int len = (is.read() << 8) + is.read(); -- -- StringBuffer sb = new StringBuffer(); -- -- while (len > 0) { -- int d1 = is.read(); -- -- if (d1 < 0) -- return sb.toString(); -- else if (d1 < 0x80) { -- len--; -- sb.append((char) d1); -- } -- else if ((d1 & 0xe0) == 0xc0) { -- len -= 2; -- sb.append(((d1 & 0x1f) << 6) + (is.read() & 0x3f)); -- } -- else if ((d1 & 0xf0) == 0xe0) { -- len -= 3; -- sb.append(((d1 & 0x0f) << 12) + -- ((is.read() & 0x3f) << 6) + -- (is.read() & 0x3f)); -- } -- else -- throw new IOException("utf-8 encoding error"); -- } -- -- return sb.toString(); -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.mux; -+ -+import java.io.IOException; -+import java.io.InputStream; -+ -+/** -+ * Input stream to a specific channel. -+ */ -+public class MuxInputStream extends InputStream { -+ private MuxServer server; -+ protected InputStream is; -+ private int channel; -+ -+ private String url; -+ -+ private int chunkLength; -+ -+ /** -+ * Null argument constructor. -+ */ -+ public MuxInputStream() -+ { -+ } -+ -+ /** -+ * Initialize the multiplexor with input and output streams. -+ */ -+ protected void init(MuxServer server, int channel) -+ throws IOException -+ { -+ this.server = server; -+ this.channel = channel; -+ -+ this.url = null; -+ -+ chunkLength = 0; -+ } -+ -+ /** -+ * Gets the raw input stream. Clients will normally not call -+ * this. -+ */ -+ protected InputStream getInputStream() -+ throws IOException -+ { -+ if (is == null && server != null) -+ is = server.readChannel(channel); -+ -+ return is; -+ } -+ -+ void setInputStream(InputStream is) -+ { -+ this.is = is; -+ } -+ -+ /** -+ * Gets the channel of the connection. -+ */ -+ public int getChannel() -+ { -+ return channel; -+ } -+ -+ /** -+ * Returns the request's URL -+ */ -+ public String getURL() -+ { -+ return url; -+ } -+ -+ /** -+ * Writes a data byte to the output stream. -+ */ -+ public int read() -+ throws IOException -+ { -+ if (chunkLength <= 0) { -+ readToData(false); -+ -+ if (chunkLength <= 0) -+ return -1; -+ } -+ -+ chunkLength--; -+ return is.read(); -+ } -+ -+ /** -+ * Complete writing to the stream, closing the channel. -+ */ -+ public void close() -+ throws IOException -+ { -+ skipToEnd(); -+ } -+ -+ /** -+ * Skips data until the end of the channel. -+ */ -+ private void skipToEnd() -+ throws IOException -+ { -+ InputStream is = getInputStream(); -+ -+ if (is == null) -+ return; -+ -+ if (chunkLength > 0) -+ is.skip(chunkLength); -+ -+ for (int tag = is.read(); tag >= 0; tag = is.read()) { -+ switch (tag) { -+ case 'Y': -+ server.freeReadLock(); -+ this.is = is = server.readChannel(channel); -+ if (is == null) { -+ this.server = null; -+ return; -+ } -+ break; -+ -+ case 'Q': -+ server.freeReadLock(); -+ this.is = null; -+ this.server = null; -+ return; -+ -+ case -1: -+ server.freeReadLock(); -+ this.is = null; -+ this.server = null; -+ return; -+ -+ default: -+ int length = (is.read() << 8) + is.read(); -+ is.skip(length); -+ break; -+ } -+ } -+ } -+ -+ /** -+ * Reads tags, until getting data. -+ */ -+ void readToData(boolean returnOnYield) -+ throws IOException -+ { -+ InputStream is = getInputStream(); -+ -+ if (is == null) -+ return; -+ -+ for (int tag = is.read(); tag >= 0; tag = is.read()) { -+ switch (tag) { -+ case 'Y': -+ server.freeReadLock(); -+ if (returnOnYield) -+ return; -+ server.readChannel(channel); -+ break; -+ -+ case 'Q': -+ server.freeReadLock(); -+ this.is = null; -+ this.server = null; -+ return; -+ -+ case 'U': -+ this.url = readUTF(); -+ break; -+ -+ case 'D': -+ chunkLength = (is.read() << 8) + is.read(); -+ return; -+ -+ default: -+ readTag(tag); -+ break; -+ } -+ } -+ } -+ -+ /** -+ * Subclasses will extend this to read values. -+ */ -+ protected void readTag(int tag) -+ throws IOException -+ { -+ int length = (is.read() << 8) + is.read(); -+ is.skip(length); -+ } -+ -+ /** -+ * Reads a UTF-8 string. -+ * -+ * @return the utf-8 encoded string -+ */ -+ protected String readUTF() -+ throws IOException -+ { -+ int len = (is.read() << 8) + is.read(); -+ -+ StringBuffer sb = new StringBuffer(); -+ -+ while (len > 0) { -+ int d1 = is.read(); -+ -+ if (d1 < 0) -+ return sb.toString(); -+ else if (d1 < 0x80) { -+ len--; -+ sb.append((char) d1); -+ } -+ else if ((d1 & 0xe0) == 0xc0) { -+ len -= 2; -+ sb.append(((d1 & 0x1f) << 6) + (is.read() & 0x3f)); -+ } -+ else if ((d1 & 0xf0) == 0xe0) { -+ len -= 3; -+ sb.append(((d1 & 0x0f) << 12) + -+ ((is.read() & 0x3f) << 6) + -+ (is.read() & 0x3f)); -+ } -+ else -+ throw new IOException("utf-8 encoding error"); -+ } -+ -+ return sb.toString(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/mux/MuxOutputStream.java hessian-4.0.65-fix/com/caucho/hessian/mux/MuxOutputStream.java ---- hessian-4.0.65-src/com/caucho/hessian/mux/MuxOutputStream.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/mux/MuxOutputStream.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,236 +1,236 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.mux; -- --import java.io.IOException; --import java.io.OutputStream; -- --/** -- * Output stream to a specific channel. -- */ --public class MuxOutputStream extends OutputStream { -- private MuxServer server; -- private int channel; -- private OutputStream os; -- -- /** -- * Null argument constructor. -- */ -- public MuxOutputStream() -- { -- } -- -- /** -- * Initialize the multiplexor with input and output streams. -- */ -- protected void init(MuxServer server, int channel) -- throws IOException -- { -- this.server = server; -- this.channel = channel; -- this.os = null; -- } -- -- /** -- * Gets the raw output stream. Clients will normally not call -- * this. -- */ -- protected OutputStream getOutputStream() -- throws IOException -- { -- if (os == null && server != null) -- os = server.writeChannel(channel); -- -- return os; -- } -- -- /** -- * Gets the channel of the connection. -- */ -- public int getChannel() -- { -- return channel; -- } -- -- /** -- * Writes a URL to the stream. -- */ -- public void writeURL(String url) -- throws IOException -- { -- writeUTF('U', url); -- } -- -- /** -- * Writes a data byte to the output stream. -- */ -- public void write(int ch) -- throws IOException -- { -- OutputStream os = getOutputStream(); -- -- os.write('D'); -- os.write(0); -- os.write(1); -- os.write(ch); -- } -- -- /** -- * Writes data to the output stream. -- */ -- public void write(byte []buffer, int offset, int length) -- throws IOException -- { -- OutputStream os = getOutputStream(); -- -- for (; length > 0x8000; length -= 0x8000) { -- os.write('D'); -- os.write(0x80); -- os.write(0x00); -- os.write(buffer, offset, 0x8000); -- -- offset += 0x8000; -- } -- -- os.write('D'); -- os.write(length >> 8); -- os.write(length); -- os.write(buffer, offset, length); -- } -- -- /** -- * Flush data to the output stream. -- */ -- public void yield() -- throws IOException -- { -- OutputStream os = this.os; -- this.os = null; -- -- if (os != null) -- server.yield(channel); -- } -- -- /** -- * Flush data to the output stream. -- */ -- public void flush() -- throws IOException -- { -- OutputStream os = this.os; -- this.os = null; -- -- if (os != null) -- server.flush(channel); -- } -- -- /** -- * Complete writing to the stream, closing the channel. -- */ -- public void close() -- throws IOException -- { -- if (server != null) { -- OutputStream os = getOutputStream(); -- this.os = null; -- -- MuxServer server = this.server; -- this.server = null; -- -- server.close(channel); -- } -- } -- -- /** -- * Writes a UTF-8 string. -- * -- * @param code the HMUX code identifying the string -- * @param string the string to write -- */ -- protected void writeUTF(int code, String string) -- throws IOException -- { -- OutputStream os = getOutputStream(); -- -- os.write(code); -- -- int charLength = string.length(); -- -- int length = 0; -- for (int i = 0; i < charLength; i++) { -- char ch = string.charAt(i); -- -- if (ch < 0x80) -- length++; -- else if (ch < 0x800) -- length += 2; -- else -- length += 3; -- } -- -- os.write(length >> 8); -- os.write(length); -- -- for (int i = 0; i < length; i++) { -- char ch = string.charAt(i); -- -- if (ch < 0x80) -- os.write(ch); -- else if (ch < 0x800) { -- os.write(0xc0 + (ch >> 6) & 0x1f); -- os.write(0x80 + (ch & 0x3f)); -- } -- else { -- os.write(0xe0 + (ch >> 12) & 0xf); -- os.write(0x80 + ((ch >> 6) & 0x3f)); -- os.write(0x80 + (ch & 0x3f)); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.mux; -+ -+import java.io.IOException; -+import java.io.OutputStream; -+ -+/** -+ * Output stream to a specific channel. -+ */ -+public class MuxOutputStream extends OutputStream { -+ private MuxServer server; -+ private int channel; -+ private OutputStream os; -+ -+ /** -+ * Null argument constructor. -+ */ -+ public MuxOutputStream() -+ { -+ } -+ -+ /** -+ * Initialize the multiplexor with input and output streams. -+ */ -+ protected void init(MuxServer server, int channel) -+ throws IOException -+ { -+ this.server = server; -+ this.channel = channel; -+ this.os = null; -+ } -+ -+ /** -+ * Gets the raw output stream. Clients will normally not call -+ * this. -+ */ -+ protected OutputStream getOutputStream() -+ throws IOException -+ { -+ if (os == null && server != null) -+ os = server.writeChannel(channel); -+ -+ return os; -+ } -+ -+ /** -+ * Gets the channel of the connection. -+ */ -+ public int getChannel() -+ { -+ return channel; -+ } -+ -+ /** -+ * Writes a URL to the stream. -+ */ -+ public void writeURL(String url) -+ throws IOException -+ { -+ writeUTF('U', url); -+ } -+ -+ /** -+ * Writes a data byte to the output stream. -+ */ -+ public void write(int ch) -+ throws IOException -+ { -+ OutputStream os = getOutputStream(); -+ -+ os.write('D'); -+ os.write(0); -+ os.write(1); -+ os.write(ch); -+ } -+ -+ /** -+ * Writes data to the output stream. -+ */ -+ public void write(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ OutputStream os = getOutputStream(); -+ -+ for (; length > 0x8000; length -= 0x8000) { -+ os.write('D'); -+ os.write(0x80); -+ os.write(0x00); -+ os.write(buffer, offset, 0x8000); -+ -+ offset += 0x8000; -+ } -+ -+ os.write('D'); -+ os.write(length >> 8); -+ os.write(length); -+ os.write(buffer, offset, length); -+ } -+ -+ /** -+ * Flush data to the output stream. -+ */ -+ public void yield() -+ throws IOException -+ { -+ OutputStream os = this.os; -+ this.os = null; -+ -+ if (os != null) -+ server.yield(channel); -+ } -+ -+ /** -+ * Flush data to the output stream. -+ */ -+ public void flush() -+ throws IOException -+ { -+ OutputStream os = this.os; -+ this.os = null; -+ -+ if (os != null) -+ server.flush(channel); -+ } -+ -+ /** -+ * Complete writing to the stream, closing the channel. -+ */ -+ public void close() -+ throws IOException -+ { -+ if (server != null) { -+ OutputStream os = getOutputStream(); -+ this.os = null; -+ -+ MuxServer server = this.server; -+ this.server = null; -+ -+ server.close(channel); -+ } -+ } -+ -+ /** -+ * Writes a UTF-8 string. -+ * -+ * @param code the HMUX code identifying the string -+ * @param string the string to write -+ */ -+ protected void writeUTF(int code, String string) -+ throws IOException -+ { -+ OutputStream os = getOutputStream(); -+ -+ os.write(code); -+ -+ int charLength = string.length(); -+ -+ int length = 0; -+ for (int i = 0; i < charLength; i++) { -+ char ch = string.charAt(i); -+ -+ if (ch < 0x80) -+ length++; -+ else if (ch < 0x800) -+ length += 2; -+ else -+ length += 3; -+ } -+ -+ os.write(length >> 8); -+ os.write(length); -+ -+ for (int i = 0; i < length; i++) { -+ char ch = string.charAt(i); -+ -+ if (ch < 0x80) -+ os.write(ch); -+ else if (ch < 0x800) { -+ os.write(0xc0 + (ch >> 6) & 0x1f); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ else { -+ os.write(0xe0 + (ch >> 12) & 0xf); -+ os.write(0x80 + ((ch >> 6) & 0x3f)); -+ os.write(0x80 + (ch & 0x3f)); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/mux/MuxServer.java hessian-4.0.65-fix/com/caucho/hessian/mux/MuxServer.java ---- hessian-4.0.65-src/com/caucho/hessian/mux/MuxServer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/mux/MuxServer.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,383 +1,383 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.mux; -- --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; -- --/** -- * Hessian Mux, a peer-to-peer protocol. -- */ --public class MuxServer { -- private Object READ_LOCK = new Object(); -- private Object WRITE_LOCK = new Object(); -- -- private InputStream is; -- private OutputStream os; -- private boolean isClient; -- -- private transient boolean isClosed; -- -- // channels that have data ready. -- private boolean inputReady[] = new boolean[4]; -- -- // true if there's a thread already reading -- private boolean isReadLocked; -- // true if there's a thread already writing -- private boolean isWriteLocked; -- -- /** -- * Null argument constructor. -- */ -- public MuxServer() -- { -- } -- -- /** -- * Create a new multiplexor with input and output streams. -- * -- * @param is the underlying input stream -- * @param os the underlying output stream -- * @param isClient true if this is the connection client. -- */ -- public MuxServer(InputStream is, OutputStream os, boolean isClient) -- { -- init(is, os, isClient); -- } -- -- /** -- * Initialize the multiplexor with input and output streams. -- * -- * @param is the underlying input stream -- * @param os the underlying output stream -- * @param isClient true if this is the connection client. -- */ -- public void init(InputStream is, OutputStream os, boolean isClient) -- { -- this.is = is; -- this.os = os; -- this.isClient = isClient; -- } -- -- /** -- * Gets the raw input stream. Clients will normally not call -- * this. -- */ -- public InputStream getInputStream() -- { -- return is; -- } -- -- /** -- * Gets the raw output stream. Clients will normally not call -- * this. -- */ -- public OutputStream getOutputStream() -- { -- return os; -- } -- -- /** -- * Starts a client call. -- */ -- public boolean startCall(MuxInputStream in, MuxOutputStream out) -- throws IOException -- { -- int channel = isClient ? 2 : 3; -- -- return startCall(channel, in, out); -- } -- -- /** -- * Starts a client call. -- */ -- public boolean startCall(int channel, MuxInputStream in, MuxOutputStream out) -- throws IOException -- { -- // XXX: Eventually need to check to see if the channel is used. -- // It's not clear whether this should cause a wait or an exception. -- -- in.init(this, channel); -- out.init(this, channel); -- -- return true; -- } -- -- /** -- * Reads a server request. -- */ -- public boolean readRequest(MuxInputStream in, MuxOutputStream out) -- throws IOException -- { -- int channel = isClient ? 3 : 2; -- -- in.init(this, channel); -- out.init(this, channel); -- -- if (readChannel(channel) != null) { -- in.setInputStream(is); -- in.readToData(false); -- return true; -- } -- else -- return false; -- } -- -- /** -- * Grabs the channel for writing. -- * -- * @param channel the channel -- * -- * @return true if the channel has permission to write. -- */ -- OutputStream writeChannel(int channel) -- throws IOException -- { -- while (os != null) { -- boolean canWrite = false; -- synchronized (WRITE_LOCK) { -- if (! isWriteLocked) { -- isWriteLocked = true; -- canWrite = true; -- } -- else { -- try { -- WRITE_LOCK.wait(5000); -- } catch (Exception e) { -- } -- } -- } -- -- if (canWrite) { -- os.write('C'); -- os.write(channel >> 8); -- os.write(channel); -- -- return os; -- } -- } -- -- return null; -- } -- -- void yield(int channel) -- throws IOException -- { -- os.write('Y'); -- freeWriteLock(); -- } -- -- void flush(int channel) -- throws IOException -- { -- os.write('Y'); -- os.flush(); -- freeWriteLock(); -- } -- -- void close(int channel) -- throws IOException -- { -- if (os != null) { -- os.write('Q'); -- os.flush(); -- freeWriteLock(); -- } -- } -- -- /** -- * Frees the channel for writing. -- */ -- void freeWriteLock() -- { -- synchronized (WRITE_LOCK) { -- isWriteLocked = false; -- WRITE_LOCK.notifyAll(); -- } -- } -- -- /** -- * Reads data from a channel. -- * -- * @param channel the channel -- * -- * @return true if the channel is valid. -- */ -- InputStream readChannel(int channel) -- throws IOException -- { -- while (! isClosed) { -- if (inputReady[channel]) { -- inputReady[channel] = false; -- return is; -- } -- -- boolean canRead = false; -- synchronized (READ_LOCK) { -- if (! isReadLocked) { -- isReadLocked = true; -- canRead = true; -- } -- else { -- try { -- READ_LOCK.wait(5000); -- } catch (Exception e) { -- } -- } -- } -- -- if (canRead) { -- try { -- readData(); -- } catch (IOException e) { -- close(); -- } -- } -- } -- -- return null; -- } -- -- boolean getReadLock() -- { -- synchronized (READ_LOCK) { -- if (! isReadLocked) { -- isReadLocked = true; -- return true; -- } -- else { -- try { -- READ_LOCK.wait(5000); -- } catch (Exception e) { -- } -- } -- } -- -- return false; -- } -- -- /** -- * Frees the channel for reading. -- */ -- void freeReadLock() -- { -- synchronized (READ_LOCK) { -- isReadLocked = false; -- READ_LOCK.notifyAll(); -- } -- } -- -- /** -- * Reads data until a channel packet 'C' or error 'E' is received. -- */ -- private void readData() -- throws IOException -- { -- while (! isClosed) { -- int code = is.read(); -- -- switch (code) { -- case ' ': -- case '\t': -- case '\n': -- case '\r': -- break; -- -- case 'C': { -- int channel = (is.read() << 8) + is.read(); -- -- inputReady[channel] = true; -- return; -- } -- -- case 'E': { -- int channel = (is.read() << 8) + is.read(); -- int status = (is.read() << 8) + is.read(); -- -- inputReady[channel] = true; -- -- return; -- } -- -- case -1: -- close(); -- return; -- -- default: -- // An error in the protocol. Kill the connection. -- close(); -- return; -- } -- } -- -- return; -- } -- -- /** -- * Close the mux -- */ -- public void close() -- throws IOException -- { -- isClosed = true; -- -- OutputStream os = this.os; -- this.os = null; -- -- InputStream is = this.is; -- this.is = null; -- -- if (os != null) -- os.close(); -- -- if (is != null) -- is.close(); -- } --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.mux; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+ -+/** -+ * Hessian Mux, a peer-to-peer protocol. -+ */ -+public class MuxServer { -+ private Object READ_LOCK = new Object(); -+ private Object WRITE_LOCK = new Object(); -+ -+ private InputStream is; -+ private OutputStream os; -+ private boolean isClient; -+ -+ private transient boolean isClosed; -+ -+ // channels that have data ready. -+ private boolean inputReady[] = new boolean[4]; -+ -+ // true if there's a thread already reading -+ private boolean isReadLocked; -+ // true if there's a thread already writing -+ private boolean isWriteLocked; -+ -+ /** -+ * Null argument constructor. -+ */ -+ public MuxServer() -+ { -+ } -+ -+ /** -+ * Create a new multiplexor with input and output streams. -+ * -+ * @param is the underlying input stream -+ * @param os the underlying output stream -+ * @param isClient true if this is the connection client. -+ */ -+ public MuxServer(InputStream is, OutputStream os, boolean isClient) -+ { -+ init(is, os, isClient); -+ } -+ -+ /** -+ * Initialize the multiplexor with input and output streams. -+ * -+ * @param is the underlying input stream -+ * @param os the underlying output stream -+ * @param isClient true if this is the connection client. -+ */ -+ public void init(InputStream is, OutputStream os, boolean isClient) -+ { -+ this.is = is; -+ this.os = os; -+ this.isClient = isClient; -+ } -+ -+ /** -+ * Gets the raw input stream. Clients will normally not call -+ * this. -+ */ -+ public InputStream getInputStream() -+ { -+ return is; -+ } -+ -+ /** -+ * Gets the raw output stream. Clients will normally not call -+ * this. -+ */ -+ public OutputStream getOutputStream() -+ { -+ return os; -+ } -+ -+ /** -+ * Starts a client call. -+ */ -+ public boolean startCall(MuxInputStream in, MuxOutputStream out) -+ throws IOException -+ { -+ int channel = isClient ? 2 : 3; -+ -+ return startCall(channel, in, out); -+ } -+ -+ /** -+ * Starts a client call. -+ */ -+ public boolean startCall(int channel, MuxInputStream in, MuxOutputStream out) -+ throws IOException -+ { -+ // XXX: Eventually need to check to see if the channel is used. -+ // It's not clear whether this should cause a wait or an exception. -+ -+ in.init(this, channel); -+ out.init(this, channel); -+ -+ return true; -+ } -+ -+ /** -+ * Reads a server request. -+ */ -+ public boolean readRequest(MuxInputStream in, MuxOutputStream out) -+ throws IOException -+ { -+ int channel = isClient ? 3 : 2; -+ -+ in.init(this, channel); -+ out.init(this, channel); -+ -+ if (readChannel(channel) != null) { -+ in.setInputStream(is); -+ in.readToData(false); -+ return true; -+ } -+ else -+ return false; -+ } -+ -+ /** -+ * Grabs the channel for writing. -+ * -+ * @param channel the channel -+ * -+ * @return true if the channel has permission to write. -+ */ -+ OutputStream writeChannel(int channel) -+ throws IOException -+ { -+ while (os != null) { -+ boolean canWrite = false; -+ synchronized (WRITE_LOCK) { -+ if (! isWriteLocked) { -+ isWriteLocked = true; -+ canWrite = true; -+ } -+ else { -+ try { -+ WRITE_LOCK.wait(5000); -+ } catch (Exception e) { -+ } -+ } -+ } -+ -+ if (canWrite) { -+ os.write('C'); -+ os.write(channel >> 8); -+ os.write(channel); -+ -+ return os; -+ } -+ } -+ -+ return null; -+ } -+ -+ void yield(int channel) -+ throws IOException -+ { -+ os.write('Y'); -+ freeWriteLock(); -+ } -+ -+ void flush(int channel) -+ throws IOException -+ { -+ os.write('Y'); -+ os.flush(); -+ freeWriteLock(); -+ } -+ -+ void close(int channel) -+ throws IOException -+ { -+ if (os != null) { -+ os.write('Q'); -+ os.flush(); -+ freeWriteLock(); -+ } -+ } -+ -+ /** -+ * Frees the channel for writing. -+ */ -+ void freeWriteLock() -+ { -+ synchronized (WRITE_LOCK) { -+ isWriteLocked = false; -+ WRITE_LOCK.notifyAll(); -+ } -+ } -+ -+ /** -+ * Reads data from a channel. -+ * -+ * @param channel the channel -+ * -+ * @return true if the channel is valid. -+ */ -+ InputStream readChannel(int channel) -+ throws IOException -+ { -+ while (! isClosed) { -+ if (inputReady[channel]) { -+ inputReady[channel] = false; -+ return is; -+ } -+ -+ boolean canRead = false; -+ synchronized (READ_LOCK) { -+ if (! isReadLocked) { -+ isReadLocked = true; -+ canRead = true; -+ } -+ else { -+ try { -+ READ_LOCK.wait(5000); -+ } catch (Exception e) { -+ } -+ } -+ } -+ -+ if (canRead) { -+ try { -+ readData(); -+ } catch (IOException e) { -+ close(); -+ } -+ } -+ } -+ -+ return null; -+ } -+ -+ boolean getReadLock() -+ { -+ synchronized (READ_LOCK) { -+ if (! isReadLocked) { -+ isReadLocked = true; -+ return true; -+ } -+ else { -+ try { -+ READ_LOCK.wait(5000); -+ } catch (Exception e) { -+ } -+ } -+ } -+ -+ return false; -+ } -+ -+ /** -+ * Frees the channel for reading. -+ */ -+ void freeReadLock() -+ { -+ synchronized (READ_LOCK) { -+ isReadLocked = false; -+ READ_LOCK.notifyAll(); -+ } -+ } -+ -+ /** -+ * Reads data until a channel packet 'C' or error 'E' is received. -+ */ -+ private void readData() -+ throws IOException -+ { -+ while (! isClosed) { -+ int code = is.read(); -+ -+ switch (code) { -+ case ' ': -+ case '\t': -+ case '\n': -+ case '\r': -+ break; -+ -+ case 'C': { -+ int channel = (is.read() << 8) + is.read(); -+ -+ inputReady[channel] = true; -+ return; -+ } -+ -+ case 'E': { -+ int channel = (is.read() << 8) + is.read(); -+ int status = (is.read() << 8) + is.read(); -+ -+ inputReady[channel] = true; -+ -+ return; -+ } -+ -+ case -1: -+ close(); -+ return; -+ -+ default: -+ // An error in the protocol. Kill the connection. -+ close(); -+ return; -+ } -+ } -+ -+ return; -+ } -+ -+ /** -+ * Close the mux -+ */ -+ public void close() -+ throws IOException -+ { -+ isClosed = true; -+ -+ OutputStream os = this.os; -+ this.os = null; -+ -+ InputStream is = this.is; -+ this.is = null; -+ -+ if (os != null) -+ os.close(); -+ -+ if (is != null) -+ is.close(); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/security/X509Encryption.java hessian-4.0.65-fix/com/caucho/hessian/security/X509Encryption.java ---- hessian-4.0.65-src/com/caucho/hessian/security/X509Encryption.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/security/X509Encryption.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,380 +1,380 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.security; -- --import java.security.*; --import java.security.cert.*; --import java.util.*; --import javax.crypto.*; -- --import java.io.*; -- --import com.caucho.hessian.io.*; -- --public class X509Encryption extends HessianEnvelope { -- private String _algorithm = "AES"; -- -- // certificate for encryption/decryption -- private X509Certificate _cert; -- -- // private key for decryption -- private PrivateKey _privateKey; -- -- private SecureRandom _secureRandom; -- -- public X509Encryption() -- { -- } -- -- /** -- * Sets the encryption algorithm for the content. -- */ -- public void setAlgorithm(String algorithm) -- { -- if (algorithm == null) -- throw new NullPointerException(); -- -- _algorithm = algorithm; -- } -- -- /** -- * Gets the encryption algorithm for the content. -- */ -- public String getAlgorithm() -- { -- return _algorithm; -- } -- -- /** -- * The X509 certificate to obtain the public key of the recipient. -- */ -- public X509Certificate getCertificate() -- { -- return _cert; -- } -- -- /** -- * The X509 certificate to obtain the public key of the recipient. -- */ -- public void setCertificate(X509Certificate cert) -- { -- _cert = cert; -- } -- -- /** -- * The private key for decryption. -- */ -- public PrivateKey getPrivateKey() -- { -- return _privateKey; -- } -- -- /** -- * The X509 certificate to obtain the public key of the recipient. -- */ -- public void setPrivateKey(PrivateKey privateKey) -- { -- _privateKey = privateKey; -- } -- -- /** -- * The random number generator for the shared secrets. -- */ -- public SecureRandom getSecureRandom() -- { -- return _secureRandom; -- } -- -- /** -- * The random number generator for the shared secrets. -- */ -- public void setSecureRandom(SecureRandom random) -- { -- _secureRandom = random; -- } -- -- public Hessian2Output wrap(Hessian2Output out) -- throws IOException -- { -- if (_cert == null) -- throw new IOException("X509Encryption.wrap requires a certificate"); -- -- OutputStream os = new EncryptOutputStream(out); -- -- Hessian2Output filterOut = new Hessian2Output(os); -- -- filterOut.setCloseStreamOnClose(true); -- -- return filterOut; -- } -- -- public Hessian2Input unwrap(Hessian2Input in) -- throws IOException -- { -- if (_privateKey == null) -- throw new IOException("X509Encryption.unwrap requires a private key"); -- -- if (_cert == null) -- throw new IOException("X509Encryption.unwrap requires a certificate"); -- -- int version = in.readEnvelope(); -- -- String method = in.readMethod(); -- -- if (! method.equals(getClass().getName())) -- throw new IOException("expected hessian Envelope method '" + -- getClass().getName() + "' at '" + method + "'"); -- -- return unwrapHeaders(in); -- } -- -- public Hessian2Input unwrapHeaders(Hessian2Input in) -- throws IOException -- { -- if (_privateKey == null) -- throw new IOException("X509Encryption.unwrap requires a private key"); -- -- if (_cert == null) -- throw new IOException("X509Encryption.unwrap requires a certificate"); -- -- InputStream is = new EncryptInputStream(in); -- -- Hessian2Input filter = new Hessian2Input(is); -- -- filter.setCloseStreamOnClose(true); -- -- return filter; -- } -- -- class EncryptOutputStream extends OutputStream { -- private Hessian2Output _out; -- -- private Cipher _cipher; -- private OutputStream _bodyOut; -- private CipherOutputStream _cipherOut; -- -- EncryptOutputStream(Hessian2Output out) -- throws IOException -- { -- try { -- _out = out; -- -- KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); -- -- if (_secureRandom != null) -- keyGen.init(_secureRandom); -- -- SecretKey sharedKey = keyGen.generateKey(); -- -- _out = out; -- -- _out.startEnvelope(X509Encryption.class.getName()); -- -- PublicKey publicKey = _cert.getPublicKey(); -- -- byte []encoded = publicKey.getEncoded(); -- MessageDigest md = MessageDigest.getInstance("SHA1"); -- md.update(encoded); -- byte []fingerprint = md.digest(); -- -- String keyAlgorithm = publicKey.getAlgorithm(); -- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -- if (_secureRandom != null) -- keyCipher.init(Cipher.WRAP_MODE, _cert, _secureRandom); -- else -- keyCipher.init(Cipher.WRAP_MODE, _cert); -- -- byte []encKey = keyCipher.wrap(sharedKey); -- -- _out.writeInt(4); -- -- _out.writeString("algorithm"); -- _out.writeString(_algorithm); -- _out.writeString("fingerprint"); -- _out.writeBytes(fingerprint); -- _out.writeString("key-algorithm"); -- _out.writeString(keyAlgorithm); -- _out.writeString("key"); -- _out.writeBytes(encKey); -- -- _bodyOut = _out.getBytesOutputStream(); -- -- _cipher = Cipher.getInstance(_algorithm); -- if (_secureRandom != null) -- _cipher.init(Cipher.ENCRYPT_MODE, sharedKey, _secureRandom); -- else -- _cipher.init(Cipher.ENCRYPT_MODE, sharedKey); -- -- _cipherOut = new CipherOutputStream(_bodyOut, _cipher); -- } catch (RuntimeException e) { -- throw e; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- public void write(int ch) -- throws IOException -- { -- _cipherOut.write(ch); -- } -- -- public void write(byte []buffer, int offset, int length) -- throws IOException -- { -- _cipherOut.write(buffer, offset, length); -- } -- -- public void close() -- throws IOException -- { -- Hessian2Output out = _out; -- _out = null; -- -- if (out != null) { -- _cipherOut.close(); -- _bodyOut.close(); -- -- out.writeInt(0); -- out.completeEnvelope(); -- out.close(); -- } -- } -- } -- -- class EncryptInputStream extends InputStream { -- private Hessian2Input _in; -- -- private Cipher _cipher; -- private InputStream _bodyIn; -- private CipherInputStream _cipherIn; -- -- EncryptInputStream(Hessian2Input in) -- throws IOException -- { -- try { -- _in = in; -- -- byte []fingerprint = null; -- String keyAlgorithm = null; -- String algorithm = null; -- byte []encKey = null; -- -- int len = in.readInt(); -- -- for (int i = 0; i < len; i++) { -- String header = in.readString(); -- -- if ("fingerprint".equals(header)) -- fingerprint = in.readBytes(); -- else if ("key-algorithm".equals(header)) -- keyAlgorithm = in.readString(); -- else if ("algorithm".equals(header)) -- algorithm = in.readString(); -- else if ("key".equals(header)) -- encKey = in.readBytes(); -- else -- throw new IOException("'" + header + "' is an unexpected header"); -- } -- -- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -- keyCipher.init(Cipher.UNWRAP_MODE, _privateKey); -- -- Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); -- _bodyIn = _in.readInputStream(); -- -- _cipher = Cipher.getInstance(algorithm); -- _cipher.init(Cipher.DECRYPT_MODE, key); -- -- _cipherIn = new CipherInputStream(_bodyIn, _cipher); -- } catch (RuntimeException e) { -- throw e; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- public int read() -- throws IOException -- { -- return _cipherIn.read(); -- } -- -- public int read(byte []buffer, int offset, int length) -- throws IOException -- { -- return _cipherIn.read(buffer, offset, length); -- } -- -- public void close() -- throws IOException -- { -- Hessian2Input in = _in; -- _in = null; -- -- if (in != null) { -- _cipherIn.close(); -- _bodyIn.close(); -- -- int len = in.readInt(); -- -- if (len != 0) -- throw new IOException("Unexpected footer"); -- -- in.completeEnvelope(); -- -- in.close(); -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.security; -+ -+import java.security.*; -+import java.security.cert.*; -+import java.util.*; -+import javax.crypto.*; -+ -+import java.io.*; -+ -+import com.caucho.hessian.io.*; -+ -+public class X509Encryption extends HessianEnvelope { -+ private String _algorithm = "AES"; -+ -+ // certificate for encryption/decryption -+ private X509Certificate _cert; -+ -+ // private key for decryption -+ private PrivateKey _privateKey; -+ -+ private SecureRandom _secureRandom; -+ -+ public X509Encryption() -+ { -+ } -+ -+ /** -+ * Sets the encryption algorithm for the content. -+ */ -+ public void setAlgorithm(String algorithm) -+ { -+ if (algorithm == null) -+ throw new NullPointerException(); -+ -+ _algorithm = algorithm; -+ } -+ -+ /** -+ * Gets the encryption algorithm for the content. -+ */ -+ public String getAlgorithm() -+ { -+ return _algorithm; -+ } -+ -+ /** -+ * The X509 certificate to obtain the public key of the recipient. -+ */ -+ public X509Certificate getCertificate() -+ { -+ return _cert; -+ } -+ -+ /** -+ * The X509 certificate to obtain the public key of the recipient. -+ */ -+ public void setCertificate(X509Certificate cert) -+ { -+ _cert = cert; -+ } -+ -+ /** -+ * The private key for decryption. -+ */ -+ public PrivateKey getPrivateKey() -+ { -+ return _privateKey; -+ } -+ -+ /** -+ * The X509 certificate to obtain the public key of the recipient. -+ */ -+ public void setPrivateKey(PrivateKey privateKey) -+ { -+ _privateKey = privateKey; -+ } -+ -+ /** -+ * The random number generator for the shared secrets. -+ */ -+ public SecureRandom getSecureRandom() -+ { -+ return _secureRandom; -+ } -+ -+ /** -+ * The random number generator for the shared secrets. -+ */ -+ public void setSecureRandom(SecureRandom random) -+ { -+ _secureRandom = random; -+ } -+ -+ public Hessian2Output wrap(Hessian2Output out) -+ throws IOException -+ { -+ if (_cert == null) -+ throw new IOException("X509Encryption.wrap requires a certificate"); -+ -+ OutputStream os = new EncryptOutputStream(out); -+ -+ Hessian2Output filterOut = new Hessian2Output(os); -+ -+ filterOut.setCloseStreamOnClose(true); -+ -+ return filterOut; -+ } -+ -+ public Hessian2Input unwrap(Hessian2Input in) -+ throws IOException -+ { -+ if (_privateKey == null) -+ throw new IOException("X509Encryption.unwrap requires a private key"); -+ -+ if (_cert == null) -+ throw new IOException("X509Encryption.unwrap requires a certificate"); -+ -+ int version = in.readEnvelope(); -+ -+ String method = in.readMethod(); -+ -+ if (! method.equals(getClass().getName())) -+ throw new IOException("expected hessian Envelope method '" + -+ getClass().getName() + "' at '" + method + "'"); -+ -+ return unwrapHeaders(in); -+ } -+ -+ public Hessian2Input unwrapHeaders(Hessian2Input in) -+ throws IOException -+ { -+ if (_privateKey == null) -+ throw new IOException("X509Encryption.unwrap requires a private key"); -+ -+ if (_cert == null) -+ throw new IOException("X509Encryption.unwrap requires a certificate"); -+ -+ InputStream is = new EncryptInputStream(in); -+ -+ Hessian2Input filter = new Hessian2Input(is); -+ -+ filter.setCloseStreamOnClose(true); -+ -+ return filter; -+ } -+ -+ class EncryptOutputStream extends OutputStream { -+ private Hessian2Output _out; -+ -+ private Cipher _cipher; -+ private OutputStream _bodyOut; -+ private CipherOutputStream _cipherOut; -+ -+ EncryptOutputStream(Hessian2Output out) -+ throws IOException -+ { -+ try { -+ _out = out; -+ -+ KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); -+ -+ if (_secureRandom != null) -+ keyGen.init(_secureRandom); -+ -+ SecretKey sharedKey = keyGen.generateKey(); -+ -+ _out = out; -+ -+ _out.startEnvelope(X509Encryption.class.getName()); -+ -+ PublicKey publicKey = _cert.getPublicKey(); -+ -+ byte []encoded = publicKey.getEncoded(); -+ MessageDigest md = MessageDigest.getInstance("SHA1"); -+ md.update(encoded); -+ byte []fingerprint = md.digest(); -+ -+ String keyAlgorithm = publicKey.getAlgorithm(); -+ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -+ if (_secureRandom != null) -+ keyCipher.init(Cipher.WRAP_MODE, _cert, _secureRandom); -+ else -+ keyCipher.init(Cipher.WRAP_MODE, _cert); -+ -+ byte []encKey = keyCipher.wrap(sharedKey); -+ -+ _out.writeInt(4); -+ -+ _out.writeString("algorithm"); -+ _out.writeString(_algorithm); -+ _out.writeString("fingerprint"); -+ _out.writeBytes(fingerprint); -+ _out.writeString("key-algorithm"); -+ _out.writeString(keyAlgorithm); -+ _out.writeString("key"); -+ _out.writeBytes(encKey); -+ -+ _bodyOut = _out.getBytesOutputStream(); -+ -+ _cipher = Cipher.getInstance(_algorithm); -+ if (_secureRandom != null) -+ _cipher.init(Cipher.ENCRYPT_MODE, sharedKey, _secureRandom); -+ else -+ _cipher.init(Cipher.ENCRYPT_MODE, sharedKey); -+ -+ _cipherOut = new CipherOutputStream(_bodyOut, _cipher); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ public void write(int ch) -+ throws IOException -+ { -+ _cipherOut.write(ch); -+ } -+ -+ public void write(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ _cipherOut.write(buffer, offset, length); -+ } -+ -+ public void close() -+ throws IOException -+ { -+ Hessian2Output out = _out; -+ _out = null; -+ -+ if (out != null) { -+ _cipherOut.close(); -+ _bodyOut.close(); -+ -+ out.writeInt(0); -+ out.completeEnvelope(); -+ out.close(); -+ } -+ } -+ } -+ -+ class EncryptInputStream extends InputStream { -+ private Hessian2Input _in; -+ -+ private Cipher _cipher; -+ private InputStream _bodyIn; -+ private CipherInputStream _cipherIn; -+ -+ EncryptInputStream(Hessian2Input in) -+ throws IOException -+ { -+ try { -+ _in = in; -+ -+ byte []fingerprint = null; -+ String keyAlgorithm = null; -+ String algorithm = null; -+ byte []encKey = null; -+ -+ int len = in.readInt(); -+ -+ for (int i = 0; i < len; i++) { -+ String header = in.readString(); -+ -+ if ("fingerprint".equals(header)) -+ fingerprint = in.readBytes(); -+ else if ("key-algorithm".equals(header)) -+ keyAlgorithm = in.readString(); -+ else if ("algorithm".equals(header)) -+ algorithm = in.readString(); -+ else if ("key".equals(header)) -+ encKey = in.readBytes(); -+ else -+ throw new IOException("'" + header + "' is an unexpected header"); -+ } -+ -+ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -+ keyCipher.init(Cipher.UNWRAP_MODE, _privateKey); -+ -+ Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); -+ _bodyIn = _in.readInputStream(); -+ -+ _cipher = Cipher.getInstance(algorithm); -+ _cipher.init(Cipher.DECRYPT_MODE, key); -+ -+ _cipherIn = new CipherInputStream(_bodyIn, _cipher); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ public int read() -+ throws IOException -+ { -+ return _cipherIn.read(); -+ } -+ -+ public int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ return _cipherIn.read(buffer, offset, length); -+ } -+ -+ public void close() -+ throws IOException -+ { -+ Hessian2Input in = _in; -+ _in = null; -+ -+ if (in != null) { -+ _cipherIn.close(); -+ _bodyIn.close(); -+ -+ int len = in.readInt(); -+ -+ if (len != 0) -+ throw new IOException("Unexpected footer"); -+ -+ in.completeEnvelope(); -+ -+ in.close(); -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/security/X509Signature.java hessian-4.0.65-fix/com/caucho/hessian/security/X509Signature.java ---- hessian-4.0.65-src/com/caucho/hessian/security/X509Signature.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/security/X509Signature.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,397 +1,397 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.security; -- --import java.security.*; --import java.security.cert.*; --import java.util.*; --import javax.crypto.*; -- --import java.io.*; -- --import com.caucho.hessian.io.*; -- --public class X509Signature extends HessianEnvelope { -- private String _algorithm = "HmacSHA256"; -- private X509Certificate _cert; -- private PrivateKey _privateKey; -- private SecureRandom _secureRandom; -- -- public X509Signature() -- { -- } -- -- /** -- * Sets the encryption algorithm for the content. -- */ -- public void setAlgorithm(String algorithm) -- { -- if (algorithm == null) -- throw new NullPointerException(); -- -- _algorithm = algorithm; -- } -- -- /** -- * Gets the encryption algorithm for the content. -- */ -- public String getAlgorithm() -- { -- return _algorithm; -- } -- -- /** -- * The X509 certificate to obtain the public key of the recipient. -- */ -- public X509Certificate getCertificate() -- { -- return _cert; -- } -- -- /** -- * The X509 certificate to obtain the public key of the recipient. -- */ -- public void setCertificate(X509Certificate cert) -- { -- _cert = cert; -- } -- -- /** -- * The key to obtain the private key of the recipient. -- */ -- public PrivateKey getPrivateKey() -- { -- return _privateKey; -- } -- -- /** -- * The private key. -- */ -- public void setPrivateKey(PrivateKey key) -- { -- _privateKey = key; -- } -- -- /** -- * The random number generator for the shared secrets. -- */ -- public SecureRandom getSecureRandom() -- { -- return _secureRandom; -- } -- -- /** -- * The random number generator for the shared secrets. -- */ -- public void setSecureRandom(SecureRandom random) -- { -- _secureRandom = random; -- } -- -- public Hessian2Output wrap(Hessian2Output out) -- throws IOException -- { -- if (_privateKey == null) -- throw new IOException("X509Signature.wrap requires a private key"); -- -- if (_cert == null) -- throw new IOException("X509Signature.wrap requires a certificate"); -- -- OutputStream os = new SignatureOutputStream(out); -- -- Hessian2Output filterOut = new Hessian2Output(os); -- -- filterOut.setCloseStreamOnClose(true); -- -- return filterOut; -- } -- -- public Hessian2Input unwrap(Hessian2Input in) -- throws IOException -- { -- if (_cert == null) -- throw new IOException("X509Signature.unwrap requires a certificate"); -- -- int version = in.readEnvelope(); -- -- String method = in.readMethod(); -- -- if (! method.equals(getClass().getName())) -- throw new IOException("expected hessian Envelope method '" + -- getClass().getName() + "' at '" + method + "'"); -- -- return unwrapHeaders(in); -- } -- -- public Hessian2Input unwrapHeaders(Hessian2Input in) -- throws IOException -- { -- if (_cert == null) -- throw new IOException("X509Signature.unwrap requires a certificate"); -- -- InputStream is = new SignatureInputStream(in); -- -- Hessian2Input filter = new Hessian2Input(is); -- -- filter.setCloseStreamOnClose(true); -- -- return filter; -- } -- -- class SignatureOutputStream extends OutputStream { -- private Hessian2Output _out; -- private OutputStream _bodyOut; -- private Mac _mac; -- -- SignatureOutputStream(Hessian2Output out) -- throws IOException -- { -- try { -- KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); -- -- if (_secureRandom != null) -- keyGen.init(_secureRandom); -- -- SecretKey sharedKey = keyGen.generateKey(); -- -- _out = out; -- -- _out.startEnvelope(X509Signature.class.getName()); -- -- PublicKey publicKey = _cert.getPublicKey(); -- -- byte []encoded = publicKey.getEncoded(); -- MessageDigest md = MessageDigest.getInstance("SHA1"); -- md.update(encoded); -- byte []fingerprint = md.digest(); -- -- String keyAlgorithm = _privateKey.getAlgorithm(); -- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -- keyCipher.init(Cipher.WRAP_MODE, _privateKey); -- -- byte []encKey = keyCipher.wrap(sharedKey); -- -- _out.writeInt(4); -- _out.writeString("algorithm"); -- _out.writeString(_algorithm); -- _out.writeString("fingerprint"); -- _out.writeBytes(fingerprint); -- _out.writeString("key-algorithm"); -- _out.writeString(keyAlgorithm); -- _out.writeString("key"); -- _out.writeBytes(encKey); -- -- _mac = Mac.getInstance(_algorithm); -- _mac.init(sharedKey); -- -- _bodyOut = _out.getBytesOutputStream(); -- } catch (RuntimeException e) { -- throw e; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- public void write(int ch) -- throws IOException -- { -- _bodyOut.write(ch); -- _mac.update((byte) ch); -- } -- -- public void write(byte []buffer, int offset, int length) -- throws IOException -- { -- _bodyOut.write(buffer, offset, length); -- _mac.update(buffer, offset, length); -- } -- -- public void close() -- throws IOException -- { -- Hessian2Output out = _out; -- _out = null; -- -- if (out == null) -- return; -- -- _bodyOut.close(); -- -- byte []sig = _mac.doFinal(); -- -- out.writeInt(1); -- out.writeString("signature"); -- out.writeBytes(sig); -- -- out.completeEnvelope(); -- out.close(); -- } -- } -- -- class SignatureInputStream extends InputStream { -- private Hessian2Input _in; -- -- private Mac _mac; -- private InputStream _bodyIn; -- private CipherInputStream _cipherIn; -- -- SignatureInputStream(Hessian2Input in) -- throws IOException -- { -- try { -- _in = in; -- -- byte []fingerprint = null; -- String keyAlgorithm = null; -- String algorithm = null; -- byte []encKey = null; -- -- int len = in.readInt(); -- -- for (int i = 0; i < len; i++) { -- String header = in.readString(); -- -- if ("fingerprint".equals(header)) -- fingerprint = in.readBytes(); -- else if ("key-algorithm".equals(header)) -- keyAlgorithm = in.readString(); -- else if ("algorithm".equals(header)) -- algorithm = in.readString(); -- else if ("key".equals(header)) -- encKey = in.readBytes(); -- else -- throw new IOException("'" + header + "' is an unexpected header"); -- } -- -- Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -- keyCipher.init(Cipher.UNWRAP_MODE, _cert); -- -- Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); -- _bodyIn = _in.readInputStream(); -- -- _mac = Mac.getInstance(algorithm); -- _mac.init(key); -- } catch (RuntimeException e) { -- throw e; -- } catch (IOException e) { -- throw e; -- } catch (Exception e) { -- throw new RuntimeException(e); -- } -- } -- -- public int read() -- throws IOException -- { -- int ch = _bodyIn.read(); -- -- if (ch < 0) -- return ch; -- -- _mac.update((byte) ch); -- -- return ch; -- } -- -- public int read(byte []buffer, int offset, int length) -- throws IOException -- { -- int len = _bodyIn.read(buffer, offset, length); -- -- if (len < 0) -- return len; -- -- _mac.update(buffer, offset, len); -- -- return len; -- } -- -- public void close() -- throws IOException -- { -- Hessian2Input in = _in; -- _in = null; -- -- if (in != null) { -- _bodyIn.close(); -- -- int len = in.readInt(); -- byte []signature = null; -- -- for (int i = 0; i < len; i++) { -- String header = in.readString(); -- -- if ("signature".equals(header)) -- signature = in.readBytes(); -- } -- -- in.completeEnvelope(); -- in.close(); -- -- -- if (signature == null) -- throw new IOException("Expected signature"); -- -- byte []sig = _mac.doFinal(); -- -- if (sig.length != signature.length) -- throw new IOException("mismatched signature"); -- -- for (int i = 0; i < sig.length; i++) { -- if (signature[i] != sig[i]) -- throw new IOException("mismatched signature"); -- } -- -- // XXX: save principal -- } -- } -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.security; -+ -+import java.security.*; -+import java.security.cert.*; -+import java.util.*; -+import javax.crypto.*; -+ -+import java.io.*; -+ -+import com.caucho.hessian.io.*; -+ -+public class X509Signature extends HessianEnvelope { -+ private String _algorithm = "HmacSHA256"; -+ private X509Certificate _cert; -+ private PrivateKey _privateKey; -+ private SecureRandom _secureRandom; -+ -+ public X509Signature() -+ { -+ } -+ -+ /** -+ * Sets the encryption algorithm for the content. -+ */ -+ public void setAlgorithm(String algorithm) -+ { -+ if (algorithm == null) -+ throw new NullPointerException(); -+ -+ _algorithm = algorithm; -+ } -+ -+ /** -+ * Gets the encryption algorithm for the content. -+ */ -+ public String getAlgorithm() -+ { -+ return _algorithm; -+ } -+ -+ /** -+ * The X509 certificate to obtain the public key of the recipient. -+ */ -+ public X509Certificate getCertificate() -+ { -+ return _cert; -+ } -+ -+ /** -+ * The X509 certificate to obtain the public key of the recipient. -+ */ -+ public void setCertificate(X509Certificate cert) -+ { -+ _cert = cert; -+ } -+ -+ /** -+ * The key to obtain the private key of the recipient. -+ */ -+ public PrivateKey getPrivateKey() -+ { -+ return _privateKey; -+ } -+ -+ /** -+ * The private key. -+ */ -+ public void setPrivateKey(PrivateKey key) -+ { -+ _privateKey = key; -+ } -+ -+ /** -+ * The random number generator for the shared secrets. -+ */ -+ public SecureRandom getSecureRandom() -+ { -+ return _secureRandom; -+ } -+ -+ /** -+ * The random number generator for the shared secrets. -+ */ -+ public void setSecureRandom(SecureRandom random) -+ { -+ _secureRandom = random; -+ } -+ -+ public Hessian2Output wrap(Hessian2Output out) -+ throws IOException -+ { -+ if (_privateKey == null) -+ throw new IOException("X509Signature.wrap requires a private key"); -+ -+ if (_cert == null) -+ throw new IOException("X509Signature.wrap requires a certificate"); -+ -+ OutputStream os = new SignatureOutputStream(out); -+ -+ Hessian2Output filterOut = new Hessian2Output(os); -+ -+ filterOut.setCloseStreamOnClose(true); -+ -+ return filterOut; -+ } -+ -+ public Hessian2Input unwrap(Hessian2Input in) -+ throws IOException -+ { -+ if (_cert == null) -+ throw new IOException("X509Signature.unwrap requires a certificate"); -+ -+ int version = in.readEnvelope(); -+ -+ String method = in.readMethod(); -+ -+ if (! method.equals(getClass().getName())) -+ throw new IOException("expected hessian Envelope method '" + -+ getClass().getName() + "' at '" + method + "'"); -+ -+ return unwrapHeaders(in); -+ } -+ -+ public Hessian2Input unwrapHeaders(Hessian2Input in) -+ throws IOException -+ { -+ if (_cert == null) -+ throw new IOException("X509Signature.unwrap requires a certificate"); -+ -+ InputStream is = new SignatureInputStream(in); -+ -+ Hessian2Input filter = new Hessian2Input(is); -+ -+ filter.setCloseStreamOnClose(true); -+ -+ return filter; -+ } -+ -+ class SignatureOutputStream extends OutputStream { -+ private Hessian2Output _out; -+ private OutputStream _bodyOut; -+ private Mac _mac; -+ -+ SignatureOutputStream(Hessian2Output out) -+ throws IOException -+ { -+ try { -+ KeyGenerator keyGen = KeyGenerator.getInstance(_algorithm); -+ -+ if (_secureRandom != null) -+ keyGen.init(_secureRandom); -+ -+ SecretKey sharedKey = keyGen.generateKey(); -+ -+ _out = out; -+ -+ _out.startEnvelope(X509Signature.class.getName()); -+ -+ PublicKey publicKey = _cert.getPublicKey(); -+ -+ byte []encoded = publicKey.getEncoded(); -+ MessageDigest md = MessageDigest.getInstance("SHA1"); -+ md.update(encoded); -+ byte []fingerprint = md.digest(); -+ -+ String keyAlgorithm = _privateKey.getAlgorithm(); -+ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -+ keyCipher.init(Cipher.WRAP_MODE, _privateKey); -+ -+ byte []encKey = keyCipher.wrap(sharedKey); -+ -+ _out.writeInt(4); -+ _out.writeString("algorithm"); -+ _out.writeString(_algorithm); -+ _out.writeString("fingerprint"); -+ _out.writeBytes(fingerprint); -+ _out.writeString("key-algorithm"); -+ _out.writeString(keyAlgorithm); -+ _out.writeString("key"); -+ _out.writeBytes(encKey); -+ -+ _mac = Mac.getInstance(_algorithm); -+ _mac.init(sharedKey); -+ -+ _bodyOut = _out.getBytesOutputStream(); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ public void write(int ch) -+ throws IOException -+ { -+ _bodyOut.write(ch); -+ _mac.update((byte) ch); -+ } -+ -+ public void write(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ _bodyOut.write(buffer, offset, length); -+ _mac.update(buffer, offset, length); -+ } -+ -+ public void close() -+ throws IOException -+ { -+ Hessian2Output out = _out; -+ _out = null; -+ -+ if (out == null) -+ return; -+ -+ _bodyOut.close(); -+ -+ byte []sig = _mac.doFinal(); -+ -+ out.writeInt(1); -+ out.writeString("signature"); -+ out.writeBytes(sig); -+ -+ out.completeEnvelope(); -+ out.close(); -+ } -+ } -+ -+ class SignatureInputStream extends InputStream { -+ private Hessian2Input _in; -+ -+ private Mac _mac; -+ private InputStream _bodyIn; -+ private CipherInputStream _cipherIn; -+ -+ SignatureInputStream(Hessian2Input in) -+ throws IOException -+ { -+ try { -+ _in = in; -+ -+ byte []fingerprint = null; -+ String keyAlgorithm = null; -+ String algorithm = null; -+ byte []encKey = null; -+ -+ int len = in.readInt(); -+ -+ for (int i = 0; i < len; i++) { -+ String header = in.readString(); -+ -+ if ("fingerprint".equals(header)) -+ fingerprint = in.readBytes(); -+ else if ("key-algorithm".equals(header)) -+ keyAlgorithm = in.readString(); -+ else if ("algorithm".equals(header)) -+ algorithm = in.readString(); -+ else if ("key".equals(header)) -+ encKey = in.readBytes(); -+ else -+ throw new IOException("'" + header + "' is an unexpected header"); -+ } -+ -+ Cipher keyCipher = Cipher.getInstance(keyAlgorithm); -+ keyCipher.init(Cipher.UNWRAP_MODE, _cert); -+ -+ Key key = keyCipher.unwrap(encKey, algorithm, Cipher.SECRET_KEY); -+ _bodyIn = _in.readInputStream(); -+ -+ _mac = Mac.getInstance(algorithm); -+ _mac.init(key); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (IOException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new RuntimeException(e); -+ } -+ } -+ -+ public int read() -+ throws IOException -+ { -+ int ch = _bodyIn.read(); -+ -+ if (ch < 0) -+ return ch; -+ -+ _mac.update((byte) ch); -+ -+ return ch; -+ } -+ -+ public int read(byte []buffer, int offset, int length) -+ throws IOException -+ { -+ int len = _bodyIn.read(buffer, offset, length); -+ -+ if (len < 0) -+ return len; -+ -+ _mac.update(buffer, offset, len); -+ -+ return len; -+ } -+ -+ public void close() -+ throws IOException -+ { -+ Hessian2Input in = _in; -+ _in = null; -+ -+ if (in != null) { -+ _bodyIn.close(); -+ -+ int len = in.readInt(); -+ byte []signature = null; -+ -+ for (int i = 0; i < len; i++) { -+ String header = in.readString(); -+ -+ if ("signature".equals(header)) -+ signature = in.readBytes(); -+ } -+ -+ in.completeEnvelope(); -+ in.close(); -+ -+ -+ if (signature == null) -+ throw new IOException("Expected signature"); -+ -+ byte []sig = _mac.doFinal(); -+ -+ if (sig.length != signature.length) -+ throw new IOException("mismatched signature"); -+ -+ for (int i = 0; i < sig.length; i++) { -+ if (signature[i] != sig[i]) -+ throw new IOException("mismatched signature"); -+ } -+ -+ // XXX: save principal -+ } -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/server/HessianDispatcher.java hessian-4.0.65-fix/com/caucho/hessian/server/HessianDispatcher.java ---- hessian-4.0.65-src/com/caucho/hessian/server/HessianDispatcher.java 1970-01-01 08:00:00.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/server/HessianDispatcher.java 2023-08-15 18:39:22.000000000 +0800 -@@ -0,0 +1,337 @@ -+ -+package com.caucho.hessian.server; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.PrintWriter; -+import java.io.Writer; -+import java.util.Map; -+import java.util.Properties; -+import java.util.concurrent.ConcurrentHashMap; -+import java.util.logging.Logger; -+ -+import javax.servlet.GenericServlet; -+import javax.servlet.Servlet; -+import javax.servlet.ServletConfig; -+import javax.servlet.ServletException; -+import javax.servlet.ServletRequest; -+import javax.servlet.ServletResponse; -+import javax.servlet.http.HttpServletRequest; -+import javax.servlet.http.HttpServletResponse; -+ -+import org.springframework.context.ApplicationContext; -+import org.springframework.web.context.support.WebApplicationContextUtils; -+ -+import com.caucho.hessian.io.Hessian2Input; -+import com.caucho.hessian.io.SerializerFactory; -+import com.caucho.services.server.Service; -+import com.caucho.services.server.ServiceContext; -+ -+ -+public class HessianDispatcher extends GenericServlet -+{ -+ -+ -+ private static final long serialVersionUID = -8611469561907416355L; -+ -+ private SerializerFactory _serializerFactory; -+ -+ private static final String SERVICE_FILE_PATH = "config-file"; -+ -+ private static Map registry = new ConcurrentHashMap(); -+ -+ private static Properties props = new Properties(); -+ -+ public HessianDispatcher() -+ { -+ } -+ -+ public String getServletInfo() -+ { -+ return "Hessian Dispatcher"; -+ } -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ public SerializerFactory getSerializerFactory() -+ { -+ if (_serializerFactory == null) -+ _serializerFactory = new SerializerFactory(); -+ -+ return _serializerFactory; -+ } -+ -+ /** -+ * Sets the serializer send collection java type. -+ */ -+ public void setSendCollectionType(boolean sendType) -+ { -+ getSerializerFactory().setSendCollectionType(sendType); -+ } -+ -+ /** -+ * Initialize the service, including the service object. -+ */ -+ public void init(ServletConfig config) throws ServletException -+ { -+ super.init(config); -+ -+ try -+ { -+ String serviceConfigFile = getInitParameter(SERVICE_FILE_PATH); -+ -+ if (null == serviceConfigFile) -+ { -+ throw new ServletException( -+ "Hessian service registry file path must be set in classpath when using 'HessianDispatcher'"); -+ } -+ -+ props.load(this.getClass().getClassLoader() -+ .getResourceAsStream(serviceConfigFile)); -+ } -+ -+ catch (Exception e) -+ { -+ throw new ServletException(e); -+ } -+ } -+ -+ private Class loadClass(String className) throws ClassNotFoundException -+ { -+ ClassLoader loader = getContextClassLoader(); -+ -+ if (loader != null) -+ return Class.forName(className, false, loader); -+ else -+ return Class.forName(className); -+ } -+ -+ protected ClassLoader getContextClassLoader() -+ { -+ return Thread.currentThread().getContextClassLoader(); -+ } -+ -+ private void init(Object service) throws ServletException -+ { -+ if (!this.getClass().equals(HessianDispatcher.class)) -+ { -+ } -+ else if (service instanceof Service) -+ ((Service) service).init(getServletConfig()); -+ else if (service instanceof Servlet) -+ ((Servlet) service).init(getServletConfig()); -+ } -+ -+ /** -+ * Execute a request. The path-info of the request selects the bean. Once -+ * the bean's selected, it will be applied. -+ */ -+ public void service(ServletRequest request, ServletResponse response) -+ throws IOException, ServletException -+ { -+ HttpServletRequest req = (HttpServletRequest) request; -+ HttpServletResponse res = (HttpServletResponse) response; -+ -+ if (!req.getMethod().equals("POST")) -+ { -+ res.setStatus(500, "Hessian Requires POST"); -+ PrintWriter out = res.getWriter(); -+ -+ res.setContentType("text/html"); -+ out.println("

Hessian Requires POST

"); -+ -+ return; -+ } -+ -+ String serviceInterface = req.getHeader("Interface-Name"); -+ -+ if (null == serviceInterface) -+ { -+ throw new ServletException( -+ "The service interface you reqeust is null. please check the client setting."); -+ } -+ -+ try -+ { -+ HessianSkeleton skeleton = findHessianSkeleton(serviceInterface); -+ -+ String serviceId = req.getPathInfo(); -+ -+ String objectId = req.getParameter("id"); -+ -+ if (objectId == null) -+ objectId = req.getParameter("ejbid"); -+ -+ ServiceContext.begin(req, serviceId, objectId); -+ -+ InputStream is = request.getInputStream(); -+ -+ OutputStream os = response.getOutputStream(); -+ -+ response.setContentType("application/x-hessian"); -+ -+ SerializerFactory serializerFactory = getSerializerFactory(); -+ -+ invoke(is, os, skeleton, serializerFactory); -+ } -+ catch (RuntimeException e) -+ { -+ throw e; -+ } -+ catch (ServletException e) -+ { -+ throw e; -+ } -+ catch (Throwable e) -+ { -+ throw new ServletException(e); -+ } -+ finally -+ { -+ ServiceContext.end(); -+ } -+ } -+ -+ -+ private HessianSkeleton findHessianSkeleton(String serviceInterface) -+ throws ServletException, ClassNotFoundException, -+ IllegalAccessException, InstantiationException -+ { -+ HessianSkeleton skeleton = null; -+ -+ if (registry.containsKey(serviceInterface))// find in cache first -+ { -+ skeleton = registry.get(serviceInterface); -+ } -+ else -+ // parse serviceImpl string to create skeleton. -+ { -+ String serviceImpl = (String) this.props.get(serviceInterface); -+ -+ if (null == serviceImpl) -+ { -+ throw new ServletException( -+ "Your request service of " -+ + serviceInterface -+ + " dose not exsit.please check the server configuration."); -+ } -+ if (serviceImpl.startsWith("#"))// for get bean from spring -+ { -+ skeleton = findSpringSkeleton(serviceInterface, serviceImpl); -+ } -+ else -+ { -+ skeleton = findLocalSkeleton(serviceInterface, serviceImpl); -+ } -+ -+ } -+ -+ registry.put(serviceInterface, skeleton); -+ -+ return skeleton; -+ } -+ -+ -+ private HessianSkeleton findLocalSkeleton(String serviceInterface, -+ String serviceImpl) throws ClassNotFoundException, -+ InstantiationException, IllegalAccessException, ServletException -+ { -+ HessianSkeleton skeleton; -+ Class homeClass = loadClass(serviceImpl); -+ -+ Object localBean = homeClass.newInstance(); -+ -+ init(localBean); -+ -+ skeleton = new HessianSkeleton(localBean, loadClass(serviceInterface)); -+ return skeleton; -+ } -+ -+ -+ private HessianSkeleton findSpringSkeleton(String serviceInterface, -+ String serviceImpl) throws ServletException, ClassNotFoundException -+ { -+ HessianSkeleton skeleton; -+ String beanId = serviceImpl.substring(1, serviceImpl.length()); -+ -+ ApplicationContext wac = WebApplicationContextUtils -+ .getWebApplicationContext(getServletContext()); -+ -+ Object springBean = wac.getBean(beanId.trim()); -+ -+ init(springBean); -+ -+ skeleton = new HessianSkeleton(springBean, loadClass(serviceInterface)); -+ -+ return skeleton; -+ } -+ -+ protected void invoke(InputStream is, OutputStream os, -+ HessianSkeleton skeleton, SerializerFactory serializerFactory) -+ throws Exception -+ { -+ skeleton.invoke(is, os, serializerFactory); -+ } -+ -+ protected Hessian2Input createHessian2Input(InputStream is) -+ { -+ return new Hessian2Input(is); -+ } -+ -+ static class LogWriter extends Writer -+ { -+ private Logger _log; -+ -+ private StringBuilder _sb = new StringBuilder(); -+ -+ LogWriter(Logger log) -+ { -+ _log = log; -+ } -+ -+ public void write(char ch) -+ { -+ if (ch == '\n' && _sb.length() > 0) -+ { -+ _log.fine(_sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ -+ public void write(char[] buffer, int offset, int length) -+ { -+ for (int i = 0; i < length; i++) -+ { -+ char ch = buffer[offset + i]; -+ -+ if (ch == '\n' && _sb.length() > 0) -+ { -+ _log.fine(_sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ } -+ -+ public void flush() -+ { -+ } -+ -+ public void close() -+ { -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/server/HessianServlet.java hessian-4.0.65-fix/com/caucho/hessian/server/HessianServlet.java ---- hessian-4.0.65-src/com/caucho/hessian/server/HessianServlet.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/server/HessianServlet.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,477 +1,551 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.server; -- --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; --import java.io.PrintWriter; --import java.io.Writer; --import java.util.logging.Logger; -- --import javax.servlet.GenericServlet; --import javax.servlet.Servlet; --import javax.servlet.ServletConfig; --import javax.servlet.ServletException; --import javax.servlet.ServletRequest; --import javax.servlet.ServletResponse; --import javax.servlet.http.HttpServlet; --import javax.servlet.http.HttpServletRequest; --import javax.servlet.http.HttpServletResponse; -- --import com.caucho.hessian.io.Hessian2Input; --import com.caucho.hessian.io.SerializerFactory; --import com.caucho.services.server.Service; --import com.caucho.services.server.ServiceContext; -- --/** -- * Servlet for serving Hessian services. -- * -- * Applications can use ServletContext inside a Hessian service to get -- * ServletRequest, ServletResponse and session information. -- */ --@SuppressWarnings("serial") --public class HessianServlet extends HttpServlet { -- private Class _homeAPI; -- private Object _homeImpl; -- -- private Class _objectAPI; -- private Object _objectImpl; -- -- private HessianSkeleton _homeSkeleton; -- private HessianSkeleton _objectSkeleton; -- -- private SerializerFactory _serializerFactory; -- -- public HessianServlet() -- { -- } -- -- public String getServletInfo() -- { -- return "Hessian Servlet"; -- } -- -- /** -- * Sets the home api. -- */ -- public void setHomeAPI(Class api) -- { -- _homeAPI = api; -- } -- -- /** -- * Sets the home implementation -- */ -- public void setHome(Object home) -- { -- _homeImpl = home; -- } -- -- /** -- * Sets the object api. -- */ -- public void setObjectAPI(Class api) -- { -- _objectAPI = api; -- } -- -- /** -- * Sets the object implementation -- */ -- public void setObject(Object object) -- { -- _objectImpl = object; -- } -- -- /** -- * Sets the service class. -- */ -- public void setService(Object service) -- { -- setHome(service); -- } -- -- /** -- * Sets the api-class. -- */ -- public void setAPIClass(Class api) -- { -- setHomeAPI(api); -- } -- -- /** -- * Gets the api-class. -- */ -- public Class getAPIClass() -- { -- return _homeAPI; -- } -- -- /** -- * Sets the serializer factory. -- */ -- public void setSerializerFactory(SerializerFactory factory) -- { -- _serializerFactory = factory; -- } -- -- /** -- * Gets the serializer factory. -- */ -- public SerializerFactory getSerializerFactory() -- { -- if (_serializerFactory == null) -- _serializerFactory = new SerializerFactory(); -- -- return _serializerFactory; -- } -- -- /** -- * Sets the serializer send collection java type. -- */ -- public void setSendCollectionType(boolean sendType) -- { -- getSerializerFactory().setSendCollectionType(sendType); -- } -- -- /** -- * Sets whitelist mode for the deserializer -- */ -- public void setWhitelist(boolean isWhitelist) -- { -- getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); -- } -- -- /** -- * Adds an allow rule to the deserializer -- * -- * Examples: "java.util.*", "com.foo.io.Bean" -- */ -- public void allow(String pattern) -- { -- getSerializerFactory().getClassFactory().allow(pattern); -- } -- -- /** -- * Adds a deny rule to the deserializer -- */ -- public void deny(String pattern) -- { -- getSerializerFactory().getClassFactory().deny(pattern); -- } -- -- /** -- * Sets the debugging flag. -- */ -- public void setDebug(boolean isDebug) -- { -- } -- -- /** -- * Sets the debugging log name. -- */ -- public void setLogName(String name) -- { -- // _log = Logger.getLogger(name); -- } -- -- /** -- * Initialize the service, including the service object. -- */ -- public void init(ServletConfig config) -- throws ServletException -- { -- super.init(config); -- -- try { -- if (_homeImpl != null) { -- } -- else if (getInitParameter("home-class") != null) { -- String className = getInitParameter("home-class"); -- -- Class homeClass = loadClass(className); -- -- _homeImpl = homeClass.newInstance(); -- -- init(_homeImpl); -- } -- else if (getInitParameter("service-class") != null) { -- String className = getInitParameter("service-class"); -- -- Class homeClass = loadClass(className); -- -- _homeImpl = homeClass.newInstance(); -- -- init(_homeImpl); -- } -- else { -- if (getClass().equals(HessianServlet.class)) -- throw new ServletException("server must extend HessianServlet"); -- -- _homeImpl = this; -- } -- -- if (_homeAPI != null) { -- } -- else if (getInitParameter("home-api") != null) { -- String className = getInitParameter("home-api"); -- -- _homeAPI = loadClass(className); -- } -- else if (getInitParameter("api-class") != null) { -- String className = getInitParameter("api-class"); -- -- _homeAPI = loadClass(className); -- } -- else if (_homeImpl != null) { -- _homeAPI = findRemoteAPI(_homeImpl.getClass()); -- -- if (_homeAPI == null) -- _homeAPI = _homeImpl.getClass(); -- -- _homeAPI = _homeImpl.getClass(); -- } -- -- if (_objectImpl != null) { -- } -- else if (getInitParameter("object-class") != null) { -- String className = getInitParameter("object-class"); -- -- Class objectClass = loadClass(className); -- -- _objectImpl = objectClass.newInstance(); -- -- init(_objectImpl); -- } -- -- if (_objectAPI != null) { -- } -- else if (getInitParameter("object-api") != null) { -- String className = getInitParameter("object-api"); -- -- _objectAPI = loadClass(className); -- } -- else if (_objectImpl != null) -- _objectAPI = _objectImpl.getClass(); -- -- _homeSkeleton = new HessianSkeleton(_homeImpl, _homeAPI); -- -- if (_objectAPI != null) -- _homeSkeleton.setObjectClass(_objectAPI); -- -- if (_objectImpl != null) { -- _objectSkeleton = new HessianSkeleton(_objectImpl, _objectAPI); -- _objectSkeleton.setHomeClass(_homeAPI); -- } -- else -- _objectSkeleton = _homeSkeleton; -- -- if ("true".equals(getInitParameter("debug"))) { -- } -- -- if ("false".equals(getInitParameter("send-collection-type"))) -- setSendCollectionType(false); -- } catch (ServletException e) { -- throw e; -- } catch (Exception e) { -- throw new ServletException(e); -- } -- } -- -- private Class findRemoteAPI(Class implClass) -- { -- // hessian/34d0 -- return null; -- -- /* -- if (implClass == null || implClass.equals(GenericService.class)) -- return null; -- -- Class []interfaces = implClass.getInterfaces(); -- -- if (interfaces.length == 1) -- return interfaces[0]; -- -- return findRemoteAPI(implClass.getSuperclass()); -- */ -- } -- -- private Class loadClass(String className) -- throws ClassNotFoundException -- { -- ClassLoader loader = getContextClassLoader(); -- -- if (loader != null) -- return Class.forName(className, false, loader); -- else -- return Class.forName(className); -- } -- -- protected ClassLoader getContextClassLoader() -- { -- return Thread.currentThread().getContextClassLoader(); -- } -- -- private void init(Object service) -- throws ServletException -- { -- if (! this.getClass().equals(HessianServlet.class)) { -- } -- else if (service instanceof Service) -- ((Service) service).init(getServletConfig()); -- else if (service instanceof Servlet) -- ((Servlet) service).init(getServletConfig()); -- } -- -- /** -- * Execute a request. The path-info of the request selects the bean. -- * Once the bean's selected, it will be applied. -- */ -- public void service(ServletRequest request, ServletResponse response) -- throws IOException, ServletException -- { -- HttpServletRequest req = (HttpServletRequest) request; -- HttpServletResponse res = (HttpServletResponse) response; -- -- if (! req.getMethod().equals("POST")) { -- res.setStatus(500); // , "Hessian Requires POST"); -- PrintWriter out = res.getWriter(); -- -- res.setContentType("text/html"); -- out.println("

Hessian Requires POST

"); -- -- return; -- } -- -- String serviceId = req.getPathInfo(); -- String objectId = req.getParameter("id"); -- if (objectId == null) -- objectId = req.getParameter("ejbid"); -- -- ServiceContext.begin(req, res, serviceId, objectId); -- -- try { -- InputStream is = request.getInputStream(); -- OutputStream os = response.getOutputStream(); -- -- response.setContentType("x-application/hessian"); -- -- SerializerFactory serializerFactory = getSerializerFactory(); -- -- invoke(is, os, objectId, serializerFactory); -- } catch (RuntimeException e) { -- throw e; -- } catch (ServletException e) { -- throw e; -- } catch (Throwable e) { -- throw new ServletException(e); -- } finally { -- ServiceContext.end(); -- } -- } -- -- protected void invoke(InputStream is, OutputStream os, -- String objectId, -- SerializerFactory serializerFactory) -- throws Exception -- { -- if (objectId != null) -- _objectSkeleton.invoke(is, os, serializerFactory); -- else -- _homeSkeleton.invoke(is, os, serializerFactory); -- } -- -- protected Hessian2Input createHessian2Input(InputStream is) -- { -- return new Hessian2Input(is); -- } -- -- static class LogWriter extends Writer { -- private Logger _log; -- private StringBuilder _sb = new StringBuilder(); -- -- LogWriter(Logger log) -- { -- _log = log; -- } -- -- public void write(char ch) -- { -- if (ch == '\n' && _sb.length() > 0) { -- _log.fine(_sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- -- public void write(char []buffer, int offset, int length) -- { -- for (int i = 0; i < length; i++) { -- char ch = buffer[offset + i]; -- -- if (ch == '\n' && _sb.length() > 0) { -- _log.fine(_sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- } -- -- public void flush() -- { -- } -- -- public void close() -- { -- } -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.server; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.PrintWriter; -+import java.io.Writer; -+import java.util.logging.Logger; -+ -+import javax.servlet.GenericServlet; -+import javax.servlet.Servlet; -+import javax.servlet.ServletConfig; -+import javax.servlet.ServletException; -+import javax.servlet.ServletRequest; -+import javax.servlet.ServletResponse; -+import javax.servlet.http.HttpServlet; -+import javax.servlet.http.HttpServletRequest; -+import javax.servlet.http.HttpServletResponse; -+ -+import org.springframework.context.ApplicationContext; -+import org.springframework.web.context.support.WebApplicationContextUtils; -+ -+import com.caucho.hessian.io.Hessian2Input; -+import com.caucho.hessian.io.SerializerFactory; -+import com.caucho.services.server.GenericService; -+import com.caucho.services.server.Service; -+import com.caucho.services.server.ServiceContext; -+ -+/** -+ * Servlet for serving Hessian services. -+ * -+ * Applications can use ServletContext inside a Hessian service to get -+ * ServletRequest, ServletResponse and session information. -+ */ -+@SuppressWarnings("serial") -+public class HessianServlet extends HttpServlet { -+ private static final long serialVersionUID = 1345616653808440850L; -+ private Logger _log = Logger.getLogger(HessianServlet.class.getName()); -+ private Class _homeAPI; -+ private Object _homeImpl; -+ -+ private Class _objectAPI; -+ private Object _objectImpl; -+ -+ private HessianSkeleton _homeSkeleton; -+ private HessianSkeleton _objectSkeleton; -+ -+ private SerializerFactory _serializerFactory; -+ private boolean _isDebug; -+ -+ public HessianServlet() -+ { -+ } -+ -+ public String getServletInfo() -+ { -+ return "Hessian Servlet"; -+ } -+ -+ /** -+ * Sets the home api. -+ */ -+ public void setHomeAPI(Class api) -+ { -+ _homeAPI = api; -+ } -+ -+ /** -+ * Sets the home implementation -+ */ -+ public void setHome(Object home) -+ { -+ _homeImpl = home; -+ } -+ -+ /** -+ * Sets the object api. -+ */ -+ public void setObjectAPI(Class api) -+ { -+ _objectAPI = api; -+ } -+ -+ /** -+ * Sets the object implementation -+ */ -+ public void setObject(Object object) -+ { -+ _objectImpl = object; -+ } -+ -+ /** -+ * Sets the service class. -+ */ -+ public void setService(Object service) -+ { -+ setHome(service); -+ } -+ -+ /** -+ * Sets the api-class. -+ */ -+ public void setAPIClass(Class api) -+ { -+ setHomeAPI(api); -+ } -+ -+ /** -+ * Gets the api-class. -+ */ -+ public Class getAPIClass() -+ { -+ return _homeAPI; -+ } -+ -+ /** -+ * Sets the serializer factory. -+ */ -+ public void setSerializerFactory(SerializerFactory factory) -+ { -+ _serializerFactory = factory; -+ } -+ -+ /** -+ * Gets the serializer factory. -+ */ -+ public SerializerFactory getSerializerFactory() -+ { -+ if (_serializerFactory == null) -+ _serializerFactory = new SerializerFactory(); -+ -+ return _serializerFactory; -+ } -+ -+ /** -+ * Sets the serializer send collection java type. -+ */ -+ public void setSendCollectionType(boolean sendType) -+ { -+ getSerializerFactory().setSendCollectionType(sendType); -+ } -+ -+ /** -+ * Sets whitelist mode for the deserializer -+ */ -+ public void setWhitelist(boolean isWhitelist) -+ { -+ getSerializerFactory().getClassFactory().setWhitelist(isWhitelist); -+ } -+ -+ /** -+ * Adds an allow rule to the deserializer -+ * -+ * Examples: "java.util.*", "com.foo.io.Bean" -+ */ -+ public void allow(String pattern) -+ { -+ getSerializerFactory().getClassFactory().allow(pattern); -+ } -+ -+ /** -+ * Adds a deny rule to the deserializer -+ */ -+ public void deny(String pattern) -+ { -+ getSerializerFactory().getClassFactory().deny(pattern); -+ } -+ -+ /** -+ * Sets the debugging flag. -+ */ -+ public void setDebug(boolean isDebug) -+ { -+ _isDebug = isDebug; -+ } -+ -+ /** -+ * Sets the debugging log name. -+ */ -+ public void setLogName(String name) -+ { -+ _log = Logger.getLogger(name); -+ } -+ -+ /** -+ * Initialize the service, including the service object. -+ */ -+ public void init(ServletConfig config) throws ServletException { -+ super.init(config); -+ -+ try { -+ String homeClassValue = getInitParameter("home-class"); -+ -+ if ((homeClassValue != null) & homeClassValue.startsWith("#")) //for get bean from spring -+ { -+ SpringPrepareForSkeleton(config, homeClassValue); -+ } else { -+ LocalPrepareForSkeleton(); -+ } -+ -+ _homeSkeleton = new HessianSkeleton(_homeImpl, _homeAPI); -+ -+ if (_objectAPI != null) { -+ _homeSkeleton.setObjectClass(_objectAPI); -+ } -+ -+ if (_objectImpl != null) { -+ _objectSkeleton = new HessianSkeleton(_objectImpl, _objectAPI); -+ _objectSkeleton.setHomeClass(_homeAPI); -+ } else { -+ _objectSkeleton = _homeSkeleton; -+ } -+ -+ if ("true".equals(getInitParameter("debug"))) { -+ _isDebug = true; -+ } -+ -+ if ("false".equals(getInitParameter("send-collection-type"))) { -+ setSendCollectionType(false); -+ } -+ } catch (ServletException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new ServletException(e); -+ } -+ } -+ -+ /** -+ * TODO -+ * -+ * @param config -+ * @param homeClassValue -+ * @throws ServletException -+ */ -+ private void SpringPrepareForSkeleton(ServletConfig config, -+ String homeClassValue) -+ throws ClassNotFoundException, InstantiationException, -+ IllegalAccessException, ServletException { -+ if (getInitParameter("home-api") != null) { -+ String className = getInitParameter("home-api"); -+ _homeAPI = loadClass(className); -+ } -+ -+ String beanID = homeClassValue.substring(1, homeClassValue.length()); -+ ApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext()); -+ _homeImpl = wac.getBean(beanID); -+ -+ init(_homeImpl); -+ } -+ -+ /** -+ * @throws ClassNotFoundException -+ * @throws InstantiationException -+ * @throws IllegalAccessException -+ * @throws ServletException -+ */ -+ private void LocalPrepareForSkeleton() -+ throws ClassNotFoundException, InstantiationException, -+ IllegalAccessException, ServletException { -+ -+ if (_homeImpl != null) { -+ } -+ else if (getInitParameter("home-class") != null) { -+ String className = getInitParameter("home-class"); -+ -+ Class homeClass = loadClass(className); -+ -+ _homeImpl = homeClass.newInstance(); -+ -+ init(_homeImpl); -+ } -+ else if (getInitParameter("service-class") != null) { -+ String className = getInitParameter("service-class"); -+ -+ Class homeClass = loadClass(className); -+ -+ _homeImpl = homeClass.newInstance(); -+ -+ init(_homeImpl); -+ } -+ else { -+ if (getClass().equals(HessianServlet.class)) -+ throw new ServletException("server must extend HessianServlet"); -+ -+ _homeImpl = this; -+ } -+ -+ if (_homeAPI != null) { -+ } -+ else if (getInitParameter("home-api") != null) { -+ String className = getInitParameter("home-api"); -+ -+ _homeAPI = loadClass(className); -+ } -+ else if (getInitParameter("api-class") != null) { -+ String className = getInitParameter("api-class"); -+ -+ _homeAPI = loadClass(className); -+ } -+ else if (_homeImpl != null) { -+ _homeAPI = findRemoteAPI(_homeImpl.getClass()); -+ -+ if (_homeAPI == null) -+ _homeAPI = _homeImpl.getClass(); -+ -+ // _homeAPI = _homeImpl.getClass(); -+ } -+ -+ if (_objectImpl != null) { -+ } -+ else if (getInitParameter("object-class") != null) { -+ String className = getInitParameter("object-class"); -+ -+ Class objectClass = loadClass(className); -+ -+ _objectImpl = objectClass.newInstance(); -+ -+ init(_objectImpl); -+ } -+ -+ if (_objectAPI != null) { -+ } -+ else if (getInitParameter("object-api") != null) { -+ String className = getInitParameter("object-api"); -+ -+ _objectAPI = loadClass(className); -+ } -+ else if (_objectImpl != null) -+ _objectAPI = _objectImpl.getClass(); -+ -+ /* _homeSkeleton = new HessianSkeleton(_homeImpl, _homeAPI); -+ -+ if (_objectAPI != null) -+ _homeSkeleton.setObjectClass(_objectAPI); -+ -+ if (_objectImpl != null) { -+ _objectSkeleton = new HessianSkeleton(_objectImpl, _objectAPI); -+ _objectSkeleton.setHomeClass(_homeAPI); -+ } -+ else -+ _objectSkeleton = _homeSkeleton; -+ -+ if ("true".equals(getInitParameter("debug"))) { -+ } -+ -+ if ("false".equals(getInitParameter("send-collection-type"))) -+ setSendCollectionType(false); -+ } catch (ServletException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new ServletException(e); -+ } -+ */ -+ -+ } -+ -+ private Class findRemoteAPI(Class implClass) -+ { -+ -+ if (implClass == null || implClass.equals(GenericService.class)) -+ return null; -+ -+ Class []interfaces = implClass.getInterfaces(); -+ -+ if (interfaces.length == 1) -+ return interfaces[0]; -+ -+ return findRemoteAPI(implClass.getSuperclass()); -+ -+ } -+ -+ private Class loadClass(String className) -+ throws ClassNotFoundException -+ { -+ ClassLoader loader = getContextClassLoader(); -+ -+ if (loader != null) -+ return Class.forName(className, false, loader); -+ else -+ return Class.forName(className); -+ } -+ -+ protected ClassLoader getContextClassLoader() -+ { -+ return Thread.currentThread().getContextClassLoader(); -+ } -+ -+ private void init(Object service) -+ throws ServletException -+ { -+ if (! this.getClass().equals(HessianServlet.class)) { -+ } -+ else if (service instanceof Service) -+ ((Service) service).init(getServletConfig()); -+ else if (service instanceof Servlet) -+ ((Servlet) service).init(getServletConfig()); -+ } -+ -+ /** -+ * Execute a request. The path-info of the request selects the bean. -+ * Once the bean's selected, it will be applied. -+ */ -+ public void service(ServletRequest request, ServletResponse response) -+ throws IOException, ServletException -+ { -+ HttpServletRequest req = (HttpServletRequest) request; -+ HttpServletResponse res = (HttpServletResponse) response; -+ -+ if (! req.getMethod().equals("POST")) { -+ res.setStatus(500); // , "Hessian Requires POST"); -+ PrintWriter out = res.getWriter(); -+ -+ res.setContentType("text/html"); -+ out.println("

Hessian Requires POST

"); -+ -+ return; -+ } -+ -+ String serviceId = req.getPathInfo(); -+ String objectId = req.getParameter("id"); -+ if (objectId == null) -+ objectId = req.getParameter("ejbid"); -+ -+ ServiceContext.begin(req, res, serviceId, objectId); -+ -+ try { -+ InputStream is = request.getInputStream(); -+ OutputStream os = response.getOutputStream(); -+ -+ response.setContentType("x-application/hessian"); -+ -+ SerializerFactory serializerFactory = getSerializerFactory(); -+ -+ invoke(is, os, objectId, serializerFactory); -+ } catch (RuntimeException e) { -+ throw e; -+ } catch (ServletException e) { -+ throw e; -+ } catch (Throwable e) { -+ throw new ServletException(e); -+ } finally { -+ ServiceContext.end(); -+ } -+ } -+ -+ protected void invoke(InputStream is, OutputStream os, -+ String objectId, -+ SerializerFactory serializerFactory) -+ throws Exception -+ { -+ if (objectId != null) -+ _objectSkeleton.invoke(is, os, serializerFactory); -+ else -+ _homeSkeleton.invoke(is, os, serializerFactory); -+ } -+ -+ protected Hessian2Input createHessian2Input(InputStream is) -+ { -+ return new Hessian2Input(is); -+ } -+ -+ static class LogWriter extends Writer { -+ private Logger _log; -+ private StringBuilder _sb = new StringBuilder(); -+ -+ LogWriter(Logger log) -+ { -+ _log = log; -+ } -+ -+ public void write(char ch) -+ { -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.fine(_sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ -+ public void write(char []buffer, int offset, int length) -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = buffer[offset + i]; -+ -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.fine(_sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ } -+ -+ public void flush() -+ { -+ } -+ -+ public void close() -+ { -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/server/HessianSkeleton.java hessian-4.0.65-fix/com/caucho/hessian/server/HessianSkeleton.java ---- hessian-4.0.65-src/com/caucho/hessian/server/HessianSkeleton.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/server/HessianSkeleton.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,416 +1,416 @@ --/* -- * Copyright (c) 2001-2009 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.server; -- --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; --import java.io.PrintWriter; --import java.io.Writer; --import java.lang.reflect.InvocationTargetException; --import java.lang.reflect.Method; --import java.util.logging.Level; --import java.util.logging.Logger; -- --import com.caucho.hessian.io.AbstractHessianInput; --import com.caucho.hessian.io.AbstractHessianOutput; --import com.caucho.hessian.io.HessianDebugInputStream; --import com.caucho.hessian.io.HessianDebugOutputStream; --import com.caucho.hessian.io.HessianFactory; --import com.caucho.hessian.io.HessianInputFactory; --import com.caucho.hessian.io.SerializerFactory; --import com.caucho.services.server.AbstractSkeleton; --import com.caucho.services.server.ServiceContext; -- --/** -- * Proxy class for Hessian services. -- */ --public class HessianSkeleton extends AbstractSkeleton { -- private static final Logger log -- = Logger.getLogger(HessianSkeleton.class.getName()); -- -- private boolean _isDebug; -- -- private HessianInputFactory _inputFactory = new HessianInputFactory(); -- private HessianFactory _hessianFactory = new HessianFactory(); -- -- private Object _service; -- -- /** -- * Create a new hessian skeleton. -- * -- * @param service the underlying service object. -- * @param apiClass the API interface -- */ -- public HessianSkeleton(Object service, Class apiClass) -- { -- super(apiClass); -- -- if (service == null) -- service = this; -- -- _service = service; -- -- if (! apiClass.isAssignableFrom(service.getClass())) -- throw new IllegalArgumentException("Service " + service + " must be an instance of " + apiClass.getName()); -- } -- -- /** -- * Create a new hessian skeleton. -- * -- * @param service the underlying service object. -- * @param apiClass the API interface -- */ -- public HessianSkeleton(Class apiClass) -- { -- super(apiClass); -- } -- -- public void setDebug(boolean isDebug) -- { -- _isDebug = isDebug; -- } -- -- public boolean isDebug() -- { -- return _isDebug; -- } -- -- public void setHessianFactory(HessianFactory factory) -- { -- _hessianFactory = factory; -- } -- -- /** -- * Invoke the object with the request from the input stream. -- * -- * @param in the Hessian input stream -- * @param out the Hessian output stream -- */ -- public void invoke(InputStream is, OutputStream os) -- throws Exception -- { -- invoke(is, os, null); -- } -- -- /** -- * Invoke the object with the request from the input stream. -- * -- * @param in the Hessian input stream -- * @param out the Hessian output stream -- */ -- public void invoke(InputStream is, OutputStream os, -- SerializerFactory serializerFactory) -- throws Exception -- { -- boolean isDebug = false; -- -- if (isDebugInvoke()) { -- isDebug = true; -- -- PrintWriter dbg = createDebugPrintWriter(); -- HessianDebugInputStream dIs = new HessianDebugInputStream(is, dbg); -- dIs.startTop2(); -- is = dIs; -- HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); -- dOs.startTop2(); -- os = dOs; -- } -- -- HessianInputFactory.HeaderType header = _inputFactory.readHeader(is); -- -- AbstractHessianInput in; -- AbstractHessianOutput out; -- -- switch (header) { -- case CALL_1_REPLY_1: -- in = _hessianFactory.createHessianInput(is); -- out = _hessianFactory.createHessianOutput(os); -- break; -- -- case CALL_1_REPLY_2: -- in = _hessianFactory.createHessianInput(is); -- out = _hessianFactory.createHessian2Output(os); -- break; -- -- case HESSIAN_2: -- in = _hessianFactory.createHessian2Input(is); -- in.readCall(); -- out = _hessianFactory.createHessian2Output(os); -- break; -- -- default: -- throw new IllegalStateException(header + " is an unknown Hessian call"); -- } -- -- if (serializerFactory != null) { -- in.setSerializerFactory(serializerFactory); -- out.setSerializerFactory(serializerFactory); -- } -- -- try { -- invoke(_service, in, out); -- } finally { -- in.close(); -- out.close(); -- -- if (isDebug) -- os.close(); -- } -- } -- -- /** -- * Invoke the object with the request from the input stream. -- * -- * @param in the Hessian input stream -- * @param out the Hessian output stream -- */ -- public void invoke(AbstractHessianInput in, AbstractHessianOutput out) -- throws Exception -- { -- invoke(_service, in, out); -- } -- -- /** -- * Invoke the object with the request from the input stream. -- * -- * @param in the Hessian input stream -- * @param out the Hessian output stream -- */ -- public void invoke(Object service, -- AbstractHessianInput in, -- AbstractHessianOutput out) -- throws Exception -- { -- ServiceContext context = ServiceContext.getContext(); -- -- // backward compatibility for some frameworks that don't read -- // the call type first -- in.skipOptionalCall(); -- -- // Hessian 1.0 backward compatibility -- String header; -- while ((header = in.readHeader()) != null) { -- Object value = in.readObject(); -- -- context.addHeader(header, value); -- } -- -- String methodName = in.readMethod(); -- int argLength = in.readMethodArgLength(); -- -- Method method; -- -- method = getMethod(methodName + "__" + argLength); -- -- if (method == null) -- method = getMethod(methodName); -- -- if (method != null) { -- } -- else if ("_hessian_getAttribute".equals(methodName)) { -- String attrName = in.readString(); -- in.completeCall(); -- -- String value = null; -- -- if ("java.api.class".equals(attrName)) -- value = getAPIClassName(); -- else if ("java.home.class".equals(attrName)) -- value = getHomeClassName(); -- else if ("java.object.class".equals(attrName)) -- value = getObjectClassName(); -- -- out.writeReply(value); -- out.close(); -- return; -- } -- else if (method == null) { -- out.writeFault("NoSuchMethodException", -- escapeMessage("The service has no method named: " + in.getMethod()), -- null); -- out.close(); -- return; -- } -- -- Class []args = method.getParameterTypes(); -- -- if (argLength != args.length && argLength >= 0) { -- out.writeFault("NoSuchMethod", -- escapeMessage("method " + method + " argument length mismatch, received length=" + argLength), -- null); -- out.close(); -- return; -- } -- -- Object []values = new Object[args.length]; -- -- for (int i = 0; i < args.length; i++) { -- // XXX: needs Marshal object -- values[i] = in.readObject(args[i]); -- } -- -- Object result = null; -- -- try { -- result = method.invoke(service, values); -- } catch (Exception e) { -- Throwable e1 = e; -- if (e1 instanceof InvocationTargetException) -- e1 = ((InvocationTargetException) e).getTargetException(); -- -- log.log(Level.FINE, this + " " + e1.toString(), e1); -- -- out.writeFault("ServiceException", -- escapeMessage(e1.getMessage()), -- e1); -- out.close(); -- return; -- } -- -- // The complete call needs to be after the invoke to handle a -- // trailing InputStream -- in.completeCall(); -- -- out.writeReply(result); -- -- out.close(); -- } -- -- private String escapeMessage(String msg) -- { -- if (msg == null) -- return null; -- -- StringBuilder sb = new StringBuilder(); -- -- int length = msg.length(); -- for (int i = 0; i < length; i++) { -- char ch = msg.charAt(i); -- -- switch (ch) { -- case '<': -- sb.append("<"); -- break; -- case '>': -- sb.append(">"); -- break; -- case 0x0: -- sb.append("�"); -- break; -- case '&': -- sb.append("&"); -- break; -- default: -- sb.append(ch); -- break; -- } -- } -- -- return sb.toString(); -- } -- -- protected boolean isDebugInvoke() -- { -- return (log.isLoggable(Level.FINEST) -- || isDebug() && log.isLoggable(Level.FINE)); -- } -- -- /** -- * Creates the PrintWriter for debug output. The default is to -- * write to java.util.Logging. -- */ -- protected PrintWriter createDebugPrintWriter() -- throws IOException -- { -- return new PrintWriter(new LogWriter(log)); -- } -- -- static class LogWriter extends Writer { -- private Logger _log; -- private StringBuilder _sb = new StringBuilder(); -- -- LogWriter(Logger log) -- { -- _log = log; -- } -- -- public void write(char ch) -- { -- if (ch == '\n' && _sb.length() > 0) { -- _log.fine(_sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- -- public void write(char []buffer, int offset, int length) -- { -- for (int i = 0; i < length; i++) { -- char ch = buffer[offset + i]; -- -- if (ch == '\n' && _sb.length() > 0) { -- _log.fine(_sb.toString()); -- _sb.setLength(0); -- } -- else -- _sb.append((char) ch); -- } -- } -- -- public void flush() -- { -- } -- -- public void close() -- { -- } -- } --} -+/* -+ * Copyright (c) 2001-2009 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.server; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.io.PrintWriter; -+import java.io.Writer; -+import java.lang.reflect.InvocationTargetException; -+import java.lang.reflect.Method; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import com.caucho.hessian.io.AbstractHessianInput; -+import com.caucho.hessian.io.AbstractHessianOutput; -+import com.caucho.hessian.io.HessianDebugInputStream; -+import com.caucho.hessian.io.HessianDebugOutputStream; -+import com.caucho.hessian.io.HessianFactory; -+import com.caucho.hessian.io.HessianInputFactory; -+import com.caucho.hessian.io.SerializerFactory; -+import com.caucho.services.server.AbstractSkeleton; -+import com.caucho.services.server.ServiceContext; -+ -+/** -+ * Proxy class for Hessian services. -+ */ -+public class HessianSkeleton extends AbstractSkeleton { -+ private static final Logger log -+ = Logger.getLogger(HessianSkeleton.class.getName()); -+ -+ private boolean _isDebug; -+ -+ private HessianInputFactory _inputFactory = new HessianInputFactory(); -+ private HessianFactory _hessianFactory = new HessianFactory(); -+ -+ private Object _service; -+ -+ /** -+ * Create a new hessian skeleton. -+ * -+ * @param service the underlying service object. -+ * @param apiClass the API interface -+ */ -+ public HessianSkeleton(Object service, Class apiClass) -+ { -+ super(apiClass); -+ -+ if (service == null) -+ service = this; -+ -+ _service = service; -+ -+ if (! apiClass.isAssignableFrom(service.getClass())) -+ throw new IllegalArgumentException("Service " + service + " must be an instance of " + apiClass.getName()); -+ } -+ -+ /** -+ * Create a new hessian skeleton. -+ * -+ * @param service the underlying service object. -+ * @param apiClass the API interface -+ */ -+ public HessianSkeleton(Class apiClass) -+ { -+ super(apiClass); -+ } -+ -+ public void setDebug(boolean isDebug) -+ { -+ _isDebug = isDebug; -+ } -+ -+ public boolean isDebug() -+ { -+ return _isDebug; -+ } -+ -+ public void setHessianFactory(HessianFactory factory) -+ { -+ _hessianFactory = factory; -+ } -+ -+ /** -+ * Invoke the object with the request from the input stream. -+ * -+ * @param in the Hessian input stream -+ * @param out the Hessian output stream -+ */ -+ public void invoke(InputStream is, OutputStream os) -+ throws Exception -+ { -+ invoke(is, os, null); -+ } -+ -+ /** -+ * Invoke the object with the request from the input stream. -+ * -+ * @param in the Hessian input stream -+ * @param out the Hessian output stream -+ */ -+ public void invoke(InputStream is, OutputStream os, -+ SerializerFactory serializerFactory) -+ throws Exception -+ { -+ boolean isDebug = false; -+ -+ if (isDebugInvoke()) { -+ isDebug = true; -+ -+ PrintWriter dbg = createDebugPrintWriter(); -+ HessianDebugInputStream dIs = new HessianDebugInputStream(is, dbg); -+ dIs.startTop2(); -+ is = dIs; -+ HessianDebugOutputStream dOs = new HessianDebugOutputStream(os, dbg); -+ dOs.startTop2(); -+ os = dOs; -+ } -+ -+ HessianInputFactory.HeaderType header = _inputFactory.readHeader(is); -+ -+ AbstractHessianInput in; -+ AbstractHessianOutput out; -+ -+ switch (header) { -+ case CALL_1_REPLY_1: -+ in = _hessianFactory.createHessianInput(is); -+ out = _hessianFactory.createHessianOutput(os); -+ break; -+ -+ case CALL_1_REPLY_2: -+ in = _hessianFactory.createHessianInput(is); -+ out = _hessianFactory.createHessian2Output(os); -+ break; -+ -+ case HESSIAN_2: -+ in = _hessianFactory.createHessian2Input(is); -+ in.readCall(); -+ out = _hessianFactory.createHessian2Output(os); -+ break; -+ -+ default: -+ throw new IllegalStateException(header + " is an unknown Hessian call"); -+ } -+ -+ if (serializerFactory != null) { -+ in.setSerializerFactory(serializerFactory); -+ out.setSerializerFactory(serializerFactory); -+ } -+ -+ try { -+ invoke(_service, in, out); -+ } finally { -+ in.close(); -+ out.close(); -+ -+ if (isDebug) -+ os.close(); -+ } -+ } -+ -+ /** -+ * Invoke the object with the request from the input stream. -+ * -+ * @param in the Hessian input stream -+ * @param out the Hessian output stream -+ */ -+ public void invoke(AbstractHessianInput in, AbstractHessianOutput out) -+ throws Exception -+ { -+ invoke(_service, in, out); -+ } -+ -+ /** -+ * Invoke the object with the request from the input stream. -+ * -+ * @param in the Hessian input stream -+ * @param out the Hessian output stream -+ */ -+ public void invoke(Object service, -+ AbstractHessianInput in, -+ AbstractHessianOutput out) -+ throws Exception -+ { -+ ServiceContext context = ServiceContext.getContext(); -+ -+ // backward compatibility for some frameworks that don't read -+ // the call type first -+ in.skipOptionalCall(); -+ -+ // Hessian 1.0 backward compatibility -+ String header; -+ while ((header = in.readHeader()) != null) { -+ Object value = in.readObject(); -+ -+ context.addHeader(header, value); -+ } -+ -+ String methodName = in.readMethod(); -+ int argLength = in.readMethodArgLength(); -+ -+ Method method; -+ -+ method = getMethod(methodName + "__" + argLength); -+ -+ if (method == null) -+ method = getMethod(methodName); -+ -+ if (method != null) { -+ } -+ else if ("_hessian_getAttribute".equals(methodName)) { -+ String attrName = in.readString(); -+ in.completeCall(); -+ -+ String value = null; -+ -+ if ("java.api.class".equals(attrName)) -+ value = getAPIClassName(); -+ else if ("java.home.class".equals(attrName)) -+ value = getHomeClassName(); -+ else if ("java.object.class".equals(attrName)) -+ value = getObjectClassName(); -+ -+ out.writeReply(value); -+ out.close(); -+ return; -+ } -+ else if (method == null) { -+ out.writeFault("NoSuchMethodException", -+ escapeMessage("The service has no method named: " + in.getMethod()), -+ null); -+ out.close(); -+ return; -+ } -+ -+ Class []args = method.getParameterTypes(); -+ -+ if (argLength != args.length && argLength >= 0) { -+ out.writeFault("NoSuchMethod", -+ escapeMessage("method " + method + " argument length mismatch, received length=" + argLength), -+ null); -+ out.close(); -+ return; -+ } -+ -+ Object []values = new Object[args.length]; -+ -+ for (int i = 0; i < args.length; i++) { -+ // XXX: needs Marshal object -+ values[i] = in.readObject(args[i]); -+ } -+ -+ Object result = null; -+ -+ try { -+ result = method.invoke(service, values); -+ } catch (Exception e) { -+ Throwable e1 = e; -+ if (e1 instanceof InvocationTargetException) -+ e1 = ((InvocationTargetException) e).getTargetException(); -+ -+ log.log(Level.FINE, this + " " + e1.toString(), e1); -+ -+ out.writeFault("ServiceException", -+ escapeMessage(e1.getMessage()), -+ e1); -+ out.close(); -+ return; -+ } -+ -+ // The complete call needs to be after the invoke to handle a -+ // trailing InputStream -+ in.completeCall(); -+ -+ out.writeReply(result); -+ -+ out.close(); -+ } -+ -+ private String escapeMessage(String msg) -+ { -+ if (msg == null) -+ return null; -+ -+ StringBuilder sb = new StringBuilder(); -+ -+ int length = msg.length(); -+ for (int i = 0; i < length; i++) { -+ char ch = msg.charAt(i); -+ -+ switch (ch) { -+ case '<': -+ sb.append("<"); -+ break; -+ case '>': -+ sb.append(">"); -+ break; -+ case 0x0: -+ sb.append("�"); -+ break; -+ case '&': -+ sb.append("&"); -+ break; -+ default: -+ sb.append(ch); -+ break; -+ } -+ } -+ -+ return sb.toString(); -+ } -+ -+ protected boolean isDebugInvoke() -+ { -+ return (log.isLoggable(Level.FINEST) -+ || isDebug() && log.isLoggable(Level.FINE)); -+ } -+ -+ /** -+ * Creates the PrintWriter for debug output. The default is to -+ * write to java.util.Logging. -+ */ -+ protected PrintWriter createDebugPrintWriter() -+ throws IOException -+ { -+ return new PrintWriter(new LogWriter(log)); -+ } -+ -+ static class LogWriter extends Writer { -+ private Logger _log; -+ private StringBuilder _sb = new StringBuilder(); -+ -+ LogWriter(Logger log) -+ { -+ _log = log; -+ } -+ -+ public void write(char ch) -+ { -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.fine(_sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ -+ public void write(char []buffer, int offset, int length) -+ { -+ for (int i = 0; i < length; i++) { -+ char ch = buffer[offset + i]; -+ -+ if (ch == '\n' && _sb.length() > 0) { -+ _log.fine(_sb.toString()); -+ _sb.setLength(0); -+ } -+ else -+ _sb.append((char) ch); -+ } -+ } -+ -+ public void flush() -+ { -+ } -+ -+ public void close() -+ { -+ } -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A0.java hessian-4.0.65-fix/com/caucho/hessian/test/A0.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A0.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A0.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A0 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A0 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A1.java hessian-4.0.65-fix/com/caucho/hessian/test/A1.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A1.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A1.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A1 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A1 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A10.java hessian-4.0.65-fix/com/caucho/hessian/test/A10.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A10.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A10.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A10 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A10 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A11.java hessian-4.0.65-fix/com/caucho/hessian/test/A11.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A11.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A11.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A11 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A11 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A12.java hessian-4.0.65-fix/com/caucho/hessian/test/A12.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A12.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A12.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A12 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A12 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A13.java hessian-4.0.65-fix/com/caucho/hessian/test/A13.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A13.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A13.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A13 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A13 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A14.java hessian-4.0.65-fix/com/caucho/hessian/test/A14.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A14.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A14.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A14 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A14 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A15.java hessian-4.0.65-fix/com/caucho/hessian/test/A15.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A15.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A15.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A15 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A15 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A16.java hessian-4.0.65-fix/com/caucho/hessian/test/A16.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A16.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A16.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A16 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A16 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A2.java hessian-4.0.65-fix/com/caucho/hessian/test/A2.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A2.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A2.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A2 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A2 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A3.java hessian-4.0.65-fix/com/caucho/hessian/test/A3.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A3.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A3.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A3 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A3 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A4.java hessian-4.0.65-fix/com/caucho/hessian/test/A4.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A4.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A4.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A4 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A4 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A5.java hessian-4.0.65-fix/com/caucho/hessian/test/A5.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A5.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A5.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A5 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A5 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A6.java hessian-4.0.65-fix/com/caucho/hessian/test/A6.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A6.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A6.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A6 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A6 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A7.java hessian-4.0.65-fix/com/caucho/hessian/test/A7.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A7.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A7.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A7 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A7 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A8.java hessian-4.0.65-fix/com/caucho/hessian/test/A8.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A8.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A8.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A8 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A8 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/A9.java hessian-4.0.65-fix/com/caucho/hessian/test/A9.java ---- hessian-4.0.65-src/com/caucho/hessian/test/A9.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/A9.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,18 +1,18 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * Empty object for short-encoding testing -- */ --public class A9 implements java.io.Serializable { -- public boolean equals(Object v) -- { -- return v != null && getClass().equals(v.getClass()); -- } -- -- public String toString() -- { -- return getClass().getName() + "[]"; -- } --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * Empty object for short-encoding testing -+ */ -+public class A9 implements java.io.Serializable { -+ public boolean equals(Object v) -+ { -+ return v != null && getClass().equals(v.getClass()); -+ } -+ -+ public String toString() -+ { -+ return getClass().getName() + "[]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/Test.java hessian-4.0.65-fix/com/caucho/hessian/test/Test.java ---- hessian-4.0.65-src/com/caucho/hessian/test/Test.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/Test.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,36 +1,36 @@ --package com.caucho.hessian.test; -- --import java.io.IOException; -- --/** -- * The Test service is a quick sanity check service. Developers of a -- * new Hessian implementation can use this service as an initial test. -- */ --public interface Test { -- /** -- * Does nothing. -- */ -- public void nullCall(); -- -- /** -- * Hello, World. -- */ -- public String hello(); -- -- /** -- * Subtraction -- */ -- public int subtract(int a, int b); -- -- /** -- * Echos the object to the server. -- *
--   */
--  public Object echo(Object value);
--  
--  /**
--   * Throws an application fault.
--   */
--  public void fault()
--    throws IOException;
--}
-+package com.caucho.hessian.test;
-+
-+import java.io.IOException;
-+
-+/**
-+ * The Test service is a quick sanity check service.  Developers of a
-+ * new Hessian implementation can use this service as an initial test.
-+ */
-+public interface Test {
-+  /**
-+   * Does nothing.
-+   */
-+  public void nullCall();
-+  
-+  /**
-+   * Hello, World.
-+   */
-+  public String hello();
-+  
-+  /**
-+   * Subtraction
-+   */
-+  public int subtract(int a, int b);
-+  
-+  /**
-+   * Echos the object to the server.
-+   * 
-+   */
-+  public Object echo(Object value);
-+  
-+  /**
-+   * Throws an application fault.
-+   */
-+  public void fault()
-+    throws IOException;
-+}
-diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestCons.java hessian-4.0.65-fix/com/caucho/hessian/test/TestCons.java
---- hessian-4.0.65-src/com/caucho/hessian/test/TestCons.java	2020-07-23 12:51:28.000000000 +0800
-+++ hessian-4.0.65-fix/com/caucho/hessian/test/TestCons.java	2023-08-15 18:39:22.000000000 +0800
-@@ -1,86 +1,86 @@
--package com.caucho.hessian.test;
--
--import java.io.IOException;
--import java.util.*;
--
--/**
-- * Cons-cell for testing
-- */
--public class TestCons implements java.io.Serializable {
--  private Object _first;
--  private Object _rest;
--
--  public TestCons()
--  {
--  }
--
--  public TestCons(Object first)
--  {
--    _first = first;
--  }
--
--  public TestCons(Object first, Object rest)
--  {
--    _first = first;
--    _rest = rest;
--  }
--
--  public Object getFirst()
--  {
--    return _first;
--  }
--
--  public void setFirst(Object first)
--  {
--    _first = first;
--  }
--
--  public Object getRest()
--  {
--    return _rest;
--  }
--
--  public void setRest(Object rest)
--  {
--    _rest = rest;
--  }
--
--  public boolean equals(Object o)
--  {
--    return toString().equals(o.toString());
--  }
--  
--  public String toString()
--  {
--    return toString(new HashMap());
--  }
--  
--  public String toString(HashMap map)
--  {
--    Object ref = map.get(this);
--
--    if (ref != null)
--      return "#" + ref;
--
--    map.put(this, map.size());
--
--    StringBuilder sb = new StringBuilder();
--    sb.append(getClass().getSimpleName()).append("[");
--
--    if (_first instanceof TestCons)
--      sb.append(((TestCons) _first).toString(map));
--    else
--      sb.append(_first);
--
--    sb.append(",");
--
--    if (_rest instanceof TestCons)
--      sb.append(((TestCons) _rest).toString(map));
--    else
--      sb.append(_rest);
--
--    sb.append("[");
--    
--    return sb.toString();
--  }
--}
-+package com.caucho.hessian.test;
-+
-+import java.io.IOException;
-+import java.util.*;
-+
-+/**
-+ * Cons-cell for testing
-+ */
-+public class TestCons implements java.io.Serializable {
-+  private Object _first;
-+  private Object _rest;
-+
-+  public TestCons()
-+  {
-+  }
-+
-+  public TestCons(Object first)
-+  {
-+    _first = first;
-+  }
-+
-+  public TestCons(Object first, Object rest)
-+  {
-+    _first = first;
-+    _rest = rest;
-+  }
-+
-+  public Object getFirst()
-+  {
-+    return _first;
-+  }
-+
-+  public void setFirst(Object first)
-+  {
-+    _first = first;
-+  }
-+
-+  public Object getRest()
-+  {
-+    return _rest;
-+  }
-+
-+  public void setRest(Object rest)
-+  {
-+    _rest = rest;
-+  }
-+
-+  public boolean equals(Object o)
-+  {
-+    return toString().equals(o.toString());
-+  }
-+  
-+  public String toString()
-+  {
-+    return toString(new HashMap());
-+  }
-+  
-+  public String toString(HashMap map)
-+  {
-+    Object ref = map.get(this);
-+
-+    if (ref != null)
-+      return "#" + ref;
-+
-+    map.put(this, map.size());
-+
-+    StringBuilder sb = new StringBuilder();
-+    sb.append(getClass().getSimpleName()).append("[");
-+
-+    if (_first instanceof TestCons)
-+      sb.append(((TestCons) _first).toString(map));
-+    else
-+      sb.append(_first);
-+
-+    sb.append(",");
-+
-+    if (_rest instanceof TestCons)
-+      sb.append(((TestCons) _rest).toString(map));
-+    else
-+      sb.append(_rest);
-+
-+    sb.append("[");
-+    
-+    return sb.toString();
-+  }
-+}
-diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2.java hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2.java
---- hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2.java	2020-07-23 12:51:28.000000000 +0800
-+++ hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2.java	2023-08-15 18:39:22.000000000 +0800
-@@ -1,1833 +1,1833 @@
--package com.caucho.hessian.test;
--
--import java.io.IOException;
--
--/**
-- * The Test service is a quick sanity check service.  Developers of a
-- * new Hessian implementation can use this service as an initial test.
-- *
-- * http://hessian.caucho.com/test/test2
-- */
--public interface TestHessian2 {
--  /**
--   * trivial null method call
--   *
--   * 
--   * H x02 x00
--   * C
--   *   x0a methodNull
--   *   x90
--   * 
-- * -- *
--   * R N
--   * 
-- */ -- public void methodNull(); -- -- // -- // result values -- // -- -- /** -- * Result of null -- * -- *
--   * R N
--   * 
-- */ -- public void replyNull(); -- -- // -- // boolean -- // -- -- /** -- * Boolean true -- * -- *
--   * T
--   * 
-- */ -- public Object replyTrue(); -- -- /** -- * Boolean false -- * -- *
--   * F
--   * 
-- */ -- public Object replyFalse(); -- -- // -- // integers -- // -- -- /** -- * Result of integer 0 -- * -- *
--   * R x90
--   * 
-- */ -- public int replyInt_0(); -- -- /** -- * Result of integer 1 -- * -- *
--   * R x91
--   * 
-- */ -- public int replyInt_1(); -- -- /** -- * Result of integer 47 -- * -- *
--   * R xbf
--   * 
-- */ -- public int replyInt_47(); -- -- /** -- * Result of integer -16 -- * -- *
--   * R x80
--   * 
-- */ -- public int replyInt_m16(); -- -- // two byte integers -- -- /** -- * Result of integer 0x30 -- * -- *
--   * R xc8 x30
--   * 
-- */ -- public int replyInt_0x30(); -- -- /** -- * Result of integer x7ff -- * -- *
--   * R xcf xff
--   * 
-- */ -- public int replyInt_0x7ff(); -- -- /** -- * Result of integer -17 -- * -- *
--   * R xc7 xef
--   * 
-- */ -- public int replyInt_m17(); -- -- /** -- * Result of integer -0x800 -- * -- *
--   * R xc0 x00
--   * 
-- */ -- public int replyInt_m0x800(); -- -- /** -- * Result of integer 0x800 -- * -- *
--   * R xd4 x08 x00
--   * 
-- */ -- public int replyInt_0x800(); -- -- /** -- * Result of integer 0x3ffff -- * -- *
--   * R xd7 xff xff
--   * 
-- */ -- public int replyInt_0x3ffff(); -- -- /** -- * Result of integer -0x801 -- * -- *
--   * R xd3 xf8 x00
--   * 
-- */ -- public int replyInt_m0x801(); -- -- /** -- * Result of integer m0x40000 -- * -- *
--   * R xd0 x00 x00
--   * 
-- */ -- public int replyInt_m0x40000(); -- -- // 5 byte integers -- -- /** -- * Result of integer 0x40000 -- * -- *
--   * R I x00 x04 x00 x00
--   * 
-- */ -- public int replyInt_0x40000(); -- -- /** -- * Result of integer 0x7fffffff -- * -- *
--   * R I x7f xff xff xff
--   * 
-- */ -- public int replyInt_0x7fffffff(); -- -- /** -- * Result of integer m0x40001 -- * -- *
--   * R I xff xf3 xff xf
--   * 
-- */ -- public int replyInt_m0x40001(); -- -- /** -- * Result of integer -0x80000000 -- * -- *
--   * R I x80 x00 x00 x00
--   * 
-- */ -- public int replyInt_m0x80000000(); -- -- // -- // longs -- // -- -- /** -- * Result of long 0 -- * -- *
--   * R xe0
--   * 
-- */ -- public long replyLong_0(); -- -- /** -- * Result of long 1 -- * -- *
--   * R xe1
--   * 
-- */ -- public long replyLong_1(); -- -- /** -- * Result of long 15 -- * -- *
--   * R xef
--   * 
-- */ -- public long replyLong_15(); -- -- /** -- * Result of long -8 -- * -- *
--   * R xd8
--   * 
-- */ -- public long replyLong_m8(); -- -- // two byte longs -- -- /** -- * Result of long 0x10 -- * -- *
--   * R xf8 x10
--   * 
-- */ -- public long replyLong_0x10(); -- -- /** -- * Result of long x7ff -- * -- *
--   * R xff xff
--   * 
-- */ -- public long replyLong_0x7ff(); -- -- /** -- * Result of long -9 -- * -- *
--   * R xf7 xf7
--   * 
-- */ -- public long replyLong_m9(); -- -- /** -- * Result of long -0x800 -- * -- *
--   * R xf0 x00
--   * 
-- */ -- public long replyLong_m0x800(); -- -- /** -- * Result of long 0x800 -- * -- *
--   * R x3c x08 x00
--   * 
-- */ -- public long replyLong_0x800(); -- -- /** -- * Result of long 0x3ffff -- * -- *
--   * R x3f xff xff
--   * 
-- */ -- public long replyLong_0x3ffff(); -- -- /** -- * Result of long -0x801 -- * -- *
--   * R x3b xf7 xff
--   * 
-- */ -- public long replyLong_m0x801(); -- -- /** -- * Result of long m0x40000 -- * -- *
--   * R x38 x00 x00
--   * 
-- */ -- public long replyLong_m0x40000(); -- -- // 5 byte longs -- -- /** -- * Result of long 0x40000 -- * -- *
--   * R x59 x00 x04 x00 x00
--   * 
-- */ -- public long replyLong_0x40000(); -- -- /** -- * Result of long 0x7fffffff -- * -- *
--   * R x59 x7f xff xff xff
--   * 
-- */ -- public long replyLong_0x7fffffff(); -- -- /** -- * Result of long m0x40001 -- * -- *
--   * R x59 xff xf3 xff xf
--   * 
-- */ -- public long replyLong_m0x40001(); -- -- /** -- * Result of long -0x80000000 -- * -- *
--   * R x59 x80 x00 x00 x00
--   * 
-- */ -- public long replyLong_m0x80000000(); -- -- /** -- * Result of long 0x80000000 -- * -- *
--   * R L x00 x00 x00 x00 x80 x00 x00 x00
--   * 
-- */ -- public long replyLong_0x80000000(); -- -- /** -- * Result of long -0x80000001 -- * -- *
--   * R L xff xff xff xff x7f xff xff xff
--   * 
-- */ -- public long replyLong_m0x80000001(); -- -- // -- // doubles -- // -- -- /** -- * Result of double 0.0 -- * -- *
--   * R x5b
--   * 
-- */ -- public double replyDouble_0_0(); -- -- /** -- * Result of double 1.0 -- * -- *
--   * R x5c
--   * 
-- */ -- public double replyDouble_1_0(); -- -- /** -- * Result of double 2.0 -- * -- *
--   * R x5d x02
--   * 
-- */ -- public double replyDouble_2_0(); -- -- /** -- * Result of double 127.0 -- * -- *
--   * R x5d x7f
--   * 
-- */ -- public double replyDouble_127_0(); -- -- /** -- * Result of double -128.0 -- * -- *
--   * R x5d x80
--   * 
-- */ -- public double replyDouble_m128_0(); -- -- /** -- * Result of double 128.0 -- * -- *
--   * R x5e x00 x80
--   * 
-- */ -- public double replyDouble_128_0(); -- -- /** -- * Result of double -129.0 -- * -- *
--   * R x5e xff x7f
--   * 
-- */ -- public double replyDouble_m129_0(); -- -- /** -- * Result of double 32767.0 -- * -- *
--   * R x5e x7f xff
--   * 
-- */ -- public double replyDouble_32767_0(); -- -- /** -- * Result of double -32768.0 -- * -- *
--   * R x5e x80 x80
--   * 
-- */ -- public double replyDouble_m32768_0(); -- -- /** -- * Result of double 0.001 -- * -- *
--   * R x5f x00 x00 x00 x01
--   * 
-- */ -- public double replyDouble_0_001(); -- -- /** -- * Result of double -0.001 -- * -- *
--   * R x5f xff xff xff xff
--   * 
-- */ -- public double replyDouble_m0_001(); -- -- /** -- * Result of double 65.536 -- * -- *
--   * R x5f x00 x01 x00 x00
--   * 
-- */ -- public double replyDouble_65_536(); -- -- /** -- * Result of double 3.14159 -- * -- *
--   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
--   * 
-- */ -- public double replyDouble_3_14159(); -- -- // -- // date -- // -- -- /** -- * date 0 (01-01-1970 00:00 GMT) -- * -- *
--   * x4a x00 x00 x00 x00
--   * 
-- */ -- public Object replyDate_0(); -- -- /** -- * Date by millisecond (05-08-1998 07:51:31.000 GMT) -- * -- *
--   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
--   * 
-- */ -- public Object replyDate_1(); -- -- /** -- * Date by minute (05-08-1998 07:51:00.000 GMT) -- * -- *
--   * x4b x00 xe3 x83 x8f
--   * 
-- */ -- public Object replyDate_2(); -- -- // -- // string length -- // -- -- /** -- * A zero-length string -- * -- *
--   * x00
--   * 
-- */ -- public String replyString_0(); -- -- /** -- * A null string -- * -- *
--   * N
--   * 
-- */ -- public String replyString_null(); -- -- /** -- * A one-length string -- * -- *
--   * x01 a
--   * 
-- */ -- public String replyString_1(); -- -- /** -- * A 31-length string -- * -- *
--   * x0f 0123456789012345678901234567890
--   * 
-- */ -- public String replyString_31(); -- -- /** -- * A 32-length string -- * -- *
--   * x30 x02 01234567890123456789012345678901
--   * 
-- */ -- public String replyString_32(); -- -- /** -- * A 1023-length string -- * -- *
--   * x33 xff 000 01234567890123456789012345678901...
--   * 
-- */ -- public String replyString_1023(); -- -- /** -- * A 1024-length string -- * -- *
--   * S x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public String replyString_1024(); -- -- /** -- * A 65536-length string -- * -- *
--   * R x80 x00 000 ...
--   * S x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public String replyString_65536(); -- -- // -- // binary length -- // -- -- /** -- * A zero-length binary -- * -- *
--   * x20
--   * 
-- */ -- public Object replyBinary_0(); -- -- /** -- * A null string -- * -- *
--   * N
--   * 
-- */ -- public Object replyBinary_null(); -- -- /** -- * A one-length string -- * -- *
--   * x01 0
--   * 
-- */ -- public Object replyBinary_1(); -- -- /** -- * A 15-length binary -- * -- *
--   * x2f 0123456789012345
--   * 
-- */ -- public Object replyBinary_15(); -- -- /** -- * A 16-length binary -- * -- *
--   * x34 x10 01234567890123456789012345678901
--   * 
-- */ -- public Object replyBinary_16(); -- -- /** -- * A 1023-length binary -- * -- *
--   * x37 xff 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object replyBinary_1023(); -- -- /** -- * A 1024-length binary -- * -- *
--   * B x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object replyBinary_1024(); -- -- /** -- * A 65536-length binary -- * -- *
--   * A x80 x00 000 ...
--   * B x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object replyBinary_65536(); -- -- // -- // lists -- // -- -- /** -- * Zero-length untyped list -- * -- *
--   * x78
--   * 
-- */ -- public Object replyUntypedFixedList_0(); -- -- /** -- * 1-length untyped list -- * -- *
--   * x79 x01 1
--   * 
-- */ -- public Object replyUntypedFixedList_1(); -- -- /** -- * 7-length untyped list -- * -- *
--   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
--   * 
-- */ -- public Object replyUntypedFixedList_7(); -- -- /** -- * 8-length untyped list -- * -- *
--   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
--   * 
-- */ -- public Object replyUntypedFixedList_8(); -- -- /** -- * Zero-length typed list (String array) -- * -- *
--   * x70 x07 [string
--   * 
-- */ -- public Object replyTypedFixedList_0(); -- -- /** -- * 1-length typed list (String array) -- * -- *
--   * x71 x07 [string x01 1
--   * 
-- */ -- public Object replyTypedFixedList_1(); -- -- /** -- * 7-length typed list (String array) -- * -- *
--   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
--   * 
-- */ -- public Object replyTypedFixedList_7(); -- -- /** -- * 8-length typed list (String array) -- * -- *
--   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
--   * 
-- */ -- public Object replyTypedFixedList_8(); -- -- // -- // untyped maps -- // -- -- /** -- * zero-length untyped map -- * -- *
--   * H Z
--   * 
-- */ -- public Object replyUntypedMap_0(); -- -- /** -- * untyped map with string key -- * -- *
--   * H x01 a x90 Z
--   * 
-- */ -- public Object replyUntypedMap_1(); -- -- /** -- * untyped map with int key -- * -- *
--   * H x90 x01 a x91 x01 b Z
--   * 
-- */ -- public Object replyUntypedMap_2(); -- -- /** -- * untyped map with list key -- * -- *
--   * H x71 x01 a x90 Z
--   * 
-- */ -- public Object replyUntypedMap_3(); -- -- // -- // typed maps -- // -- -- /** -- * zero-length typed map -- * -- *
--   * M x13 java.lang.Hashtable Z
--   * 
-- */ -- public Object replyTypedMap_0(); -- -- /** -- * untyped map with string key -- * -- *
--   * M x13 java.lang.Hashtable x01 a x90 Z
--   * 
-- */ -- public Object replyTypedMap_1(); -- -- /** -- * typed map with int key -- * -- *
--   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
--   * 
-- */ -- public Object replyTypedMap_2(); -- -- /** -- * typed map with list key -- * -- *
--   * M x13 java.lang.Hashtable x71 x01 a x90 Z
--   * 
-- */ -- public Object replyTypedMap_3(); -- -- // -- // objects -- // -- -- /** -- * Returns a single object -- * -- *
--   * C x1a com.caucho.hessian.test.A0 x90 x60
--   * 
-- */ -- public Object replyObject_0(); -- -- /** -- * Returns 16 object types -- * -- *
--   * X xa0
--   *  C x1a com.caucho.hessian.test.A0 x90 x60
--   *  C x1a com.caucho.hessian.test.A1 x90 x61
--   *  C x1a com.caucho.hessian.test.A2 x90 x62
--   *  C x1a com.caucho.hessian.test.A3 x90 x63
--   *  C x1a com.caucho.hessian.test.A4 x90 x64
--   *  C x1a com.caucho.hessian.test.A5 x90 x65
--   *  C x1a com.caucho.hessian.test.A6 x90 x66
--   *  C x1a com.caucho.hessian.test.A7 x90 x67
--   *  C x1a com.caucho.hessian.test.A8 x90 x68
--   *  C x1a com.caucho.hessian.test.A9 x90 x69
--   *  C x1b com.caucho.hessian.test.A10 x90 x6a
--   *  C x1b com.caucho.hessian.test.A11 x90 x6b
--   *  C x1b com.caucho.hessian.test.A12 x90 x6c
--   *  C x1b com.caucho.hessian.test.A13 x90 x6d
--   *  C x1b com.caucho.hessian.test.A14 x90 x6e
--   *  C x1b com.caucho.hessian.test.A15 x90 x6f
--   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
--   */
--  public Object replyObject_16();
--
--  /**
--   * Simple object with one field
--   *
--   * 
--   * C x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
--   * 
-- */ -- public Object replyObject_1(); -- -- /** -- * Simple two objects with one field -- * -- *
--   * x7a
--   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
--   *   x60 x90
--   *   x60 x91
--   * 
-- */ -- public Object replyObject_2(); -- -- /** -- * Simple repeated object -- * -- *
--   * x7a
--   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
--   *   x60 x90
--   *   Q x91
--   * 
-- */ -- public Object replyObject_2a(); -- -- /** -- * Two object with equals -- * -- *
--   * x7a
--   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
--   *   x60 x90
--   *   x60 x90
--   * 
-- */ -- public Object replyObject_2b(); -- -- /** -- * Circular object -- * -- *
--   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
--   *   x60 x01 a Q \x90x
--   * 
-- */ -- public Object replyObject_3(); -- -- // -- // arguments -- // -- -- /** -- * Null -- * -- *
--   * N
--   * 
-- */ -- public Object argNull(Object v); -- -- // -- // boolean -- // -- -- /** -- * Boolean true -- * -- *
--   * T
--   * 
-- */ -- public Object argTrue(Object v); -- -- /** -- * Boolean false -- * -- *
--   * F
--   * 
-- */ -- public Object argFalse(Object v); -- -- // -- // integer -- // -- -- /** -- * Integer 0 -- * -- *
--   * x90
--   * 
-- */ -- public Object argInt_0(Object v); -- -- /** -- * Integer 1 -- * -- *
--   * x91
--   * 
-- */ -- public Object argInt_1(Object v); -- -- /** -- * integer 47 -- * -- *
--   * xbf
--   * 
-- */ -- public Object argInt_47(Object v); -- -- /** -- * Result of integer -16 -- * -- *
--   * R x80
--   * 
-- */ -- public Object argInt_m16(Object v); -- -- // two byte integers -- -- /** -- * Integer 0x30 -- * -- *
--   * xc8 x30
--   * 
-- */ -- public Object argInt_0x30(Object v); -- -- /** -- * Result of integer x7ff -- * -- *
--   * xcf xff
--   * 
-- */ -- public Object argInt_0x7ff(Object v); -- -- /** -- * integer -17 -- * -- *
--   * xc7 xef
--   * 
-- */ -- public Object argInt_m17(Object v); -- -- /** -- * Integer -0x800 -- * -- *
--   * xc0 x00
--   * 
-- */ -- public Object argInt_m0x800(Object v); -- -- /** -- * Integer 0x800 -- * -- *
--   * xd4 x08 x00
--   * 
-- */ -- public Object argInt_0x800(Object v); -- -- /** -- * Integer 0x3ffff -- * -- *
--   * xd7 xff xff
--   * 
-- */ -- public Object argInt_0x3ffff(Object v); -- -- /** -- * Integer -0x801 -- * -- *
--   * xd3 xf8 x00
--   * 
-- */ -- public Object argInt_m0x801(Object v); -- -- /** -- * Integer m0x40000 -- * -- *
--   * xd0 x00 x00
--   * 
-- */ -- public Object argInt_m0x40000(Object v); -- -- // 5 byte integers -- -- /** -- * integer 0x40000 -- * -- *
--   * I x00 x04 x00 x00
--   * 
-- */ -- public Object argInt_0x40000(Object v); -- -- /** -- * Integer 0x7fffffff -- * -- *
--   * I x7f xff xff xff
--   * 
-- */ -- public Object argInt_0x7fffffff(Object v); -- -- /** -- * Integer m0x40001 -- * -- *
--   * I xff xfb xff xff
--   * 
-- */ -- public Object argInt_m0x40001(Object v); -- -- /** -- * Result of integer -0x80000000 -- * -- *
--   * I x80 x00 x00 x00
--   * 
-- */ -- public Object argInt_m0x80000000(Object v); -- -- // -- // longs -- // -- -- /** -- * long 0 -- * -- *
--   * xe0
--   * 
-- */ -- public Object argLong_0(Object v); -- -- /** -- * long 1 -- * -- *
--   * xe1
--   * 
-- */ -- public Object argLong_1(Object v); -- -- /** -- * long 15 -- * -- *
--   * xef
--   * 
-- */ -- public Object argLong_15(Object v); -- -- /** -- * long -8 -- * -- *
--   * xd8
--   * 
-- */ -- public Object argLong_m8(Object v); -- -- // two byte longs -- -- /** -- * long 0x10 -- * -- *
--   * xf8 x10
--   * 
-- */ -- public Object argLong_0x10(Object v); -- -- /** -- * long x7ff -- * -- *
--   * xff xff
--   * 
-- */ -- public Object argLong_0x7ff(Object v); -- -- /** -- * long -9 -- * -- *
--   * xf7 xf7
--   * 
-- */ -- public Object argLong_m9(Object v); -- -- /** -- * long -0x800 -- * -- *
--   * xf0 x00
--   * 
-- */ -- public Object argLong_m0x800(Object v); -- -- /** -- * long 0x800 -- * -- *
--   * x3c x08 x00
--   * 
-- */ -- public Object argLong_0x800(Object v); -- -- /** -- * long 0x3ffff -- * -- *
--   * x3f xff xff
--   * 
-- */ -- public Object argLong_0x3ffff(Object v); -- -- /** -- * long -0x801 -- * -- *
--   * x3b xf7 xff
--   * 
-- */ -- public Object argLong_m0x801(Object v); -- -- /** -- * long m0x40000 -- * -- *
--   * x38 x00 x00
--   * 
-- */ -- public Object argLong_m0x40000(Object v); -- -- // 5 byte longs -- -- /** -- * long 0x40000 -- * -- *
--   * x59 x00 x04 x00 x00
--   * 
-- */ -- public Object argLong_0x40000(Object v); -- -- /** -- * long 0x7fffffff -- * -- *
--   * x59 x7f xff xff xff
--   * 
-- */ -- public Object argLong_0x7fffffff(Object v); -- -- /** -- * long m0x40001 -- * -- *
--   * x59 xff xfb xff xf
--   * 
-- */ -- public Object argLong_m0x40001(Object v); -- -- /** -- * long -0x80000000 -- * -- *
--   * x59 x80 x00 x00 x00
--   * 
-- */ -- public Object argLong_m0x80000000(Object v); -- -- /** -- * Result of long 0x80000000 -- * -- *
--   * L x00 x00 x00 x00 x80 x00 x00 x00
--   * 
-- */ -- public Object argLong_0x80000000(Object v); -- -- /** -- * Result of long -0x80000001 -- * -- *
--   * L xff xff xff xff x7f xff xff xff
--   * 
-- */ -- public Object argLong_m0x80000001(Object v); -- -- // -- // doubles -- // -- -- /** -- * double 0.0 -- * -- *
--   * x5b
--   * 
-- */ -- public Object argDouble_0_0(Object v); -- -- /** -- * double 1.0 -- * -- *
--   * x5c
--   * 
-- */ -- public Object argDouble_1_0(Object v); -- -- /** -- * double 2.0 -- * -- *
--   * x5d x02
--   * 
-- */ -- public Object argDouble_2_0(Object v); -- -- /** -- * double 127.0 -- * -- *
--   * x5d x7f
--   * 
-- */ -- public Object argDouble_127_0(Object v); -- -- /** -- * double -128.0 -- * -- *
--   * x5d x80
--   * 
-- */ -- public Object argDouble_m128_0(Object v); -- -- /** -- * double 128.0 -- * -- *
--   * x5e x00 x80
--   * 
-- */ -- public Object argDouble_128_0(Object v); -- -- /** -- * double -129.0 -- * -- *
--   * x5e xff x7f
--   * 
-- */ -- public Object argDouble_m129_0(Object v); -- -- /** -- * double 32767.0 -- * -- *
--   * x5e x7f xff
--   * 
-- */ -- public Object argDouble_32767_0(Object v); -- -- /** -- * Double -32768.0 -- * -- *
--   * x5e x80 x80
--   * 
-- */ -- public Object argDouble_m32768_0(Object v); -- -- /** -- * double 0.001 -- * -- *
--   * x5f x00 x00 x00 x01
--   * 
-- */ -- public Object argDouble_0_001(Object v); -- -- /** -- * double -0.001 -- * -- *
--   * x5f xff xff xff xff
--   * 
-- */ -- public Object argDouble_m0_001(Object v); -- -- /** -- * double 65.536 -- * -- *
--   * x5f x00 x01 x00 x00
--   * 
-- */ -- public Object argDouble_65_536(Object v); -- -- /** -- * Result of double 3.14159 -- * -- *
--   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
--   * 
-- */ -- public Object argDouble_3_14159(Object v); -- -- // -- // date -- // -- -- /** -- * date 0 (01-01-1970 00:00 GMT) -- * -- *
--   * x4a x00 x00 x00 x00
--   * 
-- */ -- public Object argDate_0(Object v); -- -- /** -- * Date by millisecond (05-08-1998 07:51 GMT) -- * -- *
--   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
--   * 
-- */ -- public Object argDate_1(Object v); -- -- /** -- * Date by minute (05-08-1998 07:51 GMT) -- * -- *
--   * x4b x00 xe3 x83 x8f
--   * 
-- */ -- public Object argDate_2(Object v); -- -- // -- // string length -- // -- -- /** -- * A zero-length string -- * -- *
--   * x00
--   * 
-- */ -- public Object argString_0(Object v); -- -- /** -- * A one-length string -- * -- *
--   * x01 a
--   * 
-- */ -- public Object argString_1(Object v); -- -- /** -- * A 31-length string -- * -- *
--   * x0f 0123456789012345678901234567890
--   * 
-- */ -- public Object argString_31(Object v); -- -- /** -- * A 32-length string -- * -- *
--   * x30 x02 01234567890123456789012345678901
--   * 
-- */ -- public Object argString_32(Object v); -- -- /** -- * A 1023-length string -- * -- *
--   * x33 xff 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object argString_1023(Object v); -- -- /** -- * A 1024-length string -- * -- *
--   * S x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object argString_1024(Object v); -- -- /** -- * A 65536-length string -- * -- *
--   * R x80 x00 000 ...
--   * S x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object argString_65536(Object v); -- -- // -- // binary length -- // -- -- /** -- * A zero-length binary -- * -- *
--   * x20
--   * 
-- */ -- public Object argBinary_0(Object v); -- -- /** -- * A one-length string -- * -- *
--   * x21 0
--   * 
-- */ -- public Object argBinary_1(Object v); -- -- /** -- * A 15-length binary -- * -- *
--   * x2f 0123456789012345
--   * 
-- */ -- public Object argBinary_15(Object v); -- -- /** -- * A 16-length binary -- * -- *
--   * x34 x10 01234567890123456789012345678901
--   * 
-- */ -- public Object argBinary_16(Object v); -- -- /** -- * A 1023-length binary -- * -- *
--   * x37 xff 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object argBinary_1023(Object v); -- -- /** -- * A 1024-length binary -- * -- *
--   * B x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object argBinary_1024(Object v); -- -- /** -- * A 65536-length binary -- * -- *
--   * A x80 x00 000 ...
--   * B x04 x00 000 01234567890123456789012345678901...
--   * 
-- */ -- public Object argBinary_65536(Object v); -- -- // -- // lists -- // -- -- /** -- * Zero-length untyped list -- * -- *
--   * x78
--   * 
-- */ -- public Object argUntypedFixedList_0(Object v); -- -- /** -- * 1-length untyped list -- * -- *
--   * x79 x01 1
--   * 
-- */ -- public Object argUntypedFixedList_1(Object v); -- -- /** -- * 7-length untyped list -- * -- *
--   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
--   * 
-- */ -- public Object argUntypedFixedList_7(Object v); -- -- /** -- * 8-length untyped list -- * -- *
--   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
--   * 
-- */ -- public Object argUntypedFixedList_8(Object v); -- -- /** -- * Zero-length typed list (String array) -- * -- *
--   * x70 x07 [string
--   * 
-- */ -- public Object argTypedFixedList_0(Object v); -- -- /** -- * 1-length typed list (String array) -- * -- *
--   * x71 x07 [string x01 1
--   * 
-- */ -- public Object argTypedFixedList_1(Object v); -- -- /** -- * 7-length typed list (String array) -- * -- *
--   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
--   * 
-- */ -- public Object argTypedFixedList_7(Object v); -- -- /** -- * 8-length typed list (String array) -- * -- *
--   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
--   * 
-- */ -- public Object argTypedFixedList_8(Object v); -- -- // -- // untyped maps -- // -- -- /** -- * zero-length untyped map -- * -- *
--   * H Z
--   * 
-- */ -- public Object argUntypedMap_0(Object v); -- -- /** -- * untyped map with string key -- * -- *
--   * H x01 a x90 Z
--   * 
-- */ -- public Object argUntypedMap_1(Object v); -- -- /** -- * untyped map with int key -- * -- *
--   * H x90 x01 a x91 x01 b Z
--   * 
-- */ -- public Object argUntypedMap_2(Object v); -- -- /** -- * untyped map with list key -- * -- *
--   * H x71 x01 a x90 Z
--   * 
-- */ -- public Object argUntypedMap_3(Object v); -- -- // -- // typed maps -- // -- -- /** -- * zero-length typed map -- * -- *
--   * M x13 java.lang.Hashtable Z
--   * 
-- */ -- public Object argTypedMap_0(Object v); -- -- /** -- * untyped map with string key -- * -- *
--   * M x13 java.lang.Hashtable x01 a x90 Z
--   * 
-- */ -- public Object argTypedMap_1(Object v); -- -- /** -- * typed map with int key -- * -- *
--   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
--   * 
-- */ -- public Object argTypedMap_2(Object v); -- -- /** -- * typed map with list key -- * -- *
--   * M x13 java.lang.Hashtable x79 x01 a x90 Z
--   * 
-- */ -- public Object argTypedMap_3(Object v); -- -- // -- // objects -- // -- -- /** -- * Returns a single object -- * -- *
--   * C x1a com.caucho.hessian.test.A0 x90 x60
--   * 
-- */ -- public Object argObject_0(Object v); -- -- /** -- * Returns 16 object types -- * -- *
--   * X xa0
--   *  C x1a com.caucho.hessian.test.A0 x90 x60
--   *  C x1a com.caucho.hessian.test.A1 x90 x61
--   *  C x1a com.caucho.hessian.test.A2 x90 x62
--   *  C x1a com.caucho.hessian.test.A3 x90 x63
--   *  C x1a com.caucho.hessian.test.A4 x90 x64
--   *  C x1a com.caucho.hessian.test.A5 x90 x65
--   *  C x1a com.caucho.hessian.test.A6 x90 x66
--   *  C x1a com.caucho.hessian.test.A7 x90 x67
--   *  C x1a com.caucho.hessian.test.A8 x90 x68
--   *  C x1a com.caucho.hessian.test.A9 x90 x69
--   *  C x1b com.caucho.hessian.test.A10 x90 x6a
--   *  C x1b com.caucho.hessian.test.A11 x90 x6b
--   *  C x1b com.caucho.hessian.test.A12 x90 x6c
--   *  C x1b com.caucho.hessian.test.A13 x90 x6d
--   *  C x1b com.caucho.hessian.test.A14 x90 x6e
--   *  C x1b com.caucho.hessian.test.A15 x90 x6f
--   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
--   */
--  public Object argObject_16(Object v);
--
--  /**
--   * Simple object with one field
--   *
--   * 
--   * C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
--   * 
-- */ -- public Object argObject_1(Object v); -- -- /** -- * Simple two objects with one field -- * -- *
--   * x7a
--   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
--   *   x60 x90
--   *   x60 x91
--   * 
-- */ -- public Object argObject_2(Object v); -- -- /** -- * Simple repeated object -- * -- *
--   * x7a
--   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
--   *   x60 x90
--   *   Q x91
--   * 
-- */ -- public Object argObject_2a(Object v); -- -- /** -- * Two object with equals -- * -- *
--   * x7a
--   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
--   *   x60 x90
--   *   x60 x90
--   * 
-- */ -- public Object argObject_2b(Object v); -- -- /** -- * Circular object -- * -- *
--   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
--   *   x60 x01 a Q x90
--   * 
-- */ -- public Object argObject_3(Object v); --} -+package com.caucho.hessian.test; -+ -+import java.io.IOException; -+ -+/** -+ * The Test service is a quick sanity check service. Developers of a -+ * new Hessian implementation can use this service as an initial test. -+ * -+ * http://hessian.caucho.com/test/test2 -+ */ -+public interface TestHessian2 { -+ /** -+ * trivial null method call -+ * -+ *
-+   * H x02 x00
-+   * C
-+   *   x0a methodNull
-+   *   x90
-+   * 
-+ * -+ *
-+   * R N
-+   * 
-+ */ -+ public void methodNull(); -+ -+ // -+ // result values -+ // -+ -+ /** -+ * Result of null -+ * -+ *
-+   * R N
-+   * 
-+ */ -+ public void replyNull(); -+ -+ // -+ // boolean -+ // -+ -+ /** -+ * Boolean true -+ * -+ *
-+   * T
-+   * 
-+ */ -+ public Object replyTrue(); -+ -+ /** -+ * Boolean false -+ * -+ *
-+   * F
-+   * 
-+ */ -+ public Object replyFalse(); -+ -+ // -+ // integers -+ // -+ -+ /** -+ * Result of integer 0 -+ * -+ *
-+   * R x90
-+   * 
-+ */ -+ public int replyInt_0(); -+ -+ /** -+ * Result of integer 1 -+ * -+ *
-+   * R x91
-+   * 
-+ */ -+ public int replyInt_1(); -+ -+ /** -+ * Result of integer 47 -+ * -+ *
-+   * R xbf
-+   * 
-+ */ -+ public int replyInt_47(); -+ -+ /** -+ * Result of integer -16 -+ * -+ *
-+   * R x80
-+   * 
-+ */ -+ public int replyInt_m16(); -+ -+ // two byte integers -+ -+ /** -+ * Result of integer 0x30 -+ * -+ *
-+   * R xc8 x30
-+   * 
-+ */ -+ public int replyInt_0x30(); -+ -+ /** -+ * Result of integer x7ff -+ * -+ *
-+   * R xcf xff
-+   * 
-+ */ -+ public int replyInt_0x7ff(); -+ -+ /** -+ * Result of integer -17 -+ * -+ *
-+   * R xc7 xef
-+   * 
-+ */ -+ public int replyInt_m17(); -+ -+ /** -+ * Result of integer -0x800 -+ * -+ *
-+   * R xc0 x00
-+   * 
-+ */ -+ public int replyInt_m0x800(); -+ -+ /** -+ * Result of integer 0x800 -+ * -+ *
-+   * R xd4 x08 x00
-+   * 
-+ */ -+ public int replyInt_0x800(); -+ -+ /** -+ * Result of integer 0x3ffff -+ * -+ *
-+   * R xd7 xff xff
-+   * 
-+ */ -+ public int replyInt_0x3ffff(); -+ -+ /** -+ * Result of integer -0x801 -+ * -+ *
-+   * R xd3 xf8 x00
-+   * 
-+ */ -+ public int replyInt_m0x801(); -+ -+ /** -+ * Result of integer m0x40000 -+ * -+ *
-+   * R xd0 x00 x00
-+   * 
-+ */ -+ public int replyInt_m0x40000(); -+ -+ // 5 byte integers -+ -+ /** -+ * Result of integer 0x40000 -+ * -+ *
-+   * R I x00 x04 x00 x00
-+   * 
-+ */ -+ public int replyInt_0x40000(); -+ -+ /** -+ * Result of integer 0x7fffffff -+ * -+ *
-+   * R I x7f xff xff xff
-+   * 
-+ */ -+ public int replyInt_0x7fffffff(); -+ -+ /** -+ * Result of integer m0x40001 -+ * -+ *
-+   * R I xff xf3 xff xf
-+   * 
-+ */ -+ public int replyInt_m0x40001(); -+ -+ /** -+ * Result of integer -0x80000000 -+ * -+ *
-+   * R I x80 x00 x00 x00
-+   * 
-+ */ -+ public int replyInt_m0x80000000(); -+ -+ // -+ // longs -+ // -+ -+ /** -+ * Result of long 0 -+ * -+ *
-+   * R xe0
-+   * 
-+ */ -+ public long replyLong_0(); -+ -+ /** -+ * Result of long 1 -+ * -+ *
-+   * R xe1
-+   * 
-+ */ -+ public long replyLong_1(); -+ -+ /** -+ * Result of long 15 -+ * -+ *
-+   * R xef
-+   * 
-+ */ -+ public long replyLong_15(); -+ -+ /** -+ * Result of long -8 -+ * -+ *
-+   * R xd8
-+   * 
-+ */ -+ public long replyLong_m8(); -+ -+ // two byte longs -+ -+ /** -+ * Result of long 0x10 -+ * -+ *
-+   * R xf8 x10
-+   * 
-+ */ -+ public long replyLong_0x10(); -+ -+ /** -+ * Result of long x7ff -+ * -+ *
-+   * R xff xff
-+   * 
-+ */ -+ public long replyLong_0x7ff(); -+ -+ /** -+ * Result of long -9 -+ * -+ *
-+   * R xf7 xf7
-+   * 
-+ */ -+ public long replyLong_m9(); -+ -+ /** -+ * Result of long -0x800 -+ * -+ *
-+   * R xf0 x00
-+   * 
-+ */ -+ public long replyLong_m0x800(); -+ -+ /** -+ * Result of long 0x800 -+ * -+ *
-+   * R x3c x08 x00
-+   * 
-+ */ -+ public long replyLong_0x800(); -+ -+ /** -+ * Result of long 0x3ffff -+ * -+ *
-+   * R x3f xff xff
-+   * 
-+ */ -+ public long replyLong_0x3ffff(); -+ -+ /** -+ * Result of long -0x801 -+ * -+ *
-+   * R x3b xf7 xff
-+   * 
-+ */ -+ public long replyLong_m0x801(); -+ -+ /** -+ * Result of long m0x40000 -+ * -+ *
-+   * R x38 x00 x00
-+   * 
-+ */ -+ public long replyLong_m0x40000(); -+ -+ // 5 byte longs -+ -+ /** -+ * Result of long 0x40000 -+ * -+ *
-+   * R x59 x00 x04 x00 x00
-+   * 
-+ */ -+ public long replyLong_0x40000(); -+ -+ /** -+ * Result of long 0x7fffffff -+ * -+ *
-+   * R x59 x7f xff xff xff
-+   * 
-+ */ -+ public long replyLong_0x7fffffff(); -+ -+ /** -+ * Result of long m0x40001 -+ * -+ *
-+   * R x59 xff xf3 xff xf
-+   * 
-+ */ -+ public long replyLong_m0x40001(); -+ -+ /** -+ * Result of long -0x80000000 -+ * -+ *
-+   * R x59 x80 x00 x00 x00
-+   * 
-+ */ -+ public long replyLong_m0x80000000(); -+ -+ /** -+ * Result of long 0x80000000 -+ * -+ *
-+   * R L x00 x00 x00 x00 x80 x00 x00 x00
-+   * 
-+ */ -+ public long replyLong_0x80000000(); -+ -+ /** -+ * Result of long -0x80000001 -+ * -+ *
-+   * R L xff xff xff xff x7f xff xff xff
-+   * 
-+ */ -+ public long replyLong_m0x80000001(); -+ -+ // -+ // doubles -+ // -+ -+ /** -+ * Result of double 0.0 -+ * -+ *
-+   * R x5b
-+   * 
-+ */ -+ public double replyDouble_0_0(); -+ -+ /** -+ * Result of double 1.0 -+ * -+ *
-+   * R x5c
-+   * 
-+ */ -+ public double replyDouble_1_0(); -+ -+ /** -+ * Result of double 2.0 -+ * -+ *
-+   * R x5d x02
-+   * 
-+ */ -+ public double replyDouble_2_0(); -+ -+ /** -+ * Result of double 127.0 -+ * -+ *
-+   * R x5d x7f
-+   * 
-+ */ -+ public double replyDouble_127_0(); -+ -+ /** -+ * Result of double -128.0 -+ * -+ *
-+   * R x5d x80
-+   * 
-+ */ -+ public double replyDouble_m128_0(); -+ -+ /** -+ * Result of double 128.0 -+ * -+ *
-+   * R x5e x00 x80
-+   * 
-+ */ -+ public double replyDouble_128_0(); -+ -+ /** -+ * Result of double -129.0 -+ * -+ *
-+   * R x5e xff x7f
-+   * 
-+ */ -+ public double replyDouble_m129_0(); -+ -+ /** -+ * Result of double 32767.0 -+ * -+ *
-+   * R x5e x7f xff
-+   * 
-+ */ -+ public double replyDouble_32767_0(); -+ -+ /** -+ * Result of double -32768.0 -+ * -+ *
-+   * R x5e x80 x80
-+   * 
-+ */ -+ public double replyDouble_m32768_0(); -+ -+ /** -+ * Result of double 0.001 -+ * -+ *
-+   * R x5f x00 x00 x00 x01
-+   * 
-+ */ -+ public double replyDouble_0_001(); -+ -+ /** -+ * Result of double -0.001 -+ * -+ *
-+   * R x5f xff xff xff xff
-+   * 
-+ */ -+ public double replyDouble_m0_001(); -+ -+ /** -+ * Result of double 65.536 -+ * -+ *
-+   * R x5f x00 x01 x00 x00
-+   * 
-+ */ -+ public double replyDouble_65_536(); -+ -+ /** -+ * Result of double 3.14159 -+ * -+ *
-+   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
-+   * 
-+ */ -+ public double replyDouble_3_14159(); -+ -+ // -+ // date -+ // -+ -+ /** -+ * date 0 (01-01-1970 00:00 GMT) -+ * -+ *
-+   * x4a x00 x00 x00 x00
-+   * 
-+ */ -+ public Object replyDate_0(); -+ -+ /** -+ * Date by millisecond (05-08-1998 07:51:31.000 GMT) -+ * -+ *
-+   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
-+   * 
-+ */ -+ public Object replyDate_1(); -+ -+ /** -+ * Date by minute (05-08-1998 07:51:00.000 GMT) -+ * -+ *
-+   * x4b x00 xe3 x83 x8f
-+   * 
-+ */ -+ public Object replyDate_2(); -+ -+ // -+ // string length -+ // -+ -+ /** -+ * A zero-length string -+ * -+ *
-+   * x00
-+   * 
-+ */ -+ public String replyString_0(); -+ -+ /** -+ * A null string -+ * -+ *
-+   * N
-+   * 
-+ */ -+ public String replyString_null(); -+ -+ /** -+ * A one-length string -+ * -+ *
-+   * x01 a
-+   * 
-+ */ -+ public String replyString_1(); -+ -+ /** -+ * A 31-length string -+ * -+ *
-+   * x0f 0123456789012345678901234567890
-+   * 
-+ */ -+ public String replyString_31(); -+ -+ /** -+ * A 32-length string -+ * -+ *
-+   * x30 x02 01234567890123456789012345678901
-+   * 
-+ */ -+ public String replyString_32(); -+ -+ /** -+ * A 1023-length string -+ * -+ *
-+   * x33 xff 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public String replyString_1023(); -+ -+ /** -+ * A 1024-length string -+ * -+ *
-+   * S x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public String replyString_1024(); -+ -+ /** -+ * A 65536-length string -+ * -+ *
-+   * R x80 x00 000 ...
-+   * S x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public String replyString_65536(); -+ -+ // -+ // binary length -+ // -+ -+ /** -+ * A zero-length binary -+ * -+ *
-+   * x20
-+   * 
-+ */ -+ public Object replyBinary_0(); -+ -+ /** -+ * A null string -+ * -+ *
-+   * N
-+   * 
-+ */ -+ public Object replyBinary_null(); -+ -+ /** -+ * A one-length string -+ * -+ *
-+   * x01 0
-+   * 
-+ */ -+ public Object replyBinary_1(); -+ -+ /** -+ * A 15-length binary -+ * -+ *
-+   * x2f 0123456789012345
-+   * 
-+ */ -+ public Object replyBinary_15(); -+ -+ /** -+ * A 16-length binary -+ * -+ *
-+   * x34 x10 01234567890123456789012345678901
-+   * 
-+ */ -+ public Object replyBinary_16(); -+ -+ /** -+ * A 1023-length binary -+ * -+ *
-+   * x37 xff 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object replyBinary_1023(); -+ -+ /** -+ * A 1024-length binary -+ * -+ *
-+   * B x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object replyBinary_1024(); -+ -+ /** -+ * A 65536-length binary -+ * -+ *
-+   * A x80 x00 000 ...
-+   * B x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object replyBinary_65536(); -+ -+ // -+ // lists -+ // -+ -+ /** -+ * Zero-length untyped list -+ * -+ *
-+   * x78
-+   * 
-+ */ -+ public Object replyUntypedFixedList_0(); -+ -+ /** -+ * 1-length untyped list -+ * -+ *
-+   * x79 x01 1
-+   * 
-+ */ -+ public Object replyUntypedFixedList_1(); -+ -+ /** -+ * 7-length untyped list -+ * -+ *
-+   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
-+   * 
-+ */ -+ public Object replyUntypedFixedList_7(); -+ -+ /** -+ * 8-length untyped list -+ * -+ *
-+   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
-+   * 
-+ */ -+ public Object replyUntypedFixedList_8(); -+ -+ /** -+ * Zero-length typed list (String array) -+ * -+ *
-+   * x70 x07 [string
-+   * 
-+ */ -+ public Object replyTypedFixedList_0(); -+ -+ /** -+ * 1-length typed list (String array) -+ * -+ *
-+   * x71 x07 [string x01 1
-+   * 
-+ */ -+ public Object replyTypedFixedList_1(); -+ -+ /** -+ * 7-length typed list (String array) -+ * -+ *
-+   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
-+   * 
-+ */ -+ public Object replyTypedFixedList_7(); -+ -+ /** -+ * 8-length typed list (String array) -+ * -+ *
-+   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
-+   * 
-+ */ -+ public Object replyTypedFixedList_8(); -+ -+ // -+ // untyped maps -+ // -+ -+ /** -+ * zero-length untyped map -+ * -+ *
-+   * H Z
-+   * 
-+ */ -+ public Object replyUntypedMap_0(); -+ -+ /** -+ * untyped map with string key -+ * -+ *
-+   * H x01 a x90 Z
-+   * 
-+ */ -+ public Object replyUntypedMap_1(); -+ -+ /** -+ * untyped map with int key -+ * -+ *
-+   * H x90 x01 a x91 x01 b Z
-+   * 
-+ */ -+ public Object replyUntypedMap_2(); -+ -+ /** -+ * untyped map with list key -+ * -+ *
-+   * H x71 x01 a x90 Z
-+   * 
-+ */ -+ public Object replyUntypedMap_3(); -+ -+ // -+ // typed maps -+ // -+ -+ /** -+ * zero-length typed map -+ * -+ *
-+   * M x13 java.lang.Hashtable Z
-+   * 
-+ */ -+ public Object replyTypedMap_0(); -+ -+ /** -+ * untyped map with string key -+ * -+ *
-+   * M x13 java.lang.Hashtable x01 a x90 Z
-+   * 
-+ */ -+ public Object replyTypedMap_1(); -+ -+ /** -+ * typed map with int key -+ * -+ *
-+   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
-+   * 
-+ */ -+ public Object replyTypedMap_2(); -+ -+ /** -+ * typed map with list key -+ * -+ *
-+   * M x13 java.lang.Hashtable x71 x01 a x90 Z
-+   * 
-+ */ -+ public Object replyTypedMap_3(); -+ -+ // -+ // objects -+ // -+ -+ /** -+ * Returns a single object -+ * -+ *
-+   * C x1a com.caucho.hessian.test.A0 x90 x60
-+   * 
-+ */ -+ public Object replyObject_0(); -+ -+ /** -+ * Returns 16 object types -+ * -+ *
-+   * X xa0
-+   *  C x1a com.caucho.hessian.test.A0 x90 x60
-+   *  C x1a com.caucho.hessian.test.A1 x90 x61
-+   *  C x1a com.caucho.hessian.test.A2 x90 x62
-+   *  C x1a com.caucho.hessian.test.A3 x90 x63
-+   *  C x1a com.caucho.hessian.test.A4 x90 x64
-+   *  C x1a com.caucho.hessian.test.A5 x90 x65
-+   *  C x1a com.caucho.hessian.test.A6 x90 x66
-+   *  C x1a com.caucho.hessian.test.A7 x90 x67
-+   *  C x1a com.caucho.hessian.test.A8 x90 x68
-+   *  C x1a com.caucho.hessian.test.A9 x90 x69
-+   *  C x1b com.caucho.hessian.test.A10 x90 x6a
-+   *  C x1b com.caucho.hessian.test.A11 x90 x6b
-+   *  C x1b com.caucho.hessian.test.A12 x90 x6c
-+   *  C x1b com.caucho.hessian.test.A13 x90 x6d
-+   *  C x1b com.caucho.hessian.test.A14 x90 x6e
-+   *  C x1b com.caucho.hessian.test.A15 x90 x6f
-+   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
-+   */
-+  public Object replyObject_16();
-+
-+  /**
-+   * Simple object with one field
-+   *
-+   * 
-+   * C x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
-+   * 
-+ */ -+ public Object replyObject_1(); -+ -+ /** -+ * Simple two objects with one field -+ * -+ *
-+   * x7a
-+   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
-+   *   x60 x90
-+   *   x60 x91
-+   * 
-+ */ -+ public Object replyObject_2(); -+ -+ /** -+ * Simple repeated object -+ * -+ *
-+   * x7a
-+   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
-+   *   x60 x90
-+   *   Q x91
-+   * 
-+ */ -+ public Object replyObject_2a(); -+ -+ /** -+ * Two object with equals -+ * -+ *
-+   * x7a
-+   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
-+   *   x60 x90
-+   *   x60 x90
-+   * 
-+ */ -+ public Object replyObject_2b(); -+ -+ /** -+ * Circular object -+ * -+ *
-+   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
-+   *   x60 x01 a Q \x90x
-+   * 
-+ */ -+ public Object replyObject_3(); -+ -+ // -+ // arguments -+ // -+ -+ /** -+ * Null -+ * -+ *
-+   * N
-+   * 
-+ */ -+ public Object argNull(Object v); -+ -+ // -+ // boolean -+ // -+ -+ /** -+ * Boolean true -+ * -+ *
-+   * T
-+   * 
-+ */ -+ public Object argTrue(Object v); -+ -+ /** -+ * Boolean false -+ * -+ *
-+   * F
-+   * 
-+ */ -+ public Object argFalse(Object v); -+ -+ // -+ // integer -+ // -+ -+ /** -+ * Integer 0 -+ * -+ *
-+   * x90
-+   * 
-+ */ -+ public Object argInt_0(Object v); -+ -+ /** -+ * Integer 1 -+ * -+ *
-+   * x91
-+   * 
-+ */ -+ public Object argInt_1(Object v); -+ -+ /** -+ * integer 47 -+ * -+ *
-+   * xbf
-+   * 
-+ */ -+ public Object argInt_47(Object v); -+ -+ /** -+ * Result of integer -16 -+ * -+ *
-+   * R x80
-+   * 
-+ */ -+ public Object argInt_m16(Object v); -+ -+ // two byte integers -+ -+ /** -+ * Integer 0x30 -+ * -+ *
-+   * xc8 x30
-+   * 
-+ */ -+ public Object argInt_0x30(Object v); -+ -+ /** -+ * Result of integer x7ff -+ * -+ *
-+   * xcf xff
-+   * 
-+ */ -+ public Object argInt_0x7ff(Object v); -+ -+ /** -+ * integer -17 -+ * -+ *
-+   * xc7 xef
-+   * 
-+ */ -+ public Object argInt_m17(Object v); -+ -+ /** -+ * Integer -0x800 -+ * -+ *
-+   * xc0 x00
-+   * 
-+ */ -+ public Object argInt_m0x800(Object v); -+ -+ /** -+ * Integer 0x800 -+ * -+ *
-+   * xd4 x08 x00
-+   * 
-+ */ -+ public Object argInt_0x800(Object v); -+ -+ /** -+ * Integer 0x3ffff -+ * -+ *
-+   * xd7 xff xff
-+   * 
-+ */ -+ public Object argInt_0x3ffff(Object v); -+ -+ /** -+ * Integer -0x801 -+ * -+ *
-+   * xd3 xf8 x00
-+   * 
-+ */ -+ public Object argInt_m0x801(Object v); -+ -+ /** -+ * Integer m0x40000 -+ * -+ *
-+   * xd0 x00 x00
-+   * 
-+ */ -+ public Object argInt_m0x40000(Object v); -+ -+ // 5 byte integers -+ -+ /** -+ * integer 0x40000 -+ * -+ *
-+   * I x00 x04 x00 x00
-+   * 
-+ */ -+ public Object argInt_0x40000(Object v); -+ -+ /** -+ * Integer 0x7fffffff -+ * -+ *
-+   * I x7f xff xff xff
-+   * 
-+ */ -+ public Object argInt_0x7fffffff(Object v); -+ -+ /** -+ * Integer m0x40001 -+ * -+ *
-+   * I xff xfb xff xff
-+   * 
-+ */ -+ public Object argInt_m0x40001(Object v); -+ -+ /** -+ * Result of integer -0x80000000 -+ * -+ *
-+   * I x80 x00 x00 x00
-+   * 
-+ */ -+ public Object argInt_m0x80000000(Object v); -+ -+ // -+ // longs -+ // -+ -+ /** -+ * long 0 -+ * -+ *
-+   * xe0
-+   * 
-+ */ -+ public Object argLong_0(Object v); -+ -+ /** -+ * long 1 -+ * -+ *
-+   * xe1
-+   * 
-+ */ -+ public Object argLong_1(Object v); -+ -+ /** -+ * long 15 -+ * -+ *
-+   * xef
-+   * 
-+ */ -+ public Object argLong_15(Object v); -+ -+ /** -+ * long -8 -+ * -+ *
-+   * xd8
-+   * 
-+ */ -+ public Object argLong_m8(Object v); -+ -+ // two byte longs -+ -+ /** -+ * long 0x10 -+ * -+ *
-+   * xf8 x10
-+   * 
-+ */ -+ public Object argLong_0x10(Object v); -+ -+ /** -+ * long x7ff -+ * -+ *
-+   * xff xff
-+   * 
-+ */ -+ public Object argLong_0x7ff(Object v); -+ -+ /** -+ * long -9 -+ * -+ *
-+   * xf7 xf7
-+   * 
-+ */ -+ public Object argLong_m9(Object v); -+ -+ /** -+ * long -0x800 -+ * -+ *
-+   * xf0 x00
-+   * 
-+ */ -+ public Object argLong_m0x800(Object v); -+ -+ /** -+ * long 0x800 -+ * -+ *
-+   * x3c x08 x00
-+   * 
-+ */ -+ public Object argLong_0x800(Object v); -+ -+ /** -+ * long 0x3ffff -+ * -+ *
-+   * x3f xff xff
-+   * 
-+ */ -+ public Object argLong_0x3ffff(Object v); -+ -+ /** -+ * long -0x801 -+ * -+ *
-+   * x3b xf7 xff
-+   * 
-+ */ -+ public Object argLong_m0x801(Object v); -+ -+ /** -+ * long m0x40000 -+ * -+ *
-+   * x38 x00 x00
-+   * 
-+ */ -+ public Object argLong_m0x40000(Object v); -+ -+ // 5 byte longs -+ -+ /** -+ * long 0x40000 -+ * -+ *
-+   * x59 x00 x04 x00 x00
-+   * 
-+ */ -+ public Object argLong_0x40000(Object v); -+ -+ /** -+ * long 0x7fffffff -+ * -+ *
-+   * x59 x7f xff xff xff
-+   * 
-+ */ -+ public Object argLong_0x7fffffff(Object v); -+ -+ /** -+ * long m0x40001 -+ * -+ *
-+   * x59 xff xfb xff xf
-+   * 
-+ */ -+ public Object argLong_m0x40001(Object v); -+ -+ /** -+ * long -0x80000000 -+ * -+ *
-+   * x59 x80 x00 x00 x00
-+   * 
-+ */ -+ public Object argLong_m0x80000000(Object v); -+ -+ /** -+ * Result of long 0x80000000 -+ * -+ *
-+   * L x00 x00 x00 x00 x80 x00 x00 x00
-+   * 
-+ */ -+ public Object argLong_0x80000000(Object v); -+ -+ /** -+ * Result of long -0x80000001 -+ * -+ *
-+   * L xff xff xff xff x7f xff xff xff
-+   * 
-+ */ -+ public Object argLong_m0x80000001(Object v); -+ -+ // -+ // doubles -+ // -+ -+ /** -+ * double 0.0 -+ * -+ *
-+   * x5b
-+   * 
-+ */ -+ public Object argDouble_0_0(Object v); -+ -+ /** -+ * double 1.0 -+ * -+ *
-+   * x5c
-+   * 
-+ */ -+ public Object argDouble_1_0(Object v); -+ -+ /** -+ * double 2.0 -+ * -+ *
-+   * x5d x02
-+   * 
-+ */ -+ public Object argDouble_2_0(Object v); -+ -+ /** -+ * double 127.0 -+ * -+ *
-+   * x5d x7f
-+   * 
-+ */ -+ public Object argDouble_127_0(Object v); -+ -+ /** -+ * double -128.0 -+ * -+ *
-+   * x5d x80
-+   * 
-+ */ -+ public Object argDouble_m128_0(Object v); -+ -+ /** -+ * double 128.0 -+ * -+ *
-+   * x5e x00 x80
-+   * 
-+ */ -+ public Object argDouble_128_0(Object v); -+ -+ /** -+ * double -129.0 -+ * -+ *
-+   * x5e xff x7f
-+   * 
-+ */ -+ public Object argDouble_m129_0(Object v); -+ -+ /** -+ * double 32767.0 -+ * -+ *
-+   * x5e x7f xff
-+   * 
-+ */ -+ public Object argDouble_32767_0(Object v); -+ -+ /** -+ * Double -32768.0 -+ * -+ *
-+   * x5e x80 x80
-+   * 
-+ */ -+ public Object argDouble_m32768_0(Object v); -+ -+ /** -+ * double 0.001 -+ * -+ *
-+   * x5f x00 x00 x00 x01
-+   * 
-+ */ -+ public Object argDouble_0_001(Object v); -+ -+ /** -+ * double -0.001 -+ * -+ *
-+   * x5f xff xff xff xff
-+   * 
-+ */ -+ public Object argDouble_m0_001(Object v); -+ -+ /** -+ * double 65.536 -+ * -+ *
-+   * x5f x00 x01 x00 x00
-+   * 
-+ */ -+ public Object argDouble_65_536(Object v); -+ -+ /** -+ * Result of double 3.14159 -+ * -+ *
-+   * D x40 x09 x21 xf9 xf0 x1b x86 x6e
-+   * 
-+ */ -+ public Object argDouble_3_14159(Object v); -+ -+ // -+ // date -+ // -+ -+ /** -+ * date 0 (01-01-1970 00:00 GMT) -+ * -+ *
-+   * x4a x00 x00 x00 x00
-+   * 
-+ */ -+ public Object argDate_0(Object v); -+ -+ /** -+ * Date by millisecond (05-08-1998 07:51 GMT) -+ * -+ *
-+   * x4a x00 x00 x00 xd0 x4b x92 x84 xb8
-+   * 
-+ */ -+ public Object argDate_1(Object v); -+ -+ /** -+ * Date by minute (05-08-1998 07:51 GMT) -+ * -+ *
-+   * x4b x00 xe3 x83 x8f
-+   * 
-+ */ -+ public Object argDate_2(Object v); -+ -+ // -+ // string length -+ // -+ -+ /** -+ * A zero-length string -+ * -+ *
-+   * x00
-+   * 
-+ */ -+ public Object argString_0(Object v); -+ -+ /** -+ * A one-length string -+ * -+ *
-+   * x01 a
-+   * 
-+ */ -+ public Object argString_1(Object v); -+ -+ /** -+ * A 31-length string -+ * -+ *
-+   * x0f 0123456789012345678901234567890
-+   * 
-+ */ -+ public Object argString_31(Object v); -+ -+ /** -+ * A 32-length string -+ * -+ *
-+   * x30 x02 01234567890123456789012345678901
-+   * 
-+ */ -+ public Object argString_32(Object v); -+ -+ /** -+ * A 1023-length string -+ * -+ *
-+   * x33 xff 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object argString_1023(Object v); -+ -+ /** -+ * A 1024-length string -+ * -+ *
-+   * S x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object argString_1024(Object v); -+ -+ /** -+ * A 65536-length string -+ * -+ *
-+   * R x80 x00 000 ...
-+   * S x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object argString_65536(Object v); -+ -+ // -+ // binary length -+ // -+ -+ /** -+ * A zero-length binary -+ * -+ *
-+   * x20
-+   * 
-+ */ -+ public Object argBinary_0(Object v); -+ -+ /** -+ * A one-length string -+ * -+ *
-+   * x21 0
-+   * 
-+ */ -+ public Object argBinary_1(Object v); -+ -+ /** -+ * A 15-length binary -+ * -+ *
-+   * x2f 0123456789012345
-+   * 
-+ */ -+ public Object argBinary_15(Object v); -+ -+ /** -+ * A 16-length binary -+ * -+ *
-+   * x34 x10 01234567890123456789012345678901
-+   * 
-+ */ -+ public Object argBinary_16(Object v); -+ -+ /** -+ * A 1023-length binary -+ * -+ *
-+   * x37 xff 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object argBinary_1023(Object v); -+ -+ /** -+ * A 1024-length binary -+ * -+ *
-+   * B x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object argBinary_1024(Object v); -+ -+ /** -+ * A 65536-length binary -+ * -+ *
-+   * A x80 x00 000 ...
-+   * B x04 x00 000 01234567890123456789012345678901...
-+   * 
-+ */ -+ public Object argBinary_65536(Object v); -+ -+ // -+ // lists -+ // -+ -+ /** -+ * Zero-length untyped list -+ * -+ *
-+   * x78
-+   * 
-+ */ -+ public Object argUntypedFixedList_0(Object v); -+ -+ /** -+ * 1-length untyped list -+ * -+ *
-+   * x79 x01 1
-+   * 
-+ */ -+ public Object argUntypedFixedList_1(Object v); -+ -+ /** -+ * 7-length untyped list -+ * -+ *
-+   * x7f x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
-+   * 
-+ */ -+ public Object argUntypedFixedList_7(Object v); -+ -+ /** -+ * 8-length untyped list -+ * -+ *
-+   * X x98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
-+   * 
-+ */ -+ public Object argUntypedFixedList_8(Object v); -+ -+ /** -+ * Zero-length typed list (String array) -+ * -+ *
-+   * x70 x07 [string
-+   * 
-+ */ -+ public Object argTypedFixedList_0(Object v); -+ -+ /** -+ * 1-length typed list (String array) -+ * -+ *
-+   * x71 x07 [string x01 1
-+   * 
-+ */ -+ public Object argTypedFixedList_1(Object v); -+ -+ /** -+ * 7-length typed list (String array) -+ * -+ *
-+   * x77 x07 [string x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7
-+   * 
-+ */ -+ public Object argTypedFixedList_7(Object v); -+ -+ /** -+ * 8-length typed list (String array) -+ * -+ *
-+   * V x07 [stringx98 x01 1 x01 2 x01 3 x01 4 x01 5 x01 6 x01 7 x01 8
-+   * 
-+ */ -+ public Object argTypedFixedList_8(Object v); -+ -+ // -+ // untyped maps -+ // -+ -+ /** -+ * zero-length untyped map -+ * -+ *
-+   * H Z
-+   * 
-+ */ -+ public Object argUntypedMap_0(Object v); -+ -+ /** -+ * untyped map with string key -+ * -+ *
-+   * H x01 a x90 Z
-+   * 
-+ */ -+ public Object argUntypedMap_1(Object v); -+ -+ /** -+ * untyped map with int key -+ * -+ *
-+   * H x90 x01 a x91 x01 b Z
-+   * 
-+ */ -+ public Object argUntypedMap_2(Object v); -+ -+ /** -+ * untyped map with list key -+ * -+ *
-+   * H x71 x01 a x90 Z
-+   * 
-+ */ -+ public Object argUntypedMap_3(Object v); -+ -+ // -+ // typed maps -+ // -+ -+ /** -+ * zero-length typed map -+ * -+ *
-+   * M x13 java.lang.Hashtable Z
-+   * 
-+ */ -+ public Object argTypedMap_0(Object v); -+ -+ /** -+ * untyped map with string key -+ * -+ *
-+   * M x13 java.lang.Hashtable x01 a x90 Z
-+   * 
-+ */ -+ public Object argTypedMap_1(Object v); -+ -+ /** -+ * typed map with int key -+ * -+ *
-+   * M x13 java.lang.Hashtable x90 x01 a x91 x01 b Z
-+   * 
-+ */ -+ public Object argTypedMap_2(Object v); -+ -+ /** -+ * typed map with list key -+ * -+ *
-+   * M x13 java.lang.Hashtable x79 x01 a x90 Z
-+   * 
-+ */ -+ public Object argTypedMap_3(Object v); -+ -+ // -+ // objects -+ // -+ -+ /** -+ * Returns a single object -+ * -+ *
-+   * C x1a com.caucho.hessian.test.A0 x90 x60
-+   * 
-+ */ -+ public Object argObject_0(Object v); -+ -+ /** -+ * Returns 16 object types -+ * -+ *
-+   * X xa0
-+   *  C x1a com.caucho.hessian.test.A0 x90 x60
-+   *  C x1a com.caucho.hessian.test.A1 x90 x61
-+   *  C x1a com.caucho.hessian.test.A2 x90 x62
-+   *  C x1a com.caucho.hessian.test.A3 x90 x63
-+   *  C x1a com.caucho.hessian.test.A4 x90 x64
-+   *  C x1a com.caucho.hessian.test.A5 x90 x65
-+   *  C x1a com.caucho.hessian.test.A6 x90 x66
-+   *  C x1a com.caucho.hessian.test.A7 x90 x67
-+   *  C x1a com.caucho.hessian.test.A8 x90 x68
-+   *  C x1a com.caucho.hessian.test.A9 x90 x69
-+   *  C x1b com.caucho.hessian.test.A10 x90 x6a
-+   *  C x1b com.caucho.hessian.test.A11 x90 x6b
-+   *  C x1b com.caucho.hessian.test.A12 x90 x6c
-+   *  C x1b com.caucho.hessian.test.A13 x90 x6d
-+   *  C x1b com.caucho.hessian.test.A14 x90 x6e
-+   *  C x1b com.caucho.hessian.test.A15 x90 x6f
-+   *  C x1b com.caucho.hessian.test.A16 x90 O xa0
-+   */
-+  public Object argObject_16(Object v);
-+
-+  /**
-+   * Simple object with one field
-+   *
-+   * 
-+   * C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value x60 x90
-+   * 
-+ */ -+ public Object argObject_1(Object v); -+ -+ /** -+ * Simple two objects with one field -+ * -+ *
-+   * x7a
-+   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
-+   *   x60 x90
-+   *   x60 x91
-+   * 
-+ */ -+ public Object argObject_2(Object v); -+ -+ /** -+ * Simple repeated object -+ * -+ *
-+   * x7a
-+   *   C x30 x22 com.caucho.hessian.test.TestObject x91 x06 _value
-+   *   x60 x90
-+   *   Q x91
-+   * 
-+ */ -+ public Object argObject_2a(Object v); -+ -+ /** -+ * Two object with equals -+ * -+ *
-+   * x7a
-+   *   C x22 com.caucho.hessian.test.TestObject x91 x06 _value
-+   *   x60 x90
-+   *   x60 x90
-+   * 
-+ */ -+ public Object argObject_2b(Object v); -+ -+ /** -+ * Circular object -+ * -+ *
-+   * C x20 com.caucho.hessian.test.TestCons x91 x06 _first x05 _rest
-+   *   x60 x01 a Q x90
-+   * 
-+ */ -+ public Object argObject_3(Object v); -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2Servlet.java hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2Servlet.java ---- hessian-4.0.65-src/com/caucho/hessian/test/TestHessian2Servlet.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/TestHessian2Servlet.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,1805 +1,1805 @@ --package com.caucho.hessian.test; -- --import com.caucho.hessian.io.*; --import com.caucho.hessian.server.HessianServlet; --import java.io.*; --import java.util.*; -- --/** -- * The test service is a Hessian 2.0 protocol test for developers of -- * Hessian 2.0 clients. For a new client the recommended order is: -- * -- *
    -- *
  • methodNull -- *
  • methodHello -- *
-- */ --public class TestHessian2Servlet -- extends HessianServlet -- implements TestHessian2 --{ -- private ThreadLocal _threadWriter -- = new ThreadLocal(); -- -- public void methodNull() -- { -- } -- -- // -- // reply tests, testing serialization output -- // -- -- public void replyNull() -- { -- } -- -- // -- // boolean -- // -- -- public Object replyTrue() -- { -- return true; -- } -- -- public Object replyFalse() -- { -- return false; -- } -- -- // -- // integers -- // -- -- // single byte integers -- -- public int replyInt_0() -- { -- return 0; -- } -- -- public int replyInt_1() -- { -- return 1; -- } -- -- public int replyInt_47() -- { -- return 47; -- } -- -- public int replyInt_m16() -- { -- return -16; -- } -- -- // two byte integers -- -- public int replyInt_0x30() -- { -- return 0x30; -- } -- -- public int replyInt_0x7ff() -- { -- return 0x7ff; -- } -- -- public int replyInt_m17() -- { -- return -17; -- } -- -- public int replyInt_m0x800() -- { -- return -0x800; -- } -- -- // three byte integers -- -- public int replyInt_0x800() -- { -- return 0x800; -- } -- -- public int replyInt_0x3ffff() -- { -- return 0x3ffff; -- } -- -- public int replyInt_m0x801() -- { -- return -0x801; -- } -- -- public int replyInt_m0x40000() -- { -- return - 0x40000; -- } -- -- // 5 byte integers -- -- public int replyInt_0x40000() -- { -- return 0x40000; -- } -- -- public int replyInt_0x7fffffff() -- { -- return 0x7fffffff; -- } -- -- public int replyInt_m0x40001() -- { -- return - 0x40001; -- } -- -- public int replyInt_m0x80000000() -- { -- return - 0x80000000; -- } -- -- // -- // longs -- // -- -- // single byte longs -- -- public long replyLong_0() -- { -- return 0; -- } -- -- public long replyLong_1() -- { -- return 1; -- } -- -- public long replyLong_15() -- { -- return 15; -- } -- -- public long replyLong_m8() -- { -- return -8; -- } -- -- // two byte longs -- -- public long replyLong_0x10() -- { -- return 0x10; -- } -- -- public long replyLong_0x7ff() -- { -- return 0x7ff; -- } -- -- public long replyLong_m9() -- { -- return -9; -- } -- -- public long replyLong_m0x800() -- { -- return -0x800; -- } -- -- // three byte longs -- -- public long replyLong_0x800() -- { -- return 0x800; -- } -- -- public long replyLong_0x3ffff() -- { -- return 0x3ffff; -- } -- -- public long replyLong_m0x801() -- { -- return -0x801; -- } -- -- public long replyLong_m0x40000() -- { -- return - 0x40000; -- } -- -- // 5 byte longs -- -- public long replyLong_0x40000() -- { -- return 0x40000; -- } -- -- public long replyLong_0x7fffffff() -- { -- return 0x7fffffff; -- } -- -- public long replyLong_m0x40001() -- { -- return - 0x40001; -- } -- -- public long replyLong_m0x80000000() -- { -- return - 0x80000000; -- } -- -- public long replyLong_0x80000000() -- { -- return 0x80000000L; -- } -- -- public long replyLong_m0x80000001() -- { -- return - 0x80000001L; -- } -- -- // -- // doubles -- // -- -- public double replyDouble_0_0() -- { -- return 0; -- } -- -- public double replyDouble_1_0() -- { -- return 1; -- } -- -- public double replyDouble_2_0() -- { -- return 2; -- } -- -- public double replyDouble_127_0() -- { -- return 127; -- } -- -- public double replyDouble_m128_0() -- { -- return -128; -- } -- -- public double replyDouble_128_0() -- { -- return 128; -- } -- -- public double replyDouble_m129_0() -- { -- return -129; -- } -- -- public double replyDouble_32767_0() -- { -- return 32767; -- } -- -- public double replyDouble_m32768_0() -- { -- return -32768; -- } -- -- public double replyDouble_0_001() -- { -- return 0.001; -- } -- -- public double replyDouble_m0_001() -- { -- return - 0.001; -- } -- -- public double replyDouble_65_536() -- { -- return 65.536; -- } -- -- public double replyDouble_3_14159() -- { -- return 3.14159; -- } -- -- // date -- -- public Object replyDate_0() -- { -- return new Date(0); -- } -- -- public Object replyDate_1() -- { -- long time = 894621091000L; -- -- return new Date(time); -- } -- -- public Object replyDate_2() -- { -- long time = 894621091000L; -- -- time -= time % 60000L; -- -- return new Date(time); -- } -- -- // strings by length -- -- public String replyString_0() -- { -- return ""; -- } -- -- public String replyString_null() -- { -- return null; -- } -- -- public String replyString_1() -- { -- return "0"; -- } -- -- public String replyString_31() -- { -- return "0123456789012345678901234567890"; -- } -- -- public String replyString_32() -- { -- return "01234567890123456789012345678901"; -- } -- -- public String replyString_1023() -- { -- StringBuilder sb = new StringBuilder(); -- -- for (int i = 0; i < 16; i++) { -- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -- } -- -- sb.setLength(1023); -- -- return sb.toString(); -- } -- -- public String replyString_1024() -- { -- StringBuilder sb = new StringBuilder(); -- -- for (int i = 0; i < 16; i++) { -- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -- } -- -- sb.setLength(1024); -- -- return sb.toString(); -- } -- -- public String replyString_65536() -- { -- StringBuilder sb = new StringBuilder(); -- -- for (int i = 0; i < 64 * 16; i++) { -- sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); -- } -- -- sb.setLength(65536); -- -- return sb.toString(); -- } -- -- // binarys by length -- -- public Object replyBinary_0() -- { -- return new byte[0]; -- } -- -- public Object replyBinary_null() -- { -- return null; -- } -- -- public Object replyBinary_1() -- { -- return toBinary("0"); -- } -- -- public Object replyBinary_15() -- { -- return toBinary("012345678901234"); -- } -- -- public Object replyBinary_16() -- { -- return toBinary("0123456789012345"); -- } -- -- public Object replyBinary_1023() -- { -- StringBuilder sb = new StringBuilder(); -- -- for (int i = 0; i < 16; i++) { -- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -- } -- -- sb.setLength(1023); -- -- return toBinary(sb.toString()); -- } -- -- public Object replyBinary_1024() -- { -- StringBuilder sb = new StringBuilder(); -- -- for (int i = 0; i < 16; i++) { -- sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -- } -- -- sb.setLength(1024); -- -- return toBinary(sb.toString()); -- } -- -- public Object replyBinary_65536() -- { -- StringBuilder sb = new StringBuilder(); -- -- for (int i = 0; i < 64 * 16; i++) { -- sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); -- } -- -- sb.setLength(65536); -- -- return toBinary(sb.toString()); -- } -- -- private byte []toBinary(String s) -- { -- byte []buffer = new byte[s.length()]; -- -- for (int i = 0; i < s.length(); i++) -- buffer[i] = (byte) s.charAt(i); -- -- return buffer; -- } -- -- // -- // lists -- // -- -- public Object replyUntypedFixedList_0() -- { -- ArrayList list = new ArrayList(); -- -- return list; -- } -- -- public Object replyUntypedFixedList_1() -- { -- ArrayList list = new ArrayList(); -- -- list.add("1"); -- -- return list; -- } -- -- public Object replyUntypedFixedList_7() -- { -- ArrayList list = new ArrayList(); -- -- list.add("1"); -- list.add("2"); -- list.add("3"); -- list.add("4"); -- list.add("5"); -- list.add("6"); -- list.add("7"); -- -- return list; -- } -- -- public Object replyUntypedFixedList_8() -- { -- ArrayList list = new ArrayList(); -- -- list.add("1"); -- list.add("2"); -- list.add("3"); -- list.add("4"); -- list.add("5"); -- list.add("6"); -- list.add("7"); -- list.add("8"); -- -- return list; -- } -- -- public Object replyTypedFixedList_0() -- { -- return new String[] {}; -- } -- -- public Object replyTypedFixedList_1() -- { -- return new String[] { "1" }; -- } -- -- public Object replyTypedFixedList_7() -- { -- return new String[] { "1", "2", "3", "4", "5", "6", "7" }; -- } -- -- public Object replyTypedFixedList_8() -- { -- return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }; -- } -- -- // untyped map -- -- public Object replyUntypedMap_0() -- { -- return new HashMap(); -- } -- -- public Object replyUntypedMap_1() -- { -- HashMap map = new HashMap(); -- map.put("a", 0); -- -- return map; -- } -- -- public Object replyUntypedMap_2() -- { -- HashMap map = new HashMap(); -- -- map.put(0, "a"); -- map.put(1, "b"); -- -- return map; -- } -- -- public Object replyUntypedMap_3() -- { -- HashMap map = new HashMap(); -- -- ArrayList list = new ArrayList(); -- list.add("a"); -- -- map.put(list, 0); -- -- return map; -- } -- -- // typed map -- -- public Object replyTypedMap_0() -- { -- Hashtable map = new Hashtable(); -- -- return map; -- } -- -- public Object replyTypedMap_1() -- { -- Map map = new Hashtable(); -- -- map.put("a", 0); -- -- return map; -- } -- -- public Object replyTypedMap_2() -- { -- Map map = new Hashtable(); -- -- map.put(0, "a"); -- map.put(1, "b"); -- -- return map; -- } -- -- public Object replyTypedMap_3() -- { -- Map map = new Hashtable(); -- -- ArrayList list = new ArrayList(); -- list.add("a"); -- -- map.put(list, 0); -- -- return map; -- } -- -- // -- // objects -- // -- -- public Object replyObject_0() -- { -- return new A0(); -- } -- -- public Object replyObject_16() -- { -- ArrayList list = new ArrayList(); -- -- list.add(new A0()); -- list.add(new A1()); -- list.add(new A2()); -- list.add(new A3()); -- list.add(new A4()); -- list.add(new A5()); -- list.add(new A6()); -- list.add(new A7()); -- list.add(new A8()); -- list.add(new A9()); -- list.add(new A10()); -- list.add(new A11()); -- list.add(new A12()); -- list.add(new A13()); -- list.add(new A14()); -- list.add(new A15()); -- list.add(new A16()); -- -- return list; -- } -- -- public Object replyObject_1() -- { -- return new TestObject(0); -- } -- -- public Object replyObject_2() -- { -- ArrayList list = new ArrayList(); -- -- list.add(new TestObject(0)); -- list.add(new TestObject(1)); -- -- return list; -- } -- -- public Object replyObject_2a() -- { -- ArrayList list = new ArrayList(); -- -- TestObject obj = new TestObject(0); -- -- list.add(obj); -- list.add(obj); -- -- return list; -- } -- -- public Object replyObject_2b() -- { -- ArrayList list = new ArrayList(); -- -- list.add(new TestObject(0)); -- list.add(new TestObject(0)); -- -- return list; -- } -- -- public Object replyObject_3() -- { -- TestCons cons = new TestCons(); -- -- cons.setFirst("a"); -- cons.setRest(cons); -- -- return cons; -- } -- -- // -- // arguments -- // -- -- public Object argNull(Object v) -- { -- if (v == null) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argTrue(Object v) -- { -- if (Boolean.TRUE.equals(v)) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argFalse(Object v) -- { -- if (Boolean.FALSE.equals(v)) -- return true; -- -- return getInputDebug(); -- } -- -- // integers -- -- public Object argInt_0(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 0) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_1(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 1) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_47(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 47) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_m16(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == -16) -- return true; -- } -- -- return getInputDebug(); -- } -- -- // two byte integers -- -- public Object argInt_0x30(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 0x30) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_0x7ff(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 0x7ff) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_m17(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == -17) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_m0x800(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == -0x800) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_0x800(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 0x800) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_0x3ffff(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 0x3ffff) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_m0x801(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == -0x801) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_m0x40000(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == -0x40000) -- return true; -- } -- -- return getInputDebug(); -- } -- -- // 5 byte integers -- -- public Object argInt_0x40000(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 0x40000) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_0x7fffffff(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == 0x7fffffff) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_m0x40001(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == -0x40001) -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argInt_m0x80000000(Object v) -- { -- if (v instanceof Integer) { -- Integer value = (Integer) v; -- -- if (value == -0x80000000) -- return true; -- } -- -- return getInputDebug(); -- } -- -- // -- // longs -- // -- -- public Object argLong_0(Object v) -- { -- if (v.equals(replyLong_0())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_1(Object v) -- { -- if (v.equals(replyLong_1())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_15(Object v) -- { -- if (v.equals(replyLong_15())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m8(Object v) -- { -- if (v.equals(replyLong_m8())) -- return true; -- -- return getInputDebug(); -- } -- -- // two byte longs -- -- public Object argLong_0x10(Object v) -- { -- if (v.equals(replyLong_0x10())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_0x7ff(Object v) -- { -- if (v.equals(replyLong_0x7ff())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m9(Object v) -- { -- if (v.equals(replyLong_m9())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m0x800(Object v) -- { -- if (v.equals(replyLong_m0x800())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_0x800(Object v) -- { -- if (v.equals(replyLong_0x800())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_0x3ffff(Object v) -- { -- if (v.equals(replyLong_0x3ffff())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m0x801(Object v) -- { -- if (v.equals(replyLong_m0x801())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m0x40000(Object v) -- { -- if (v.equals(replyLong_m0x40000())) -- return true; -- -- return getInputDebug(); -- } -- -- // 5 byte longs -- -- public Object argLong_0x40000(Object v) -- { -- if (v.equals(replyLong_0x40000())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_0x7fffffff(Object v) -- { -- if (v.equals(replyLong_0x7fffffff())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m0x40001(Object v) -- { -- if (v.equals(replyLong_m0x40001())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m0x80000000(Object v) -- { -- if (v.equals(replyLong_m0x80000000())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_0x80000000(Object v) -- { -- if (v.equals(replyLong_0x80000000())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argLong_m0x80000001(Object v) -- { -- if (v.equals(replyLong_m0x80000001())) -- return true; -- -- return getInputDebug(); -- } -- -- // -- // doubles -- // -- -- /** -- * double 0.0 -- * -- *
--   * x5b
--   * 
-- */ -- public Object argDouble_0_0(Object v) -- { -- if (v.equals(replyDouble_0_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double 1.0 -- * -- *
--   * x5c
--   * 
-- */ -- public Object argDouble_1_0(Object v) -- { -- if (v.equals(replyDouble_1_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double 2.0 -- * -- *
--   * x5d x02
--   * 
-- */ -- public Object argDouble_2_0(Object v) -- { -- if (v.equals(replyDouble_2_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double 127.0 -- * -- *
--   * x5d x7f
--   * 
-- */ -- public Object argDouble_127_0(Object v) -- { -- if (v.equals(replyDouble_127_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double -128.0 -- * -- *
--   * x5d x80
--   * 
-- */ -- public Object argDouble_m128_0(Object v) -- { -- if (v.equals(replyDouble_m128_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double 128.0 -- * -- *
--   * x5e x00 x80
--   * 
-- */ -- public Object argDouble_128_0(Object v) -- { -- if (v.equals(replyDouble_128_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double -129.0 -- * -- *
--   * x5e xff x7f
--   * 
-- */ -- public Object argDouble_m129_0(Object v) -- { -- if (v.equals(replyDouble_m129_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double 32767.0 -- * -- *
--   * x5e x7f xff
--   * 
-- */ -- public Object argDouble_32767_0(Object v) -- { -- if (v.equals(replyDouble_32767_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * Double -32768.0 -- * -- *
--   * x5e x80 x80
--   * 
-- */ -- public Object argDouble_m32768_0(Object v) -- { -- if (v.equals(replyDouble_m32768_0())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double 0.001 -- * -- *
--   * x5f x00 x00 x00 x01
--   * 
-- */ -- public Object argDouble_0_001(Object v) -- { -- if (v.equals(replyDouble_0_001())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double -0.001 -- * -- *
--   * x5f xff xff xff xff
--   * 
-- */ -- public Object argDouble_m0_001(Object v) -- { -- if (v.equals(replyDouble_m0_001())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * double 65.536 -- * -- *
--   * x5f x00 x01 x00 x00
--   * 
-- */ -- public Object argDouble_65_536(Object v) -- { -- if (v.equals(replyDouble_65_536())) -- return true; -- -- return getInputDebug(); -- } -- -- /** -- * Result of double 3.14159 -- * -- *
--   * D x00 x01 x00 x00 x00 x00 x00 x00
--   * 
-- */ -- public Object argDouble_3_14159(Object v) -- { -- if (v.equals(replyDouble_3_14159())) -- return true; -- -- return getInputDebug(); -- } -- -- // -- // date -- // -- -- public Object argDate_0(Object v) -- { -- if (v.equals(replyDate_0())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argDate_1(Object v) -- { -- if (v.equals(replyDate_1())) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argDate_2(Object v) -- { -- if (v.equals(replyDate_2())) -- return true; -- -- return getInputDebug(); -- } -- -- // -- // string length -- // -- -- public Object argString_0(Object v) -- { -- String expect = ""; -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argString_1(Object v) -- { -- String expect = "0"; -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argString_31(Object v) -- { -- String expect = "0123456789012345678901234567890"; -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argString_32(Object v) -- { -- String expect = "01234567890123456789012345678901"; -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argString_1023(Object v) -- { -- String expect = replyString_1023(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argString_1024(Object v) -- { -- String expect = replyString_1024(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argString_65536(Object v) -- { -- String expect = replyString_65536(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- // -- // binary length -- // -- -- public Object argBinary_0(Object v) -- { -- byte []expect = (byte []) replyBinary_0(); -- -- if (equals(expect, v)) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argBinary_1(Object v) -- { -- byte []expect = (byte []) replyBinary_1(); -- -- if (equals(expect, v)) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argBinary_15(Object v) -- { -- byte []expect = (byte []) replyBinary_15(); -- -- if (equals(expect, v)) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argBinary_16(Object v) -- { -- byte []expect = (byte []) replyBinary_16(); -- -- if (equals(expect, v)) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argBinary_1023(Object v) -- { -- byte []expect = (byte []) replyBinary_1023(); -- -- if (equals(expect, v)) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argBinary_1024(Object v) -- { -- byte []expect = (byte []) replyBinary_1024(); -- -- if (equals(expect, v)) -- return true; -- -- return getInputDebug(); -- } -- -- public Object argBinary_65536(Object v) -- { -- byte []expect = (byte []) replyBinary_65536(); -- -- if (equals(expect, v)) -- return true; -- -- return getInputDebug(); -- } -- -- // -- // lists -- // -- -- public Object argUntypedFixedList_0(Object v) -- { -- Object expect = replyUntypedFixedList_0(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argUntypedFixedList_1(Object v) -- { -- Object expect = replyUntypedFixedList_1(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argUntypedFixedList_7(Object v) -- { -- Object expect = replyUntypedFixedList_7(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argUntypedFixedList_8(Object v) -- { -- Object expect = replyUntypedFixedList_8(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argTypedFixedList_0(Object v) -- { -- String []expect = (String []) replyTypedFixedList_0(); -- -- if (v instanceof String[] && equals(expect, (String []) v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argTypedFixedList_1(Object v) -- { -- String []expect = (String []) replyTypedFixedList_1(); -- -- if (v instanceof String[] && equals(expect, (String []) v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argTypedFixedList_7(Object v) -- { -- String []expect = (String []) replyTypedFixedList_7(); -- -- if (v instanceof String[] && equals(expect, (String []) v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argTypedFixedList_8(Object v) -- { -- String []expect = (String []) replyTypedFixedList_8(); -- -- if (v instanceof String[] && equals(expect, (String []) v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- // -- // untyped maps -- // -- -- public Object argUntypedMap_0(Object v) -- { -- Object expect = replyUntypedMap_0(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argUntypedMap_1(Object v) -- { -- Object expect = replyUntypedMap_1(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argUntypedMap_2(Object v) -- { -- Object expect = replyUntypedMap_2(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argUntypedMap_3(Object v) -- { -- Object expect = replyUntypedMap_3(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- // -- // typed maps -- // -- -- public Object argTypedMap_0(Object v) -- { -- Object expect = replyTypedMap_0(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argTypedMap_1(Object v) -- { -- Object expect = replyTypedMap_1(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argTypedMap_2(Object v) -- { -- Object expect = replyTypedMap_2(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argTypedMap_3(Object v) -- { -- Object expect = replyTypedMap_3(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- // -- // objects -- // -- -- public Object argObject_0(Object v) -- { -- Object expect = replyObject_0(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argObject_16(Object v) -- { -- Object expect = replyObject_16(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argObject_1(Object v) -- { -- Object expect = replyObject_1(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argObject_2(Object v) -- { -- Object expect = replyObject_2(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argObject_2a(Object v) -- { -- Object expect = replyObject_2a(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argObject_2b(Object v) -- { -- Object expect = replyObject_2b(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- public Object argObject_3(Object v) -- { -- Object expect = replyObject_3(); -- -- if (expect.equals(v)) { -- return true; -- } -- -- return getInputDebug(); -- } -- -- private boolean equals(String []a, String []b) -- { -- if (a == null || b == null) -- return false; -- -- if (a.length != b.length) -- return false; -- -- for (int i = 0; i < a.length; i++) { -- if (! a[i].equals(b[i])) -- return false; -- } -- -- return true; -- } -- -- private boolean equals(byte []a, Object obj) -- { -- if (! (obj instanceof byte[])) -- return false; -- -- byte []b = (byte []) obj; -- -- if (a == null || b == null) -- return false; -- -- if (a.length != b.length) -- return false; -- -- for (int i = 0; i < a.length; i++) { -- if (a[i] != b[i]) { -- return false; -- } -- } -- -- return true; -- } -- -- protected String getInputDebug() -- { -- CharArrayWriter writer = _threadWriter.get(); -- if (writer != null) -- return writer.toString(); -- else -- return null; -- } -- -- /** -- * Invoke the object with the request from the input stream. -- * -- * @param in the Hessian input stream -- * @param out the Hessian output stream -- */ -- @Override -- public void invoke(InputStream is, OutputStream os, String objectId, -- SerializerFactory serializerFactory) -- throws Exception -- { -- CharArrayWriter writer = new CharArrayWriter(); -- -- _threadWriter.set(writer); -- -- PrintWriter dbg = new PrintWriter(writer); -- -- HessianDebugInputStream debug = new HessianDebugInputStream(is, dbg); -- debug.startTop2(); -- -- super.invoke(debug, os, objectId, serializerFactory); -- } --} -+package com.caucho.hessian.test; -+ -+import com.caucho.hessian.io.*; -+import com.caucho.hessian.server.HessianServlet; -+import java.io.*; -+import java.util.*; -+ -+/** -+ * The test service is a Hessian 2.0 protocol test for developers of -+ * Hessian 2.0 clients. For a new client the recommended order is: -+ * -+ *
    -+ *
  • methodNull -+ *
  • methodHello -+ *
-+ */ -+public class TestHessian2Servlet -+ extends HessianServlet -+ implements TestHessian2 -+{ -+ private ThreadLocal _threadWriter -+ = new ThreadLocal(); -+ -+ public void methodNull() -+ { -+ } -+ -+ // -+ // reply tests, testing serialization output -+ // -+ -+ public void replyNull() -+ { -+ } -+ -+ // -+ // boolean -+ // -+ -+ public Object replyTrue() -+ { -+ return true; -+ } -+ -+ public Object replyFalse() -+ { -+ return false; -+ } -+ -+ // -+ // integers -+ // -+ -+ // single byte integers -+ -+ public int replyInt_0() -+ { -+ return 0; -+ } -+ -+ public int replyInt_1() -+ { -+ return 1; -+ } -+ -+ public int replyInt_47() -+ { -+ return 47; -+ } -+ -+ public int replyInt_m16() -+ { -+ return -16; -+ } -+ -+ // two byte integers -+ -+ public int replyInt_0x30() -+ { -+ return 0x30; -+ } -+ -+ public int replyInt_0x7ff() -+ { -+ return 0x7ff; -+ } -+ -+ public int replyInt_m17() -+ { -+ return -17; -+ } -+ -+ public int replyInt_m0x800() -+ { -+ return -0x800; -+ } -+ -+ // three byte integers -+ -+ public int replyInt_0x800() -+ { -+ return 0x800; -+ } -+ -+ public int replyInt_0x3ffff() -+ { -+ return 0x3ffff; -+ } -+ -+ public int replyInt_m0x801() -+ { -+ return -0x801; -+ } -+ -+ public int replyInt_m0x40000() -+ { -+ return - 0x40000; -+ } -+ -+ // 5 byte integers -+ -+ public int replyInt_0x40000() -+ { -+ return 0x40000; -+ } -+ -+ public int replyInt_0x7fffffff() -+ { -+ return 0x7fffffff; -+ } -+ -+ public int replyInt_m0x40001() -+ { -+ return - 0x40001; -+ } -+ -+ public int replyInt_m0x80000000() -+ { -+ return - 0x80000000; -+ } -+ -+ // -+ // longs -+ // -+ -+ // single byte longs -+ -+ public long replyLong_0() -+ { -+ return 0; -+ } -+ -+ public long replyLong_1() -+ { -+ return 1; -+ } -+ -+ public long replyLong_15() -+ { -+ return 15; -+ } -+ -+ public long replyLong_m8() -+ { -+ return -8; -+ } -+ -+ // two byte longs -+ -+ public long replyLong_0x10() -+ { -+ return 0x10; -+ } -+ -+ public long replyLong_0x7ff() -+ { -+ return 0x7ff; -+ } -+ -+ public long replyLong_m9() -+ { -+ return -9; -+ } -+ -+ public long replyLong_m0x800() -+ { -+ return -0x800; -+ } -+ -+ // three byte longs -+ -+ public long replyLong_0x800() -+ { -+ return 0x800; -+ } -+ -+ public long replyLong_0x3ffff() -+ { -+ return 0x3ffff; -+ } -+ -+ public long replyLong_m0x801() -+ { -+ return -0x801; -+ } -+ -+ public long replyLong_m0x40000() -+ { -+ return - 0x40000; -+ } -+ -+ // 5 byte longs -+ -+ public long replyLong_0x40000() -+ { -+ return 0x40000; -+ } -+ -+ public long replyLong_0x7fffffff() -+ { -+ return 0x7fffffff; -+ } -+ -+ public long replyLong_m0x40001() -+ { -+ return - 0x40001; -+ } -+ -+ public long replyLong_m0x80000000() -+ { -+ return - 0x80000000; -+ } -+ -+ public long replyLong_0x80000000() -+ { -+ return 0x80000000L; -+ } -+ -+ public long replyLong_m0x80000001() -+ { -+ return - 0x80000001L; -+ } -+ -+ // -+ // doubles -+ // -+ -+ public double replyDouble_0_0() -+ { -+ return 0; -+ } -+ -+ public double replyDouble_1_0() -+ { -+ return 1; -+ } -+ -+ public double replyDouble_2_0() -+ { -+ return 2; -+ } -+ -+ public double replyDouble_127_0() -+ { -+ return 127; -+ } -+ -+ public double replyDouble_m128_0() -+ { -+ return -128; -+ } -+ -+ public double replyDouble_128_0() -+ { -+ return 128; -+ } -+ -+ public double replyDouble_m129_0() -+ { -+ return -129; -+ } -+ -+ public double replyDouble_32767_0() -+ { -+ return 32767; -+ } -+ -+ public double replyDouble_m32768_0() -+ { -+ return -32768; -+ } -+ -+ public double replyDouble_0_001() -+ { -+ return 0.001; -+ } -+ -+ public double replyDouble_m0_001() -+ { -+ return - 0.001; -+ } -+ -+ public double replyDouble_65_536() -+ { -+ return 65.536; -+ } -+ -+ public double replyDouble_3_14159() -+ { -+ return 3.14159; -+ } -+ -+ // date -+ -+ public Object replyDate_0() -+ { -+ return new Date(0); -+ } -+ -+ public Object replyDate_1() -+ { -+ long time = 894621091000L; -+ -+ return new Date(time); -+ } -+ -+ public Object replyDate_2() -+ { -+ long time = 894621091000L; -+ -+ time -= time % 60000L; -+ -+ return new Date(time); -+ } -+ -+ // strings by length -+ -+ public String replyString_0() -+ { -+ return ""; -+ } -+ -+ public String replyString_null() -+ { -+ return null; -+ } -+ -+ public String replyString_1() -+ { -+ return "0"; -+ } -+ -+ public String replyString_31() -+ { -+ return "0123456789012345678901234567890"; -+ } -+ -+ public String replyString_32() -+ { -+ return "01234567890123456789012345678901"; -+ } -+ -+ public String replyString_1023() -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ for (int i = 0; i < 16; i++) { -+ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -+ } -+ -+ sb.setLength(1023); -+ -+ return sb.toString(); -+ } -+ -+ public String replyString_1024() -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ for (int i = 0; i < 16; i++) { -+ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -+ } -+ -+ sb.setLength(1024); -+ -+ return sb.toString(); -+ } -+ -+ public String replyString_65536() -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ for (int i = 0; i < 64 * 16; i++) { -+ sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); -+ } -+ -+ sb.setLength(65536); -+ -+ return sb.toString(); -+ } -+ -+ // binarys by length -+ -+ public Object replyBinary_0() -+ { -+ return new byte[0]; -+ } -+ -+ public Object replyBinary_null() -+ { -+ return null; -+ } -+ -+ public Object replyBinary_1() -+ { -+ return toBinary("0"); -+ } -+ -+ public Object replyBinary_15() -+ { -+ return toBinary("012345678901234"); -+ } -+ -+ public Object replyBinary_16() -+ { -+ return toBinary("0123456789012345"); -+ } -+ -+ public Object replyBinary_1023() -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ for (int i = 0; i < 16; i++) { -+ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -+ } -+ -+ sb.setLength(1023); -+ -+ return toBinary(sb.toString()); -+ } -+ -+ public Object replyBinary_1024() -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ for (int i = 0; i < 16; i++) { -+ sb.append("" + (i / 10) + (i % 10) + " 456789012345678901234567890123456789012345678901234567890123\n"); -+ } -+ -+ sb.setLength(1024); -+ -+ return toBinary(sb.toString()); -+ } -+ -+ public Object replyBinary_65536() -+ { -+ StringBuilder sb = new StringBuilder(); -+ -+ for (int i = 0; i < 64 * 16; i++) { -+ sb.append("" + (i / 100) + (i / 10 % 10) + (i % 10) + " 56789012345678901234567890123456789012345678901234567890123\n"); -+ } -+ -+ sb.setLength(65536); -+ -+ return toBinary(sb.toString()); -+ } -+ -+ private byte []toBinary(String s) -+ { -+ byte []buffer = new byte[s.length()]; -+ -+ for (int i = 0; i < s.length(); i++) -+ buffer[i] = (byte) s.charAt(i); -+ -+ return buffer; -+ } -+ -+ // -+ // lists -+ // -+ -+ public Object replyUntypedFixedList_0() -+ { -+ ArrayList list = new ArrayList(); -+ -+ return list; -+ } -+ -+ public Object replyUntypedFixedList_1() -+ { -+ ArrayList list = new ArrayList(); -+ -+ list.add("1"); -+ -+ return list; -+ } -+ -+ public Object replyUntypedFixedList_7() -+ { -+ ArrayList list = new ArrayList(); -+ -+ list.add("1"); -+ list.add("2"); -+ list.add("3"); -+ list.add("4"); -+ list.add("5"); -+ list.add("6"); -+ list.add("7"); -+ -+ return list; -+ } -+ -+ public Object replyUntypedFixedList_8() -+ { -+ ArrayList list = new ArrayList(); -+ -+ list.add("1"); -+ list.add("2"); -+ list.add("3"); -+ list.add("4"); -+ list.add("5"); -+ list.add("6"); -+ list.add("7"); -+ list.add("8"); -+ -+ return list; -+ } -+ -+ public Object replyTypedFixedList_0() -+ { -+ return new String[] {}; -+ } -+ -+ public Object replyTypedFixedList_1() -+ { -+ return new String[] { "1" }; -+ } -+ -+ public Object replyTypedFixedList_7() -+ { -+ return new String[] { "1", "2", "3", "4", "5", "6", "7" }; -+ } -+ -+ public Object replyTypedFixedList_8() -+ { -+ return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }; -+ } -+ -+ // untyped map -+ -+ public Object replyUntypedMap_0() -+ { -+ return new HashMap(); -+ } -+ -+ public Object replyUntypedMap_1() -+ { -+ HashMap map = new HashMap(); -+ map.put("a", 0); -+ -+ return map; -+ } -+ -+ public Object replyUntypedMap_2() -+ { -+ HashMap map = new HashMap(); -+ -+ map.put(0, "a"); -+ map.put(1, "b"); -+ -+ return map; -+ } -+ -+ public Object replyUntypedMap_3() -+ { -+ HashMap map = new HashMap(); -+ -+ ArrayList list = new ArrayList(); -+ list.add("a"); -+ -+ map.put(list, 0); -+ -+ return map; -+ } -+ -+ // typed map -+ -+ public Object replyTypedMap_0() -+ { -+ Hashtable map = new Hashtable(); -+ -+ return map; -+ } -+ -+ public Object replyTypedMap_1() -+ { -+ Map map = new Hashtable(); -+ -+ map.put("a", 0); -+ -+ return map; -+ } -+ -+ public Object replyTypedMap_2() -+ { -+ Map map = new Hashtable(); -+ -+ map.put(0, "a"); -+ map.put(1, "b"); -+ -+ return map; -+ } -+ -+ public Object replyTypedMap_3() -+ { -+ Map map = new Hashtable(); -+ -+ ArrayList list = new ArrayList(); -+ list.add("a"); -+ -+ map.put(list, 0); -+ -+ return map; -+ } -+ -+ // -+ // objects -+ // -+ -+ public Object replyObject_0() -+ { -+ return new A0(); -+ } -+ -+ public Object replyObject_16() -+ { -+ ArrayList list = new ArrayList(); -+ -+ list.add(new A0()); -+ list.add(new A1()); -+ list.add(new A2()); -+ list.add(new A3()); -+ list.add(new A4()); -+ list.add(new A5()); -+ list.add(new A6()); -+ list.add(new A7()); -+ list.add(new A8()); -+ list.add(new A9()); -+ list.add(new A10()); -+ list.add(new A11()); -+ list.add(new A12()); -+ list.add(new A13()); -+ list.add(new A14()); -+ list.add(new A15()); -+ list.add(new A16()); -+ -+ return list; -+ } -+ -+ public Object replyObject_1() -+ { -+ return new TestObject(0); -+ } -+ -+ public Object replyObject_2() -+ { -+ ArrayList list = new ArrayList(); -+ -+ list.add(new TestObject(0)); -+ list.add(new TestObject(1)); -+ -+ return list; -+ } -+ -+ public Object replyObject_2a() -+ { -+ ArrayList list = new ArrayList(); -+ -+ TestObject obj = new TestObject(0); -+ -+ list.add(obj); -+ list.add(obj); -+ -+ return list; -+ } -+ -+ public Object replyObject_2b() -+ { -+ ArrayList list = new ArrayList(); -+ -+ list.add(new TestObject(0)); -+ list.add(new TestObject(0)); -+ -+ return list; -+ } -+ -+ public Object replyObject_3() -+ { -+ TestCons cons = new TestCons(); -+ -+ cons.setFirst("a"); -+ cons.setRest(cons); -+ -+ return cons; -+ } -+ -+ // -+ // arguments -+ // -+ -+ public Object argNull(Object v) -+ { -+ if (v == null) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTrue(Object v) -+ { -+ if (Boolean.TRUE.equals(v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argFalse(Object v) -+ { -+ if (Boolean.FALSE.equals(v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ // integers -+ -+ public Object argInt_0(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 0) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_1(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 1) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_47(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 47) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_m16(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == -16) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ // two byte integers -+ -+ public Object argInt_0x30(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 0x30) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_0x7ff(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 0x7ff) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_m17(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == -17) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_m0x800(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == -0x800) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_0x800(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 0x800) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_0x3ffff(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 0x3ffff) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_m0x801(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == -0x801) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_m0x40000(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == -0x40000) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ // 5 byte integers -+ -+ public Object argInt_0x40000(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 0x40000) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_0x7fffffff(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == 0x7fffffff) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_m0x40001(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == -0x40001) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argInt_m0x80000000(Object v) -+ { -+ if (v instanceof Integer) { -+ Integer value = (Integer) v; -+ -+ if (value == -0x80000000) -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // longs -+ // -+ -+ public Object argLong_0(Object v) -+ { -+ if (v.equals(replyLong_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_1(Object v) -+ { -+ if (v.equals(replyLong_1())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_15(Object v) -+ { -+ if (v.equals(replyLong_15())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m8(Object v) -+ { -+ if (v.equals(replyLong_m8())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ // two byte longs -+ -+ public Object argLong_0x10(Object v) -+ { -+ if (v.equals(replyLong_0x10())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_0x7ff(Object v) -+ { -+ if (v.equals(replyLong_0x7ff())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m9(Object v) -+ { -+ if (v.equals(replyLong_m9())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m0x800(Object v) -+ { -+ if (v.equals(replyLong_m0x800())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_0x800(Object v) -+ { -+ if (v.equals(replyLong_0x800())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_0x3ffff(Object v) -+ { -+ if (v.equals(replyLong_0x3ffff())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m0x801(Object v) -+ { -+ if (v.equals(replyLong_m0x801())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m0x40000(Object v) -+ { -+ if (v.equals(replyLong_m0x40000())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ // 5 byte longs -+ -+ public Object argLong_0x40000(Object v) -+ { -+ if (v.equals(replyLong_0x40000())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_0x7fffffff(Object v) -+ { -+ if (v.equals(replyLong_0x7fffffff())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m0x40001(Object v) -+ { -+ if (v.equals(replyLong_m0x40001())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m0x80000000(Object v) -+ { -+ if (v.equals(replyLong_m0x80000000())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_0x80000000(Object v) -+ { -+ if (v.equals(replyLong_0x80000000())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argLong_m0x80000001(Object v) -+ { -+ if (v.equals(replyLong_m0x80000001())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // doubles -+ // -+ -+ /** -+ * double 0.0 -+ * -+ *
-+   * x5b
-+   * 
-+ */ -+ public Object argDouble_0_0(Object v) -+ { -+ if (v.equals(replyDouble_0_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double 1.0 -+ * -+ *
-+   * x5c
-+   * 
-+ */ -+ public Object argDouble_1_0(Object v) -+ { -+ if (v.equals(replyDouble_1_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double 2.0 -+ * -+ *
-+   * x5d x02
-+   * 
-+ */ -+ public Object argDouble_2_0(Object v) -+ { -+ if (v.equals(replyDouble_2_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double 127.0 -+ * -+ *
-+   * x5d x7f
-+   * 
-+ */ -+ public Object argDouble_127_0(Object v) -+ { -+ if (v.equals(replyDouble_127_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double -128.0 -+ * -+ *
-+   * x5d x80
-+   * 
-+ */ -+ public Object argDouble_m128_0(Object v) -+ { -+ if (v.equals(replyDouble_m128_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double 128.0 -+ * -+ *
-+   * x5e x00 x80
-+   * 
-+ */ -+ public Object argDouble_128_0(Object v) -+ { -+ if (v.equals(replyDouble_128_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double -129.0 -+ * -+ *
-+   * x5e xff x7f
-+   * 
-+ */ -+ public Object argDouble_m129_0(Object v) -+ { -+ if (v.equals(replyDouble_m129_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double 32767.0 -+ * -+ *
-+   * x5e x7f xff
-+   * 
-+ */ -+ public Object argDouble_32767_0(Object v) -+ { -+ if (v.equals(replyDouble_32767_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * Double -32768.0 -+ * -+ *
-+   * x5e x80 x80
-+   * 
-+ */ -+ public Object argDouble_m32768_0(Object v) -+ { -+ if (v.equals(replyDouble_m32768_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double 0.001 -+ * -+ *
-+   * x5f x00 x00 x00 x01
-+   * 
-+ */ -+ public Object argDouble_0_001(Object v) -+ { -+ if (v.equals(replyDouble_0_001())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double -0.001 -+ * -+ *
-+   * x5f xff xff xff xff
-+   * 
-+ */ -+ public Object argDouble_m0_001(Object v) -+ { -+ if (v.equals(replyDouble_m0_001())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * double 65.536 -+ * -+ *
-+   * x5f x00 x01 x00 x00
-+   * 
-+ */ -+ public Object argDouble_65_536(Object v) -+ { -+ if (v.equals(replyDouble_65_536())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ /** -+ * Result of double 3.14159 -+ * -+ *
-+   * D x00 x01 x00 x00 x00 x00 x00 x00
-+   * 
-+ */ -+ public Object argDouble_3_14159(Object v) -+ { -+ if (v.equals(replyDouble_3_14159())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // date -+ // -+ -+ public Object argDate_0(Object v) -+ { -+ if (v.equals(replyDate_0())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argDate_1(Object v) -+ { -+ if (v.equals(replyDate_1())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argDate_2(Object v) -+ { -+ if (v.equals(replyDate_2())) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // string length -+ // -+ -+ public Object argString_0(Object v) -+ { -+ String expect = ""; -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argString_1(Object v) -+ { -+ String expect = "0"; -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argString_31(Object v) -+ { -+ String expect = "0123456789012345678901234567890"; -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argString_32(Object v) -+ { -+ String expect = "01234567890123456789012345678901"; -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argString_1023(Object v) -+ { -+ String expect = replyString_1023(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argString_1024(Object v) -+ { -+ String expect = replyString_1024(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argString_65536(Object v) -+ { -+ String expect = replyString_65536(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // binary length -+ // -+ -+ public Object argBinary_0(Object v) -+ { -+ byte []expect = (byte []) replyBinary_0(); -+ -+ if (equals(expect, v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argBinary_1(Object v) -+ { -+ byte []expect = (byte []) replyBinary_1(); -+ -+ if (equals(expect, v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argBinary_15(Object v) -+ { -+ byte []expect = (byte []) replyBinary_15(); -+ -+ if (equals(expect, v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argBinary_16(Object v) -+ { -+ byte []expect = (byte []) replyBinary_16(); -+ -+ if (equals(expect, v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argBinary_1023(Object v) -+ { -+ byte []expect = (byte []) replyBinary_1023(); -+ -+ if (equals(expect, v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argBinary_1024(Object v) -+ { -+ byte []expect = (byte []) replyBinary_1024(); -+ -+ if (equals(expect, v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ public Object argBinary_65536(Object v) -+ { -+ byte []expect = (byte []) replyBinary_65536(); -+ -+ if (equals(expect, v)) -+ return true; -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // lists -+ // -+ -+ public Object argUntypedFixedList_0(Object v) -+ { -+ Object expect = replyUntypedFixedList_0(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argUntypedFixedList_1(Object v) -+ { -+ Object expect = replyUntypedFixedList_1(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argUntypedFixedList_7(Object v) -+ { -+ Object expect = replyUntypedFixedList_7(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argUntypedFixedList_8(Object v) -+ { -+ Object expect = replyUntypedFixedList_8(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTypedFixedList_0(Object v) -+ { -+ String []expect = (String []) replyTypedFixedList_0(); -+ -+ if (v instanceof String[] && equals(expect, (String []) v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTypedFixedList_1(Object v) -+ { -+ String []expect = (String []) replyTypedFixedList_1(); -+ -+ if (v instanceof String[] && equals(expect, (String []) v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTypedFixedList_7(Object v) -+ { -+ String []expect = (String []) replyTypedFixedList_7(); -+ -+ if (v instanceof String[] && equals(expect, (String []) v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTypedFixedList_8(Object v) -+ { -+ String []expect = (String []) replyTypedFixedList_8(); -+ -+ if (v instanceof String[] && equals(expect, (String []) v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // untyped maps -+ // -+ -+ public Object argUntypedMap_0(Object v) -+ { -+ Object expect = replyUntypedMap_0(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argUntypedMap_1(Object v) -+ { -+ Object expect = replyUntypedMap_1(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argUntypedMap_2(Object v) -+ { -+ Object expect = replyUntypedMap_2(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argUntypedMap_3(Object v) -+ { -+ Object expect = replyUntypedMap_3(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // typed maps -+ // -+ -+ public Object argTypedMap_0(Object v) -+ { -+ Object expect = replyTypedMap_0(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTypedMap_1(Object v) -+ { -+ Object expect = replyTypedMap_1(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTypedMap_2(Object v) -+ { -+ Object expect = replyTypedMap_2(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argTypedMap_3(Object v) -+ { -+ Object expect = replyTypedMap_3(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ // -+ // objects -+ // -+ -+ public Object argObject_0(Object v) -+ { -+ Object expect = replyObject_0(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argObject_16(Object v) -+ { -+ Object expect = replyObject_16(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argObject_1(Object v) -+ { -+ Object expect = replyObject_1(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argObject_2(Object v) -+ { -+ Object expect = replyObject_2(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argObject_2a(Object v) -+ { -+ Object expect = replyObject_2a(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argObject_2b(Object v) -+ { -+ Object expect = replyObject_2b(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ public Object argObject_3(Object v) -+ { -+ Object expect = replyObject_3(); -+ -+ if (expect.equals(v)) { -+ return true; -+ } -+ -+ return getInputDebug(); -+ } -+ -+ private boolean equals(String []a, String []b) -+ { -+ if (a == null || b == null) -+ return false; -+ -+ if (a.length != b.length) -+ return false; -+ -+ for (int i = 0; i < a.length; i++) { -+ if (! a[i].equals(b[i])) -+ return false; -+ } -+ -+ return true; -+ } -+ -+ private boolean equals(byte []a, Object obj) -+ { -+ if (! (obj instanceof byte[])) -+ return false; -+ -+ byte []b = (byte []) obj; -+ -+ if (a == null || b == null) -+ return false; -+ -+ if (a.length != b.length) -+ return false; -+ -+ for (int i = 0; i < a.length; i++) { -+ if (a[i] != b[i]) { -+ return false; -+ } -+ } -+ -+ return true; -+ } -+ -+ protected String getInputDebug() -+ { -+ CharArrayWriter writer = _threadWriter.get(); -+ if (writer != null) -+ return writer.toString(); -+ else -+ return null; -+ } -+ -+ /** -+ * Invoke the object with the request from the input stream. -+ * -+ * @param in the Hessian input stream -+ * @param out the Hessian output stream -+ */ -+ @Override -+ public void invoke(InputStream is, OutputStream os, String objectId, -+ SerializerFactory serializerFactory) -+ throws Exception -+ { -+ CharArrayWriter writer = new CharArrayWriter(); -+ -+ _threadWriter.set(writer); -+ -+ PrintWriter dbg = new PrintWriter(writer); -+ -+ HessianDebugInputStream debug = new HessianDebugInputStream(is, dbg); -+ debug.startTop2(); -+ -+ super.invoke(debug, os, objectId, serializerFactory); -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestHessianServlet.java hessian-4.0.65-fix/com/caucho/hessian/test/TestHessianServlet.java ---- hessian-4.0.65-src/com/caucho/hessian/test/TestHessianServlet.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/test/TestHessianServlet.java 2023-08-15 18:39:22.000000000 +0800 -@@ -1,64 +1,64 @@ --package com.caucho.hessian.test; -- --import com.caucho.hessian.io.*; --import com.caucho.hessian.server.HessianServlet; --import java.io.*; --import java.util.*; -- --/** -- * The test service is a Hessian 2.0 protocol test for developers of -- * Hessian 2.0 clients. For a new client the recommended order is: -- * -- *
    -- *
  • methodNull -- *
  • methodHello -- *
-- */ --public class TestHessianServlet -- extends HessianServlet -- implements Test --{ -- private ThreadLocal _threadWriter -- = new ThreadLocal(); -- -- /** -- * Does nothing. -- */ -- public void nullCall() -- { -- } -- -- /** -- * Hello, World. -- */ -- public String hello() -- { -- return "Hello, World"; -- } -- -- /** -- * Subtraction -- */ -- public int subtract(int a, int b) -- { -- return a - b; -- } -- -- /** -- * Echos the object to the server. -- *
--   */
--  public Object echo(Object value)
--  {
--    return value;
--  }
--  
--  /**
--   * Throws an application fault.
--   */
--  public void fault()
--    throws IOException
--  {
--    throw new NullPointerException("sample exception");
--  }
--}
-+package com.caucho.hessian.test;
-+
-+import com.caucho.hessian.io.*;
-+import com.caucho.hessian.server.HessianServlet;
-+import java.io.*;
-+import java.util.*;
-+
-+/**
-+ * The test service is a Hessian 2.0 protocol test for developers of
-+ * Hessian 2.0 clients.  For a new client the recommended order is:
-+ *
-+ * 
    -+ *
  • methodNull -+ *
  • methodHello -+ *
-+ */ -+public class TestHessianServlet -+ extends HessianServlet -+ implements Test -+{ -+ private ThreadLocal _threadWriter -+ = new ThreadLocal(); -+ -+ /** -+ * Does nothing. -+ */ -+ public void nullCall() -+ { -+ } -+ -+ /** -+ * Hello, World. -+ */ -+ public String hello() -+ { -+ return "Hello, World"; -+ } -+ -+ /** -+ * Subtraction -+ */ -+ public int subtract(int a, int b) -+ { -+ return a - b; -+ } -+ -+ /** -+ * Echos the object to the server. -+ *
-+   */
-+  public Object echo(Object value)
-+  {
-+    return value;
-+  }
-+  
-+  /**
-+   * Throws an application fault.
-+   */
-+  public void fault()
-+    throws IOException
-+  {
-+    throw new NullPointerException("sample exception");
-+  }
-+}
-diff -uNr hessian-4.0.65-src/com/caucho/hessian/test/TestObject.java hessian-4.0.65-fix/com/caucho/hessian/test/TestObject.java
---- hessian-4.0.65-src/com/caucho/hessian/test/TestObject.java	2020-07-23 12:51:28.000000000 +0800
-+++ hessian-4.0.65-fix/com/caucho/hessian/test/TestObject.java	2023-08-15 18:39:22.000000000 +0800
-@@ -1,50 +1,50 @@
--package com.caucho.hessian.test;
--
--import java.io.IOException;
--
--/**
-- * Empty object for short-encoding testing
-- */
--public class TestObject implements java.io.Serializable {
--  private Object _value;
--
--  public TestObject()
--  {
--  }
--
--  public TestObject(Object value)
--  {
--    _value = value;
--  }
--
--  public Object getValue()
--  {
--    return _value;
--  }
--
--  public int hashCode()
--  {
--    if (_value != null)
--      return _value.hashCode();
--    else
--      return 0;
--  }
--
--  public boolean equals(Object o)
--  {
--    if (! (o instanceof TestObject))
--      return false;
--
--    TestObject obj = (TestObject) o;
--
--    if (_value != null)
--      return _value.equals(obj._value);
--    else
--      return _value == obj._value;
--  }
--  
--  public String toString()
--  {
--    return getClass().getName() + "[" + _value + "]";
--  }
--}
-+package com.caucho.hessian.test;
-+
-+import java.io.IOException;
-+
-+/**
-+ * Empty object for short-encoding testing
-+ */
-+public class TestObject implements java.io.Serializable {
-+  private Object _value;
-+
-+  public TestObject()
-+  {
-+  }
-+
-+  public TestObject(Object value)
-+  {
-+    _value = value;
-+  }
-+
-+  public Object getValue()
-+  {
-+    return _value;
-+  }
-+
-+  public int hashCode()
-+  {
-+    if (_value != null)
-+      return _value.hashCode();
-+    else
-+      return 0;
-+  }
-+
-+  public boolean equals(Object o)
-+  {
-+    if (! (o instanceof TestObject))
-+      return false;
-+
-+    TestObject obj = (TestObject) o;
-+
-+    if (_value != null)
-+      return _value.equals(obj._value);
-+    else
-+      return _value == obj._value;
-+  }
-+  
-+  public String toString()
-+  {
-+    return getClass().getName() + "[" + _value + "]";
-+  }
-+}
-diff -uNr hessian-4.0.65-src/com/caucho/hessian/util/HessianFreeList.java hessian-4.0.65-fix/com/caucho/hessian/util/HessianFreeList.java
---- hessian-4.0.65-src/com/caucho/hessian/util/HessianFreeList.java	2020-07-23 12:51:28.000000000 +0800
-+++ hessian-4.0.65-fix/com/caucho/hessian/util/HessianFreeList.java	2023-08-15 18:39:22.000000000 +0800
-@@ -1,145 +1,145 @@
--/*
-- * Copyright (c) 2001-2008 Caucho Technology, Inc.  All rights reserved.
-- *
-- * The Apache Software License, Version 1.1
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions
-- * are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright
-- *    notice, this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright
-- *    notice, this list of conditions and the following disclaimer in
-- *    the documentation and/or other materials provided with the
-- *    distribution.
-- *
-- * 3. The end-user documentation included with the redistribution, if
-- *    any, must include the following acknowlegement:
-- *       "This product includes software developed by the
-- *        Caucho Technology (http://www.caucho.com/)."
-- *    Alternately, this acknowlegement may appear in the software itself,
-- *    if and wherever such third-party acknowlegements normally appear.
-- *
-- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to
-- *    endorse or promote products derived from this software without prior
-- *    written permission. For written permission, please contact
-- *    info@caucho.com.
-- *
-- * 5. Products derived from this software may not be called "Resin"
-- *    nor may "Resin" appear in their names without prior written
-- *    permission of Caucho Technology.
-- *
-- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
-- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- * DISCLAIMED.  IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
-- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- *
-- * @author Scott Ferguson
-- */
--
--package com.caucho.hessian.util;
--
--import java.util.concurrent.atomic.AtomicInteger;
--import java.util.concurrent.atomic.AtomicReferenceArray;
--
--/**
-- * FreeList provides a simple class to manage free objects.  This is useful
-- * for large data structures that otherwise would gobble up huge GC time.
-- *
-- * 

The free list is bounded. Freeing an object when the list is full will -- * do nothing. -- */ --public final class HessianFreeList { -- private final AtomicReferenceArray _freeStack; -- private final AtomicInteger _top = new AtomicInteger(); -- -- /** -- * Create a new free list. -- * -- * @param initialSize maximum number of free objects to store. -- */ -- public HessianFreeList(int size) -- { -- _freeStack = new AtomicReferenceArray(size); -- } -- -- /** -- * Try to get an object from the free list. Returns null if the free list -- * is empty. -- * -- * @return the new object or null. -- */ -- public T allocate() -- { -- int top = _top.get(); -- -- if (top > 0 && _top.compareAndSet(top, top - 1)) -- return _freeStack.getAndSet(top - 1, null); -- else -- return null; -- } -- -- /** -- * Frees the object. If the free list is full, the object will be garbage -- * collected. -- * -- * @param obj the object to be freed. -- */ -- public boolean free(T obj) -- { -- int top = _top.get(); -- -- if (top < _freeStack.length()) { -- boolean isFree = _freeStack.compareAndSet(top, null, obj); -- -- _top.compareAndSet(top, top + 1); -- -- return isFree; -- } -- else -- return false; -- } -- -- public boolean allowFree(T obj) -- { -- return _top.get() < _freeStack.length(); -- } -- -- /** -- * Frees the object. If the free list is full, the object will be garbage -- * collected. -- * -- * @param obj the object to be freed. -- */ -- public void freeCareful(T obj) -- { -- if (checkDuplicate(obj)) -- throw new IllegalStateException("tried to free object twice: " + obj); -- -- free(obj); -- } -- -- /** -- * Debugging to see if the object has already been freed. -- */ -- public boolean checkDuplicate(T obj) -- { -- int top = _top.get(); -- -- for (int i = top - 1; i >= 0; i--) { -- if (_freeStack.get(i) == obj) -- return true; -- } -- -- return false; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.util; -+ -+import java.util.concurrent.atomic.AtomicInteger; -+import java.util.concurrent.atomic.AtomicReferenceArray; -+ -+/** -+ * FreeList provides a simple class to manage free objects. This is useful -+ * for large data structures that otherwise would gobble up huge GC time. -+ * -+ *

The free list is bounded. Freeing an object when the list is full will -+ * do nothing. -+ */ -+public final class HessianFreeList { -+ private final AtomicReferenceArray _freeStack; -+ private final AtomicInteger _top = new AtomicInteger(); -+ -+ /** -+ * Create a new free list. -+ * -+ * @param initialSize maximum number of free objects to store. -+ */ -+ public HessianFreeList(int size) -+ { -+ _freeStack = new AtomicReferenceArray(size); -+ } -+ -+ /** -+ * Try to get an object from the free list. Returns null if the free list -+ * is empty. -+ * -+ * @return the new object or null. -+ */ -+ public T allocate() -+ { -+ int top = _top.get(); -+ -+ if (top > 0 && _top.compareAndSet(top, top - 1)) -+ return _freeStack.getAndSet(top - 1, null); -+ else -+ return null; -+ } -+ -+ /** -+ * Frees the object. If the free list is full, the object will be garbage -+ * collected. -+ * -+ * @param obj the object to be freed. -+ */ -+ public boolean free(T obj) -+ { -+ int top = _top.get(); -+ -+ if (top < _freeStack.length()) { -+ boolean isFree = _freeStack.compareAndSet(top, null, obj); -+ -+ _top.compareAndSet(top, top + 1); -+ -+ return isFree; -+ } -+ else -+ return false; -+ } -+ -+ public boolean allowFree(T obj) -+ { -+ return _top.get() < _freeStack.length(); -+ } -+ -+ /** -+ * Frees the object. If the free list is full, the object will be garbage -+ * collected. -+ * -+ * @param obj the object to be freed. -+ */ -+ public void freeCareful(T obj) -+ { -+ if (checkDuplicate(obj)) -+ throw new IllegalStateException("tried to free object twice: " + obj); -+ -+ free(obj); -+ } -+ -+ /** -+ * Debugging to see if the object has already been freed. -+ */ -+ public boolean checkDuplicate(T obj) -+ { -+ int top = _top.get(); -+ -+ for (int i = top - 1; i >= 0; i--) { -+ if (_freeStack.get(i) == obj) -+ return true; -+ } -+ -+ return false; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/util/IdentityIntMap.java hessian-4.0.65-fix/com/caucho/hessian/util/IdentityIntMap.java ---- hessian-4.0.65-src/com/caucho/hessian/util/IdentityIntMap.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/util/IdentityIntMap.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,276 +1,276 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.util; -- --/** -- * The IntMap provides a simple hashmap from keys to integers. The API is -- * an abbreviation of the HashMap collection API. -- * -- *

The convenience of IntMap is avoiding all the silly wrapping of -- * integers. -- */ --public class IdentityIntMap { -- /** -- * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, -- * it's impossible to distinguish between the two. -- */ -- public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; -- -- private Object []_keys; -- private int []_values; -- -- private int _size; -- private int _prime; -- -- /** -- * Create a new IntMap. Default size is 16. -- */ -- public IdentityIntMap(int capacity) -- { -- _keys = new Object[capacity]; -- _values = new int[capacity]; -- -- _prime = getBiggestPrime(_keys.length); -- _size = 0; -- } -- -- /** -- * Clear the hashmap. -- */ -- public void clear() -- { -- final Object []keys = _keys; -- final int []values = _values; -- -- for (int i = keys.length - 1; i >= 0; i--) { -- keys[i] = null; -- values[i] = 0; -- } -- -- _size = 0; -- } -- /** -- * Returns the current number of entries in the map. -- */ -- public final int size() -- { -- return _size; -- } -- -- /** -- * Puts a new value in the property table with the appropriate flags -- */ -- public final int get(Object key) -- { -- int prime = _prime; -- int hash = System.identityHashCode(key) % prime; -- // int hash = key.hashCode() & mask; -- -- final Object []keys = _keys; -- -- while (true) { -- Object mapKey = keys[hash]; -- -- if (mapKey == null) -- return NULL; -- else if (mapKey == key) -- return _values[hash]; -- -- hash = (hash + 1) % prime; -- } -- } -- -- /** -- * Puts a new value in the property table with the appropriate flags -- */ -- public final int put(Object key, int value, boolean isReplace) -- { -- int prime = _prime; -- int hash = Math.abs(System.identityHashCode(key) % prime); -- // int hash = key.hashCode() % prime; -- -- Object []keys = _keys; -- -- while (true) { -- Object testKey = keys[hash]; -- -- if (testKey == null) { -- keys[hash] = key; -- _values[hash] = value; -- -- _size++; -- -- if (keys.length <= 4 * _size) -- resize(4 * keys.length); -- -- return value; -- } -- else if (key != testKey) { -- hash = (hash + 1) % prime; -- -- continue; -- } -- else if (isReplace){ -- int old = _values[hash]; -- -- _values[hash] = value; -- -- return old; -- } -- else { -- return _values[hash]; -- } -- } -- } -- -- /** -- * Removes a value in the property table. -- */ -- public final void remove(Object key) -- { -- if (put(key, NULL, true) != NULL) { -- _size--; -- } -- } -- -- /** -- * Expands the property table -- */ -- private void resize(int newSize) -- { -- Object []keys = _keys; -- int values[] = _values; -- -- _keys = new Object[newSize]; -- _values = new int[newSize]; -- _size = 0; -- -- _prime = getBiggestPrime(_keys.length); -- -- for (int i = keys.length - 1; i >= 0; i--) { -- Object key = keys[i]; -- int value = values[i]; -- -- if (key != null && value != NULL) { -- put(key, value, true); -- } -- } -- } -- -- protected int hashCode(Object value) -- { -- return System.identityHashCode(value); -- } -- -- public String toString() -- { -- StringBuffer sbuf = new StringBuffer(); -- -- sbuf.append("IntMap["); -- boolean isFirst = true; -- -- for (int i = 0; i <= _keys.length; i++) { -- if (_keys[i] != null) { -- if (! isFirst) -- sbuf.append(", "); -- -- isFirst = false; -- sbuf.append(_keys[i]); -- sbuf.append(":"); -- sbuf.append(_values[i]); -- } -- } -- sbuf.append("]"); -- -- return sbuf.toString(); -- } -- -- public static final int []PRIMES = -- { -- 1, /* 1<< 0 = 1 */ -- 2, /* 1<< 1 = 2 */ -- 3, /* 1<< 2 = 4 */ -- 7, /* 1<< 3 = 8 */ -- 13, /* 1<< 4 = 16 */ -- 31, /* 1<< 5 = 32 */ -- 61, /* 1<< 6 = 64 */ -- 127, /* 1<< 7 = 128 */ -- 251, /* 1<< 8 = 256 */ -- 509, /* 1<< 9 = 512 */ -- 1021, /* 1<<10 = 1024 */ -- 2039, /* 1<<11 = 2048 */ -- 4093, /* 1<<12 = 4096 */ -- 8191, /* 1<<13 = 8192 */ -- 16381, /* 1<<14 = 16384 */ -- 32749, /* 1<<15 = 32768 */ -- 65521, /* 1<<16 = 65536 */ -- 131071, /* 1<<17 = 131072 */ -- 262139, /* 1<<18 = 262144 */ -- 524287, /* 1<<19 = 524288 */ -- 1048573, /* 1<<20 = 1048576 */ -- 2097143, /* 1<<21 = 2097152 */ -- 4194301, /* 1<<22 = 4194304 */ -- 8388593, /* 1<<23 = 8388608 */ -- 16777213, /* 1<<24 = 16777216 */ -- 33554393, /* 1<<25 = 33554432 */ -- 67108859, /* 1<<26 = 67108864 */ -- 134217689, /* 1<<27 = 134217728 */ -- 268435399, /* 1<<28 = 268435456 */ -- }; -- -- public static int getBiggestPrime(int value) -- { -- for (int i = PRIMES.length - 1; i >= 0; i--) { -- if (PRIMES[i] <= value) -- return PRIMES[i]; -- } -- -- return 2; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.util; -+ -+/** -+ * The IntMap provides a simple hashmap from keys to integers. The API is -+ * an abbreviation of the HashMap collection API. -+ * -+ *

The convenience of IntMap is avoiding all the silly wrapping of -+ * integers. -+ */ -+public class IdentityIntMap { -+ /** -+ * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, -+ * it's impossible to distinguish between the two. -+ */ -+ public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; -+ -+ private Object []_keys; -+ private int []_values; -+ -+ private int _size; -+ private int _prime; -+ -+ /** -+ * Create a new IntMap. Default size is 16. -+ */ -+ public IdentityIntMap(int capacity) -+ { -+ _keys = new Object[capacity]; -+ _values = new int[capacity]; -+ -+ _prime = getBiggestPrime(_keys.length); -+ _size = 0; -+ } -+ -+ /** -+ * Clear the hashmap. -+ */ -+ public void clear() -+ { -+ final Object []keys = _keys; -+ final int []values = _values; -+ -+ for (int i = keys.length - 1; i >= 0; i--) { -+ keys[i] = null; -+ values[i] = 0; -+ } -+ -+ _size = 0; -+ } -+ /** -+ * Returns the current number of entries in the map. -+ */ -+ public final int size() -+ { -+ return _size; -+ } -+ -+ /** -+ * Puts a new value in the property table with the appropriate flags -+ */ -+ public final int get(Object key) -+ { -+ int prime = _prime; -+ int hash = System.identityHashCode(key) % prime; -+ // int hash = key.hashCode() & mask; -+ -+ final Object []keys = _keys; -+ -+ while (true) { -+ Object mapKey = keys[hash]; -+ -+ if (mapKey == null) -+ return NULL; -+ else if (mapKey == key) -+ return _values[hash]; -+ -+ hash = (hash + 1) % prime; -+ } -+ } -+ -+ /** -+ * Puts a new value in the property table with the appropriate flags -+ */ -+ public final int put(Object key, int value, boolean isReplace) -+ { -+ int prime = _prime; -+ int hash = Math.abs(System.identityHashCode(key) % prime); -+ // int hash = key.hashCode() % prime; -+ -+ Object []keys = _keys; -+ -+ while (true) { -+ Object testKey = keys[hash]; -+ -+ if (testKey == null) { -+ keys[hash] = key; -+ _values[hash] = value; -+ -+ _size++; -+ -+ if (keys.length <= 4 * _size) -+ resize(4 * keys.length); -+ -+ return value; -+ } -+ else if (key != testKey) { -+ hash = (hash + 1) % prime; -+ -+ continue; -+ } -+ else if (isReplace){ -+ int old = _values[hash]; -+ -+ _values[hash] = value; -+ -+ return old; -+ } -+ else { -+ return _values[hash]; -+ } -+ } -+ } -+ -+ /** -+ * Removes a value in the property table. -+ */ -+ public final void remove(Object key) -+ { -+ if (put(key, NULL, true) != NULL) { -+ _size--; -+ } -+ } -+ -+ /** -+ * Expands the property table -+ */ -+ private void resize(int newSize) -+ { -+ Object []keys = _keys; -+ int values[] = _values; -+ -+ _keys = new Object[newSize]; -+ _values = new int[newSize]; -+ _size = 0; -+ -+ _prime = getBiggestPrime(_keys.length); -+ -+ for (int i = keys.length - 1; i >= 0; i--) { -+ Object key = keys[i]; -+ int value = values[i]; -+ -+ if (key != null && value != NULL) { -+ put(key, value, true); -+ } -+ } -+ } -+ -+ protected int hashCode(Object value) -+ { -+ return System.identityHashCode(value); -+ } -+ -+ public String toString() -+ { -+ StringBuffer sbuf = new StringBuffer(); -+ -+ sbuf.append("IntMap["); -+ boolean isFirst = true; -+ -+ for (int i = 0; i <= _keys.length; i++) { -+ if (_keys[i] != null) { -+ if (! isFirst) -+ sbuf.append(", "); -+ -+ isFirst = false; -+ sbuf.append(_keys[i]); -+ sbuf.append(":"); -+ sbuf.append(_values[i]); -+ } -+ } -+ sbuf.append("]"); -+ -+ return sbuf.toString(); -+ } -+ -+ public static final int []PRIMES = -+ { -+ 1, /* 1<< 0 = 1 */ -+ 2, /* 1<< 1 = 2 */ -+ 3, /* 1<< 2 = 4 */ -+ 7, /* 1<< 3 = 8 */ -+ 13, /* 1<< 4 = 16 */ -+ 31, /* 1<< 5 = 32 */ -+ 61, /* 1<< 6 = 64 */ -+ 127, /* 1<< 7 = 128 */ -+ 251, /* 1<< 8 = 256 */ -+ 509, /* 1<< 9 = 512 */ -+ 1021, /* 1<<10 = 1024 */ -+ 2039, /* 1<<11 = 2048 */ -+ 4093, /* 1<<12 = 4096 */ -+ 8191, /* 1<<13 = 8192 */ -+ 16381, /* 1<<14 = 16384 */ -+ 32749, /* 1<<15 = 32768 */ -+ 65521, /* 1<<16 = 65536 */ -+ 131071, /* 1<<17 = 131072 */ -+ 262139, /* 1<<18 = 262144 */ -+ 524287, /* 1<<19 = 524288 */ -+ 1048573, /* 1<<20 = 1048576 */ -+ 2097143, /* 1<<21 = 2097152 */ -+ 4194301, /* 1<<22 = 4194304 */ -+ 8388593, /* 1<<23 = 8388608 */ -+ 16777213, /* 1<<24 = 16777216 */ -+ 33554393, /* 1<<25 = 33554432 */ -+ 67108859, /* 1<<26 = 67108864 */ -+ 134217689, /* 1<<27 = 134217728 */ -+ 268435399, /* 1<<28 = 268435456 */ -+ }; -+ -+ public static int getBiggestPrime(int value) -+ { -+ for (int i = PRIMES.length - 1; i >= 0; i--) { -+ if (PRIMES[i] <= value) -+ return PRIMES[i]; -+ } -+ -+ return 2; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/hessian/util/IntMap.java hessian-4.0.65-fix/com/caucho/hessian/util/IntMap.java ---- hessian-4.0.65-src/com/caucho/hessian/util/IntMap.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/hessian/util/IntMap.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,267 +1,267 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.hessian.util; -- --/** -- * The IntMap provides a simple hashmap from keys to integers. The API is -- * an abbreviation of the HashMap collection API. -- * -- *

The convenience of IntMap is avoiding all the silly wrapping of -- * integers. -- */ --public class IntMap { -- /** -- * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, -- * it's impossible to distinguish between the two. -- */ -- public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; -- -- private Object []_keys; -- private int []_values; -- -- private int _size; -- private int _prime; -- -- /** -- * Create a new IntMap. Default size is 16. -- */ -- public IntMap() -- { -- int capacity = 1024; -- -- _keys = new Object[capacity]; -- _values = new int[capacity]; -- -- _prime = getBiggestPrime(_keys.length); -- _size = 0; -- } -- -- /** -- * Clear the hashmap. -- */ -- public void clear() -- { -- final Object []keys = _keys; -- final int []values = _values; -- -- for (int i = keys.length - 1; i >= 0; i--) { -- keys[i] = null; -- values[i] = 0; -- } -- -- _size = 0; -- } -- /** -- * Returns the current number of entries in the map. -- */ -- public final int size() -- { -- return _size; -- } -- -- /** -- * Puts a new value in the property table with the appropriate flags -- */ -- public final int get(Object key) -- { -- int prime = _prime; -- int hash = hashCode(key) % prime; -- // int hash = key.hashCode() & mask; -- -- final Object []keys = _keys; -- -- while (true) { -- Object mapKey = keys[hash]; -- -- if (mapKey == null) -- return NULL; -- else if (mapKey == key) -- return _values[hash]; -- -- hash = (hash + 1) % prime; -- } -- } -- -- /** -- * Puts a new value in the property table with the appropriate flags -- */ -- public final int put(Object key, int value, boolean isReplace) -- { -- int prime = _prime; -- int hash = hashCode(key) % prime; -- // int hash = key.hashCode() % prime; -- -- Object []keys = _keys; -- -- while (true) { -- Object testKey = keys[hash]; -- -- if (testKey == null) { -- keys[hash] = key; -- _values[hash] = value; -- -- _size++; -- -- if (keys.length <= 4 * _size) -- resize(4 * keys.length); -- -- return NULL; -- } -- else if (key != testKey) { -- hash = (hash + 1) % prime; -- -- continue; -- } -- else if (isReplace){ -- int old = _values[hash]; -- -- _values[hash] = value; -- -- return old; -- } -- else { -- return _values[hash]; -- } -- } -- } -- -- /** -- * Expands the property table -- */ -- private void resize(int newSize) -- { -- Object []keys = _keys; -- int values[] = _values; -- -- _keys = new Object[newSize]; -- _values = new int[newSize]; -- _size = 0; -- -- _prime = getBiggestPrime(_keys.length); -- -- for (int i = keys.length - 1; i >= 0; i--) { -- Object key = keys[i]; -- -- if (key != null) { -- put(key, values[i], true); -- } -- } -- } -- -- protected int hashCode(Object value) -- { -- return value.hashCode(); -- } -- -- public String toString() -- { -- StringBuffer sbuf = new StringBuffer(); -- -- sbuf.append("IntMap["); -- boolean isFirst = true; -- -- for (int i = 0; i <= _keys.length; i++) { -- if (_keys[i] != null) { -- if (! isFirst) -- sbuf.append(", "); -- -- isFirst = false; -- sbuf.append(_keys[i]); -- sbuf.append(":"); -- sbuf.append(_values[i]); -- } -- } -- sbuf.append("]"); -- -- return sbuf.toString(); -- } -- -- public static final int []PRIMES = -- { -- 1, /* 1<< 0 = 1 */ -- 2, /* 1<< 1 = 2 */ -- 3, /* 1<< 2 = 4 */ -- 7, /* 1<< 3 = 8 */ -- 13, /* 1<< 4 = 16 */ -- 31, /* 1<< 5 = 32 */ -- 61, /* 1<< 6 = 64 */ -- 127, /* 1<< 7 = 128 */ -- 251, /* 1<< 8 = 256 */ -- 509, /* 1<< 9 = 512 */ -- 1021, /* 1<<10 = 1024 */ -- 2039, /* 1<<11 = 2048 */ -- 4093, /* 1<<12 = 4096 */ -- 8191, /* 1<<13 = 8192 */ -- 16381, /* 1<<14 = 16384 */ -- 32749, /* 1<<15 = 32768 */ -- 65521, /* 1<<16 = 65536 */ -- 131071, /* 1<<17 = 131072 */ -- 262139, /* 1<<18 = 262144 */ -- 524287, /* 1<<19 = 524288 */ -- 1048573, /* 1<<20 = 1048576 */ -- 2097143, /* 1<<21 = 2097152 */ -- 4194301, /* 1<<22 = 4194304 */ -- 8388593, /* 1<<23 = 8388608 */ -- 16777213, /* 1<<24 = 16777216 */ -- 33554393, /* 1<<25 = 33554432 */ -- 67108859, /* 1<<26 = 67108864 */ -- 134217689, /* 1<<27 = 134217728 */ -- 268435399, /* 1<<28 = 268435456 */ -- }; -- -- public static int getBiggestPrime(int value) -- { -- for (int i = PRIMES.length - 1; i >= 0; i--) { -- if (PRIMES[i] <= value) -- return PRIMES[i]; -- } -- -- return 2; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.hessian.util; -+ -+/** -+ * The IntMap provides a simple hashmap from keys to integers. The API is -+ * an abbreviation of the HashMap collection API. -+ * -+ *

The convenience of IntMap is avoiding all the silly wrapping of -+ * integers. -+ */ -+public class IntMap { -+ /** -+ * Encoding of a null entry. Since NULL is equal to Integer.MIN_VALUE, -+ * it's impossible to distinguish between the two. -+ */ -+ public final static int NULL = 0xdeadbeef; // Integer.MIN_VALUE + 1; -+ -+ private Object []_keys; -+ private int []_values; -+ -+ private int _size; -+ private int _prime; -+ -+ /** -+ * Create a new IntMap. Default size is 16. -+ */ -+ public IntMap() -+ { -+ int capacity = 1024; -+ -+ _keys = new Object[capacity]; -+ _values = new int[capacity]; -+ -+ _prime = getBiggestPrime(_keys.length); -+ _size = 0; -+ } -+ -+ /** -+ * Clear the hashmap. -+ */ -+ public void clear() -+ { -+ final Object []keys = _keys; -+ final int []values = _values; -+ -+ for (int i = keys.length - 1; i >= 0; i--) { -+ keys[i] = null; -+ values[i] = 0; -+ } -+ -+ _size = 0; -+ } -+ /** -+ * Returns the current number of entries in the map. -+ */ -+ public final int size() -+ { -+ return _size; -+ } -+ -+ /** -+ * Puts a new value in the property table with the appropriate flags -+ */ -+ public final int get(Object key) -+ { -+ int prime = _prime; -+ int hash = hashCode(key) % prime; -+ // int hash = key.hashCode() & mask; -+ -+ final Object []keys = _keys; -+ -+ while (true) { -+ Object mapKey = keys[hash]; -+ -+ if (mapKey == null) -+ return NULL; -+ else if (mapKey == key) -+ return _values[hash]; -+ -+ hash = (hash + 1) % prime; -+ } -+ } -+ -+ /** -+ * Puts a new value in the property table with the appropriate flags -+ */ -+ public final int put(Object key, int value, boolean isReplace) -+ { -+ int prime = _prime; -+ int hash = hashCode(key) % prime; -+ // int hash = key.hashCode() % prime; -+ -+ Object []keys = _keys; -+ -+ while (true) { -+ Object testKey = keys[hash]; -+ -+ if (testKey == null) { -+ keys[hash] = key; -+ _values[hash] = value; -+ -+ _size++; -+ -+ if (keys.length <= 4 * _size) -+ resize(4 * keys.length); -+ -+ return NULL; -+ } -+ else if (key != testKey) { -+ hash = (hash + 1) % prime; -+ -+ continue; -+ } -+ else if (isReplace){ -+ int old = _values[hash]; -+ -+ _values[hash] = value; -+ -+ return old; -+ } -+ else { -+ return _values[hash]; -+ } -+ } -+ } -+ -+ /** -+ * Expands the property table -+ */ -+ private void resize(int newSize) -+ { -+ Object []keys = _keys; -+ int values[] = _values; -+ -+ _keys = new Object[newSize]; -+ _values = new int[newSize]; -+ _size = 0; -+ -+ _prime = getBiggestPrime(_keys.length); -+ -+ for (int i = keys.length - 1; i >= 0; i--) { -+ Object key = keys[i]; -+ -+ if (key != null) { -+ put(key, values[i], true); -+ } -+ } -+ } -+ -+ protected int hashCode(Object value) -+ { -+ return value.hashCode(); -+ } -+ -+ public String toString() -+ { -+ StringBuffer sbuf = new StringBuffer(); -+ -+ sbuf.append("IntMap["); -+ boolean isFirst = true; -+ -+ for (int i = 0; i <= _keys.length; i++) { -+ if (_keys[i] != null) { -+ if (! isFirst) -+ sbuf.append(", "); -+ -+ isFirst = false; -+ sbuf.append(_keys[i]); -+ sbuf.append(":"); -+ sbuf.append(_values[i]); -+ } -+ } -+ sbuf.append("]"); -+ -+ return sbuf.toString(); -+ } -+ -+ public static final int []PRIMES = -+ { -+ 1, /* 1<< 0 = 1 */ -+ 2, /* 1<< 1 = 2 */ -+ 3, /* 1<< 2 = 4 */ -+ 7, /* 1<< 3 = 8 */ -+ 13, /* 1<< 4 = 16 */ -+ 31, /* 1<< 5 = 32 */ -+ 61, /* 1<< 6 = 64 */ -+ 127, /* 1<< 7 = 128 */ -+ 251, /* 1<< 8 = 256 */ -+ 509, /* 1<< 9 = 512 */ -+ 1021, /* 1<<10 = 1024 */ -+ 2039, /* 1<<11 = 2048 */ -+ 4093, /* 1<<12 = 4096 */ -+ 8191, /* 1<<13 = 8192 */ -+ 16381, /* 1<<14 = 16384 */ -+ 32749, /* 1<<15 = 32768 */ -+ 65521, /* 1<<16 = 65536 */ -+ 131071, /* 1<<17 = 131072 */ -+ 262139, /* 1<<18 = 262144 */ -+ 524287, /* 1<<19 = 524288 */ -+ 1048573, /* 1<<20 = 1048576 */ -+ 2097143, /* 1<<21 = 2097152 */ -+ 4194301, /* 1<<22 = 4194304 */ -+ 8388593, /* 1<<23 = 8388608 */ -+ 16777213, /* 1<<24 = 16777216 */ -+ 33554393, /* 1<<25 = 33554432 */ -+ 67108859, /* 1<<26 = 67108864 */ -+ 134217689, /* 1<<27 = 134217728 */ -+ 268435399, /* 1<<28 = 268435456 */ -+ }; -+ -+ public static int getBiggestPrime(int value) -+ { -+ for (int i = PRIMES.length - 1; i >= 0; i--) { -+ if (PRIMES[i] <= value) -+ return PRIMES[i]; -+ } -+ -+ return 2; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/client/ServiceProxyFactory.java hessian-4.0.65-fix/com/caucho/services/client/ServiceProxyFactory.java ---- hessian-4.0.65-src/com/caucho/services/client/ServiceProxyFactory.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/client/ServiceProxyFactory.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,81 +1,81 @@ --/* -- * The Apache Software License, Version 1.1 -- * -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.client; -- --/** -- * Factory for creating client stubs. The returned stub will -- * call the remote object for all methods. -- * -- *

-- * URL url = new URL("http://localhost:8080/ejb/hello");
-- * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-- * 
-- * -- * After creation, the stub can be like a regular Java class. Because -- * it makes remote calls, it can throw more exceptions than a Java class. -- * In particular, it may throw protocol exceptions. -- */ --public interface ServiceProxyFactory { -- /** -- * Creates a new proxy with the specified URL. The returned object -- * is a proxy with the interface specified by api. -- * -- *
--   * String url = "http://localhost:8080/ejb/hello");
--   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
--   * 
-- * -- * @param api the interface the proxy class needs to implement -- * @param url the URL where the client object is located. -- * -- * @return a proxy to the object with the specified interface. -- */ -- public Object create(Class api, String url) -- throws java.net.MalformedURLException; --} -+/* -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.client; -+ -+/** -+ * Factory for creating client stubs. The returned stub will -+ * call the remote object for all methods. -+ * -+ *
-+ * URL url = new URL("http://localhost:8080/ejb/hello");
-+ * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+ * 
-+ * -+ * After creation, the stub can be like a regular Java class. Because -+ * it makes remote calls, it can throw more exceptions than a Java class. -+ * In particular, it may throw protocol exceptions. -+ */ -+public interface ServiceProxyFactory { -+ /** -+ * Creates a new proxy with the specified URL. The returned object -+ * is a proxy with the interface specified by api. -+ * -+ *
-+   * String url = "http://localhost:8080/ejb/hello");
-+   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
-+   * 
-+ * -+ * @param api the interface the proxy class needs to implement -+ * @param url the URL where the client object is located. -+ * -+ * @return a proxy to the object with the specified interface. -+ */ -+ public Object create(Class api, String url) -+ throws java.net.MalformedURLException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/message/MessageSender.java hessian-4.0.65-fix/com/caucho/services/message/MessageSender.java ---- hessian-4.0.65-src/com/caucho/services/message/MessageSender.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/message/MessageSender.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,85 +1,85 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be -- * used to endorse or promote products derived from this software -- * without prior written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.message; -- --import java.util.HashMap; -- --/** -- * Service API for a bare-bones message server. -- * -- *

A minimal message server only needs to implement the MessageSender -- * interface. Keeping the server API simple makes it easier for -- * implementations to start up message servers. -- * -- *

The MessageSender service is queue or topic specific. So there's no -- * need for a To header if there's no routing involved. -- * In other words, the service URL generally includes the queue -- * or topic identifier, e.g. -- * -- *

-- * http://www.caucho.com/hessian/hessian/message?ejbid=topic-a
-- * 
-- *
-- * 

More complicated messaging topologies, including configurations -- * with routing mesaging servers, will use the headers to define the -- * final destination. The headers have the same functional purpose as -- * RFC-822 mail headers. -- */ --public interface MessageSender { -- /** -- * Send a message to the server. -- * -- * @param headers any message headers -- * @param message the message data -- * -- * @exception MessageServiceException if the message cannot be delivered -- */ -- public void send(HashMap headers, Object message) -- throws MessageServiceException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be -+ * used to endorse or promote products derived from this software -+ * without prior written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.message; -+ -+import java.util.HashMap; -+ -+/** -+ * Service API for a bare-bones message server. -+ * -+ *

A minimal message server only needs to implement the MessageSender -+ * interface. Keeping the server API simple makes it easier for -+ * implementations to start up message servers. -+ * -+ *

The MessageSender service is queue or topic specific. So there's no -+ * need for a To header if there's no routing involved. -+ * In other words, the service URL generally includes the queue -+ * or topic identifier, e.g. -+ * -+ *

-+ * http://www.caucho.com/hessian/hessian/message?ejbid=topic-a
-+ * 
-+ *
-+ * 

More complicated messaging topologies, including configurations -+ * with routing mesaging servers, will use the headers to define the -+ * final destination. The headers have the same functional purpose as -+ * RFC-822 mail headers. -+ */ -+public interface MessageSender { -+ /** -+ * Send a message to the server. -+ * -+ * @param headers any message headers -+ * @param message the message data -+ * -+ * @exception MessageServiceException if the message cannot be delivered -+ */ -+ public void send(HashMap headers, Object message) -+ throws MessageServiceException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/message/MessageServiceException.java hessian-4.0.65-fix/com/caucho/services/message/MessageServiceException.java ---- hessian-4.0.65-src/com/caucho/services/message/MessageServiceException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/message/MessageServiceException.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,110 +1,110 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.message; -- --import java.io.IOException; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroHessianInput. -- */ --public class MessageServiceException extends IOException { -- private Throwable _rootCause; -- -- /** -- * Zero-arg constructor. -- */ -- public MessageServiceException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public MessageServiceException(String message) -- { -- super(message); -- } -- -- /** -- * Create the exception. -- */ -- public MessageServiceException(String message, Throwable rootCause) -- { -- super(message); -- -- _rootCause = rootCause; -- } -- -- /** -- * Create the exception. -- */ -- public MessageServiceException(Throwable rootCause) -- { -- super(String.valueOf(rootCause)); -- -- _rootCause = rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getRootCause() -- { -- return getCause(); -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getCause() -- { -- return _rootCause; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.message; -+ -+import java.io.IOException; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroHessianInput. -+ */ -+public class MessageServiceException extends IOException { -+ private Throwable _rootCause; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public MessageServiceException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public MessageServiceException(String message) -+ { -+ super(message); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public MessageServiceException(String message, Throwable rootCause) -+ { -+ super(message); -+ -+ _rootCause = rootCause; -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public MessageServiceException(Throwable rootCause) -+ { -+ super(String.valueOf(rootCause)); -+ -+ _rootCause = rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getRootCause() -+ { -+ return getCause(); -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getCause() -+ { -+ return _rootCause; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/name/NameServer.java hessian-4.0.65-fix/com/caucho/services/name/NameServer.java ---- hessian-4.0.65-src/com/caucho/services/name/NameServer.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/name/NameServer.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,100 +1,100 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be -- * used to endorse or promote products derived from this software -- * without prior written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.name; -- --/** -- * A read-only name service. The name service provides hierarchical -- * object lookup. The path names are separated by '/'. -- * -- *

Because the name service is hierarchical, a lookup of an intermediate -- * node will return a NameServer instance. -- * -- *

The following example is a simple use of the NameServer: -- *

-- * /dir-1/1 - where foo contains the string "foo-1"
-- * /dir-1/2 - where foo contains the string "foo-2"
-- * /dir-2/1 - where foo contains the string "foo-1"
-- * /dir-2/2 - where foo contains the string "foo-2"
-- * 
-- * -- *

The root server might have a URL like: -- *

-- * http://www.caucho.com/hessian/hessian/name?ejbid=/
-- * 
-- * -- *

So root.lookup("/dir-1/1") will return the string -- * "foo-1", and root.lookup("/dir-1") will return the -- * NameServer with the URL: -- *

-- * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
-- * 
-- */ --public interface NameServer { -- /** -- * Lookup an object from the name server. -- * -- * @param name the relative path name -- * -- * @return the matching object or null if no object maches -- * -- * @exception NameServiceException if there's an error -- */ -- public Object lookup(String name) -- throws NameServiceException; -- -- /** -- * Lists all the object name components directly below the current context. -- * The names are the relative compent name. -- * -- *

For example, if the name server context is "/dir-1", the returned -- * values will be ["1", "2"]. -- */ -- public String []list() -- throws NameServiceException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be -+ * used to endorse or promote products derived from this software -+ * without prior written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.name; -+ -+/** -+ * A read-only name service. The name service provides hierarchical -+ * object lookup. The path names are separated by '/'. -+ * -+ *

Because the name service is hierarchical, a lookup of an intermediate -+ * node will return a NameServer instance. -+ * -+ *

The following example is a simple use of the NameServer: -+ *

-+ * /dir-1/1 - where foo contains the string "foo-1"
-+ * /dir-1/2 - where foo contains the string "foo-2"
-+ * /dir-2/1 - where foo contains the string "foo-1"
-+ * /dir-2/2 - where foo contains the string "foo-2"
-+ * 
-+ * -+ *

The root server might have a URL like: -+ *

-+ * http://www.caucho.com/hessian/hessian/name?ejbid=/
-+ * 
-+ * -+ *

So root.lookup("/dir-1/1") will return the string -+ * "foo-1", and root.lookup("/dir-1") will return the -+ * NameServer with the URL: -+ *

-+ * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
-+ * 
-+ */ -+public interface NameServer { -+ /** -+ * Lookup an object from the name server. -+ * -+ * @param name the relative path name -+ * -+ * @return the matching object or null if no object maches -+ * -+ * @exception NameServiceException if there's an error -+ */ -+ public Object lookup(String name) -+ throws NameServiceException; -+ -+ /** -+ * Lists all the object name components directly below the current context. -+ * The names are the relative compent name. -+ * -+ *

For example, if the name server context is "/dir-1", the returned -+ * values will be ["1", "2"]. -+ */ -+ public String []list() -+ throws NameServiceException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/name/NameServerRemote.java hessian-4.0.65-fix/com/caucho/services/name/NameServerRemote.java ---- hessian-4.0.65-src/com/caucho/services/name/NameServerRemote.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/name/NameServerRemote.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,102 +1,102 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be -- * used to endorse or promote products derived from this software -- * without prior written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.name; -- --import java.rmi.RemoteException; -- --/** -- * A read-only name service. The name service provides hierarchical -- * object lookup. The path names are separated by '/'. -- * -- *

Because the name service is hierarchical, a lookup of an intermediate -- * node will return a NameServer instance. -- * -- *

The following example is a simple use of the NameServer: -- *

-- * /dir-1/1 - where foo contains the string "foo-1"
-- * /dir-1/2 - where foo contains the string "foo-2"
-- * /dir-2/1 - where foo contains the string "foo-1"
-- * /dir-2/2 - where foo contains the string "foo-2"
-- * 
-- * -- *

The root server might have a URL like: -- *

-- * http://www.caucho.com/hessian/hessian/name?ejbid=/
-- * 
-- * -- *

So root.lookup("/dir-1/1") will return the string -- * "foo-1", and root.lookup("/dir-1") will return the -- * NameServer with the URL: -- *

-- * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
-- * 
-- */ --public interface NameServerRemote { -- /** -- * Lookup an object from the name server. -- * -- * @param name the relative path name -- * -- * @return the matching object or null if no object maches -- * -- * @exception NameServiceException if there's an error -- */ -- public Object lookup(String name) -- throws NameServiceException, RemoteException; -- -- /** -- * Lists all the object name components directly below the current context. -- * The names are the relative compent name. -- * -- *

For example, if the name server context is "/dir-1", the returned -- * values will be ["1", "2"]. -- */ -- public String []list() -- throws NameServiceException, RemoteException; --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Hessian", "Resin", and "Caucho" must not be -+ * used to endorse or promote products derived from this software -+ * without prior written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.name; -+ -+import java.rmi.RemoteException; -+ -+/** -+ * A read-only name service. The name service provides hierarchical -+ * object lookup. The path names are separated by '/'. -+ * -+ *

Because the name service is hierarchical, a lookup of an intermediate -+ * node will return a NameServer instance. -+ * -+ *

The following example is a simple use of the NameServer: -+ *

-+ * /dir-1/1 - where foo contains the string "foo-1"
-+ * /dir-1/2 - where foo contains the string "foo-2"
-+ * /dir-2/1 - where foo contains the string "foo-1"
-+ * /dir-2/2 - where foo contains the string "foo-2"
-+ * 
-+ * -+ *

The root server might have a URL like: -+ *

-+ * http://www.caucho.com/hessian/hessian/name?ejbid=/
-+ * 
-+ * -+ *

So root.lookup("/dir-1/1") will return the string -+ * "foo-1", and root.lookup("/dir-1") will return the -+ * NameServer with the URL: -+ *

-+ * http://www.caucho.com/hessian/hessian/name?ejbid=/dir-1
-+ * 
-+ */ -+public interface NameServerRemote { -+ /** -+ * Lookup an object from the name server. -+ * -+ * @param name the relative path name -+ * -+ * @return the matching object or null if no object maches -+ * -+ * @exception NameServiceException if there's an error -+ */ -+ public Object lookup(String name) -+ throws NameServiceException, RemoteException; -+ -+ /** -+ * Lists all the object name components directly below the current context. -+ * The names are the relative compent name. -+ * -+ *

For example, if the name server context is "/dir-1", the returned -+ * values will be ["1", "2"]. -+ */ -+ public String []list() -+ throws NameServiceException, RemoteException; -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/name/NameServiceException.java hessian-4.0.65-fix/com/caucho/services/name/NameServiceException.java ---- hessian-4.0.65-src/com/caucho/services/name/NameServiceException.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/name/NameServiceException.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,102 +1,102 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.name; -- --import java.io.IOException; -- --/** -- * Exception for faults when the fault doesn't return a java exception. -- * This exception is required for MicroHessianInput. -- */ --public class NameServiceException extends IOException { -- private Throwable rootCause; -- -- /** -- * Zero-arg constructor. -- */ -- public NameServiceException() -- { -- } -- -- /** -- * Create the exception. -- */ -- public NameServiceException(String name) -- { -- super(name); -- } -- -- /** -- * Create the exception. -- */ -- public NameServiceException(String name, Throwable rootCause) -- { -- super(name); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Create the exception. -- */ -- public NameServiceException(Throwable rootCause) -- { -- super(String.valueOf(rootCause)); -- -- this.rootCause = rootCause; -- } -- -- /** -- * Returns the underlying cause. -- */ -- public Throwable getRootCause() -- { -- return rootCause; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Burlap", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.name; -+ -+import java.io.IOException; -+ -+/** -+ * Exception for faults when the fault doesn't return a java exception. -+ * This exception is required for MicroHessianInput. -+ */ -+public class NameServiceException extends IOException { -+ private Throwable rootCause; -+ -+ /** -+ * Zero-arg constructor. -+ */ -+ public NameServiceException() -+ { -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public NameServiceException(String name) -+ { -+ super(name); -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public NameServiceException(String name, Throwable rootCause) -+ { -+ super(name); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Create the exception. -+ */ -+ public NameServiceException(Throwable rootCause) -+ { -+ super(String.valueOf(rootCause)); -+ -+ this.rootCause = rootCause; -+ } -+ -+ /** -+ * Returns the underlying cause. -+ */ -+ public Throwable getRootCause() -+ { -+ return rootCause; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/server/AbstractSkeleton.java hessian-4.0.65-fix/com/caucho/services/server/AbstractSkeleton.java ---- hessian-4.0.65-src/com/caucho/services/server/AbstractSkeleton.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/server/AbstractSkeleton.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,221 +1,221 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.server; -- --import java.io.InputStream; --import java.lang.reflect.Method; --import java.util.HashMap; -- --/** -- * Proxy class for Hessian services. -- */ --abstract public class AbstractSkeleton { -- private Class _apiClass; -- private Class _homeClass; -- private Class _objectClass; -- -- private HashMap _methodMap = new HashMap(); -- -- /** -- * Create a new hessian skeleton. -- * -- * @param apiClass the API interface -- */ -- protected AbstractSkeleton(Class apiClass) -- { -- _apiClass = apiClass; -- -- Method []methodList = apiClass.getMethods(); -- -- for (int i = 0; i < methodList.length; i++) { -- Method method = methodList[i]; -- -- if (_methodMap.get(method.getName()) == null) -- _methodMap.put(method.getName(), methodList[i]); -- -- Class []param = method.getParameterTypes(); -- String mangledName = method.getName() + "__" + param.length; -- _methodMap.put(mangledName, methodList[i]); -- -- _methodMap.put(mangleName(method, false), methodList[i]); -- } -- } -- -- /** -- * Returns the API class of the current object. -- */ -- public String getAPIClassName() -- { -- return _apiClass.getName(); -- } -- -- /** -- * Returns the API class of the factory/home. -- */ -- public String getHomeClassName() -- { -- if (_homeClass != null) -- return _homeClass.getName(); -- else -- return getAPIClassName(); -- } -- -- /** -- * Sets the home API class. -- */ -- public void setHomeClass(Class homeAPI) -- { -- _homeClass = homeAPI; -- } -- -- /** -- * Returns the API class of the object URLs -- */ -- public String getObjectClassName() -- { -- if (_objectClass != null) -- return _objectClass.getName(); -- else -- return getAPIClassName(); -- } -- -- /** -- * Sets the object API class. -- */ -- public void setObjectClass(Class objectAPI) -- { -- _objectClass = objectAPI; -- } -- -- /** -- * Returns the method by the mangled name. -- * -- * @param mangledName the name passed by the protocol -- */ -- protected Method getMethod(String mangledName) -- { -- return (Method) _methodMap.get(mangledName); -- } -- -- /** -- * Creates a unique mangled method name based on the method name and -- * the method parameters. -- * -- * @param method the method to mangle -- * @param isFull if true, mangle the full classname -- * -- * @return a mangled string. -- */ -- public static String mangleName(Method method, boolean isFull) -- { -- StringBuffer sb = new StringBuffer(); -- -- sb.append(method.getName()); -- -- Class []params = method.getParameterTypes(); -- for (int i = 0; i < params.length; i++) { -- sb.append('_'); -- sb.append(mangleClass(params[i], isFull)); -- } -- -- return sb.toString(); -- } -- -- /** -- * Mangles a classname. -- */ -- public static String mangleClass(Class cl, boolean isFull) -- { -- String name = cl.getName(); -- -- if (name.equals("boolean") || name.equals("java.lang.Boolean")) -- return "boolean"; -- else if (name.equals("int") || name.equals("java.lang.Integer") -- || name.equals("short") || name.equals("java.lang.Short") -- || name.equals("byte") || name.equals("java.lang.Byte")) -- return "int"; -- else if (name.equals("long") || name.equals("java.lang.Long")) -- return "long"; -- else if (name.equals("float") || name.equals("java.lang.Float") -- || name.equals("double") || name.equals("java.lang.Double")) -- return "double"; -- else if (name.equals("java.lang.String") -- || name.equals("com.caucho.util.CharBuffer") -- || name.equals("char") || name.equals("java.lang.Character") -- || name.equals("java.io.Reader")) -- return "string"; -- else if (name.equals("java.util.Date") -- || name.equals("com.caucho.util.QDate")) -- return "date"; -- else if (InputStream.class.isAssignableFrom(cl) -- || name.equals("[B")) -- return "binary"; -- else if (cl.isArray()) { -- return "[" + mangleClass(cl.getComponentType(), isFull); -- } -- else if (name.equals("org.w3c.dom.Node") -- || name.equals("org.w3c.dom.Element") -- || name.equals("org.w3c.dom.Document")) -- return "xml"; -- else if (isFull) -- return name; -- else { -- int p = name.lastIndexOf('.'); -- if (p > 0) -- return name.substring(p + 1); -- else -- return name; -- } -- } -- -- public String toString() -- { -- return getClass().getSimpleName() + "[" + _apiClass.getName() + "]"; -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.server; -+ -+import java.io.InputStream; -+import java.lang.reflect.Method; -+import java.util.HashMap; -+ -+/** -+ * Proxy class for Hessian services. -+ */ -+abstract public class AbstractSkeleton { -+ private Class _apiClass; -+ private Class _homeClass; -+ private Class _objectClass; -+ -+ private HashMap _methodMap = new HashMap(); -+ -+ /** -+ * Create a new hessian skeleton. -+ * -+ * @param apiClass the API interface -+ */ -+ protected AbstractSkeleton(Class apiClass) -+ { -+ _apiClass = apiClass; -+ -+ Method []methodList = apiClass.getMethods(); -+ -+ for (int i = 0; i < methodList.length; i++) { -+ Method method = methodList[i]; -+ -+ if (_methodMap.get(method.getName()) == null) -+ _methodMap.put(method.getName(), methodList[i]); -+ -+ Class []param = method.getParameterTypes(); -+ String mangledName = method.getName() + "__" + param.length; -+ _methodMap.put(mangledName, methodList[i]); -+ -+ _methodMap.put(mangleName(method, false), methodList[i]); -+ } -+ } -+ -+ /** -+ * Returns the API class of the current object. -+ */ -+ public String getAPIClassName() -+ { -+ return _apiClass.getName(); -+ } -+ -+ /** -+ * Returns the API class of the factory/home. -+ */ -+ public String getHomeClassName() -+ { -+ if (_homeClass != null) -+ return _homeClass.getName(); -+ else -+ return getAPIClassName(); -+ } -+ -+ /** -+ * Sets the home API class. -+ */ -+ public void setHomeClass(Class homeAPI) -+ { -+ _homeClass = homeAPI; -+ } -+ -+ /** -+ * Returns the API class of the object URLs -+ */ -+ public String getObjectClassName() -+ { -+ if (_objectClass != null) -+ return _objectClass.getName(); -+ else -+ return getAPIClassName(); -+ } -+ -+ /** -+ * Sets the object API class. -+ */ -+ public void setObjectClass(Class objectAPI) -+ { -+ _objectClass = objectAPI; -+ } -+ -+ /** -+ * Returns the method by the mangled name. -+ * -+ * @param mangledName the name passed by the protocol -+ */ -+ protected Method getMethod(String mangledName) -+ { -+ return (Method) _methodMap.get(mangledName); -+ } -+ -+ /** -+ * Creates a unique mangled method name based on the method name and -+ * the method parameters. -+ * -+ * @param method the method to mangle -+ * @param isFull if true, mangle the full classname -+ * -+ * @return a mangled string. -+ */ -+ public static String mangleName(Method method, boolean isFull) -+ { -+ StringBuffer sb = new StringBuffer(); -+ -+ sb.append(method.getName()); -+ -+ Class []params = method.getParameterTypes(); -+ for (int i = 0; i < params.length; i++) { -+ sb.append('_'); -+ sb.append(mangleClass(params[i], isFull)); -+ } -+ -+ return sb.toString(); -+ } -+ -+ /** -+ * Mangles a classname. -+ */ -+ public static String mangleClass(Class cl, boolean isFull) -+ { -+ String name = cl.getName(); -+ -+ if (name.equals("boolean") || name.equals("java.lang.Boolean")) -+ return "boolean"; -+ else if (name.equals("int") || name.equals("java.lang.Integer") -+ || name.equals("short") || name.equals("java.lang.Short") -+ || name.equals("byte") || name.equals("java.lang.Byte")) -+ return "int"; -+ else if (name.equals("long") || name.equals("java.lang.Long")) -+ return "long"; -+ else if (name.equals("float") || name.equals("java.lang.Float") -+ || name.equals("double") || name.equals("java.lang.Double")) -+ return "double"; -+ else if (name.equals("java.lang.String") -+ || name.equals("com.caucho.util.CharBuffer") -+ || name.equals("char") || name.equals("java.lang.Character") -+ || name.equals("java.io.Reader")) -+ return "string"; -+ else if (name.equals("java.util.Date") -+ || name.equals("com.caucho.util.QDate")) -+ return "date"; -+ else if (InputStream.class.isAssignableFrom(cl) -+ || name.equals("[B")) -+ return "binary"; -+ else if (cl.isArray()) { -+ return "[" + mangleClass(cl.getComponentType(), isFull); -+ } -+ else if (name.equals("org.w3c.dom.Node") -+ || name.equals("org.w3c.dom.Element") -+ || name.equals("org.w3c.dom.Document")) -+ return "xml"; -+ else if (isFull) -+ return name; -+ else { -+ int p = name.lastIndexOf('.'); -+ if (p > 0) -+ return name.substring(p + 1); -+ else -+ return name; -+ } -+ } -+ -+ public String toString() -+ { -+ return getClass().getSimpleName() + "[" + _apiClass.getName() + "]"; -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/server/GenericService.java hessian-4.0.65-fix/com/caucho/services/server/GenericService.java ---- hessian-4.0.65-src/com/caucho/services/server/GenericService.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/server/GenericService.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,153 +1,153 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.server; -- --import javax.servlet.ServletConfig; --import javax.servlet.ServletContext; --import javax.servlet.ServletException; --import javax.servlet.ServletRequest; -- --/** -- * Interface for a service, including lifecycle. -- */ --public class GenericService implements Service { -- protected ServletConfig config; -- -- /** -- * Initialize the service instance. -- */ -- public void init(ServletConfig config) -- throws ServletException -- { -- this.config = config; -- -- init(); -- } -- -- /** -- * Initialize the service instance. -- */ -- public void init() -- throws ServletException -- { -- } -- -- /** -- * Returns the named initialization parameter. -- */ -- public String getInitParameter(String name) -- { -- return this.config.getInitParameter(name); -- } -- -- /** -- * Returns the servlet context. -- */ -- public ServletConfig getServletConfig() -- { -- return this.config; -- } -- -- /** -- * Returns the servlet context. -- */ -- public ServletContext getServletContext() -- { -- return this.config.getServletContext(); -- } -- -- /** -- * Logs a message to the error stream. -- */ -- public void log(String message) -- { -- getServletContext().log(message); -- } -- -- /** -- * Returns the servlet request object for the request. -- */ -- public ServletRequest getRequest() -- { -- return ServiceContext.getRequest(); -- } -- -- /** -- * Returns the service identifier for the request. -- */ -- public String getServiceName() -- { -- return ServiceContext.getServiceName(); -- } -- -- /** -- * Returns the service identifier for the request. -- * -- * @deprecated -- */ -- public String getServiceId() -- { -- return getServiceName(); -- } -- -- /** -- * Returns the object identifier for the request. -- */ -- public String getObjectId() -- { -- return ServiceContext.getObjectId(); -- } -- -- /** -- * Cleanup the service instance. -- */ -- public void destroy() -- { -- } --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.server; -+ -+import javax.servlet.ServletConfig; -+import javax.servlet.ServletContext; -+import javax.servlet.ServletException; -+import javax.servlet.ServletRequest; -+ -+/** -+ * Interface for a service, including lifecycle. -+ */ -+public class GenericService implements Service { -+ protected ServletConfig config; -+ -+ /** -+ * Initialize the service instance. -+ */ -+ public void init(ServletConfig config) -+ throws ServletException -+ { -+ this.config = config; -+ -+ init(); -+ } -+ -+ /** -+ * Initialize the service instance. -+ */ -+ public void init() -+ throws ServletException -+ { -+ } -+ -+ /** -+ * Returns the named initialization parameter. -+ */ -+ public String getInitParameter(String name) -+ { -+ return this.config.getInitParameter(name); -+ } -+ -+ /** -+ * Returns the servlet context. -+ */ -+ public ServletConfig getServletConfig() -+ { -+ return this.config; -+ } -+ -+ /** -+ * Returns the servlet context. -+ */ -+ public ServletContext getServletContext() -+ { -+ return this.config.getServletContext(); -+ } -+ -+ /** -+ * Logs a message to the error stream. -+ */ -+ public void log(String message) -+ { -+ getServletContext().log(message); -+ } -+ -+ /** -+ * Returns the servlet request object for the request. -+ */ -+ public ServletRequest getRequest() -+ { -+ return ServiceContext.getRequest(); -+ } -+ -+ /** -+ * Returns the service identifier for the request. -+ */ -+ public String getServiceName() -+ { -+ return ServiceContext.getServiceName(); -+ } -+ -+ /** -+ * Returns the service identifier for the request. -+ * -+ * @deprecated -+ */ -+ public String getServiceId() -+ { -+ return getServiceName(); -+ } -+ -+ /** -+ * Returns the object identifier for the request. -+ */ -+ public String getObjectId() -+ { -+ return ServiceContext.getObjectId(); -+ } -+ -+ /** -+ * Cleanup the service instance. -+ */ -+ public void destroy() -+ { -+ } -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/server/Service.java hessian-4.0.65-fix/com/caucho/services/server/Service.java ---- hessian-4.0.65-src/com/caucho/services/server/Service.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/server/Service.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,83 +1,83 @@ --/* -- * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.server; -- --import javax.servlet.ServletConfig; --import javax.servlet.ServletException; -- --/** -- * Interface for a service lifecycle. -- * -- *

The lifecycle for a service starts with the init -- * method when the service starts. -- * -- *

-- * myService.init(config);
-- * ...
-- * myService.hello();
-- * ...
-- * myService.hello();
-- * ...
-- * myService.destroy();
-- * 
-- */ --public interface Service { -- /** -- * Initialize the service instance. -- * -- * @param config the configuration for the service. -- */ -- public void init(ServletConfig config) -- throws ServletException; -- -- /** -- * Cleanup the service instance. -- */ -- public void destroy(); --} -+/* -+ * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.server; -+ -+import javax.servlet.ServletConfig; -+import javax.servlet.ServletException; -+ -+/** -+ * Interface for a service lifecycle. -+ * -+ *

The lifecycle for a service starts with the init -+ * method when the service starts. -+ * -+ *

-+ * myService.init(config);
-+ * ...
-+ * myService.hello();
-+ * ...
-+ * myService.hello();
-+ * ...
-+ * myService.destroy();
-+ * 
-+ */ -+public interface Service { -+ /** -+ * Initialize the service instance. -+ * -+ * @param config the configuration for the service. -+ */ -+ public void init(ServletConfig config) -+ throws ServletException; -+ -+ /** -+ * Cleanup the service instance. -+ */ -+ public void destroy(); -+} -diff -uNr hessian-4.0.65-src/com/caucho/services/server/ServiceContext.java hessian-4.0.65-fix/com/caucho/services/server/ServiceContext.java ---- hessian-4.0.65-src/com/caucho/services/server/ServiceContext.java 2020-07-23 12:51:28.000000000 +0800 -+++ hessian-4.0.65-fix/com/caucho/services/server/ServiceContext.java 2023-08-15 18:39:24.000000000 +0800 -@@ -1,259 +1,274 @@ --/* -- * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -- * -- * The Apache Software License, Version 1.1 -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in -- * the documentation and/or other materials provided with the -- * distribution. -- * -- * 3. The end-user documentation included with the redistribution, if -- * any, must include the following acknowlegement: -- * "This product includes software developed by the -- * Caucho Technology (http://www.caucho.com/)." -- * Alternately, this acknowlegement may appear in the software itself, -- * if and wherever such third-party acknowlegements normally appear. -- * -- * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -- * endorse or promote products derived from this software without prior -- * written permission. For written permission, please contact -- * info@caucho.com. -- * -- * 5. Products derived from this software may not be called "Resin" -- * nor may "Resin" appear in their names without prior written -- * permission of Caucho Technology. -- * -- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * @author Scott Ferguson -- */ -- --package com.caucho.services.server; -- --import javax.servlet.ServletException; --import javax.servlet.ServletRequest; --import javax.servlet.ServletResponse; -- --import java.util.HashMap; -- --/** -- * Context for a service, to handle request-specific information. -- * -- * Applications can use the ServiceContext to get servlet session ids or -- * HTTP headers. -- * -- *
-- * ServletRequest req = ServiceContext.getContext().getRequest();
-- * 
-- */ --public class ServiceContext { -- private static final ThreadLocal _localContext -- = new ThreadLocal(); -- -- private ServletRequest _request; -- private ServletResponse _response; -- private String _serviceName; -- private String _objectId; -- private int _count; -- private HashMap _headers = new HashMap(); -- -- private ServiceContext() -- { -- } -- -- /** -- * Sets the request object prior to calling the service's method. -- * -- * @param request the calling servlet request -- * @param serviceId the service identifier -- * @param objectId the object identifier -- */ -- public static void begin(ServletRequest request, -- ServletResponse response, -- String serviceName, -- String objectId) -- throws ServletException -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context == null) { -- context = new ServiceContext(); -- _localContext.set(context); -- } -- -- context._request = request; -- context._response = response; -- context._serviceName = serviceName; -- context._objectId = objectId; -- context._count++; -- } -- -- /** -- * Returns the service request. -- */ -- public static ServiceContext getContext() -- { -- return (ServiceContext) _localContext.get(); -- } -- -- /** -- * Adds a header. -- */ -- public void addHeader(String header, Object value) -- { -- _headers.put(header, value); -- } -- -- /** -- * Gets a header. -- */ -- public Object getHeader(String header) -- { -- return _headers.get(header); -- } -- -- /** -- * Gets a header from the context. -- */ -- public static Object getContextHeader(String header) -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context.getHeader(header); -- else -- return null; -- } -- -- /** -- * Returns the service request. -- */ -- public static ServletRequest getContextRequest() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context._request; -- else -- return null; -- } -- -- /** -- * Returns the service request. -- */ -- public static ServletResponse getContextResponse() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context._response; -- else -- return null; -- } -- -- /** -- * Returns the service id, corresponding to the pathInfo of the URL. -- */ -- public static String getContextServiceName() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context._serviceName; -- else -- return null; -- } -- -- /** -- * Returns the object id, corresponding to the ?id= of the URL. -- */ -- public static String getContextObjectId() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context._objectId; -- else -- return null; -- } -- -- /** -- * Cleanup at the end of a request. -- */ -- public static void end() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null && --context._count == 0) { -- context._request = null; -- context._response = null; -- -- context._headers.clear(); -- -- _localContext.set(null); -- } -- } -- -- /** -- * Returns the service request. -- * -- * @deprecated -- */ -- public static ServletRequest getRequest() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context._request; -- else -- return null; -- } -- -- /** -- * Returns the service id, corresponding to the pathInfo of the URL. -- * -- * @deprecated -- */ -- public static String getServiceName() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context._serviceName; -- else -- return null; -- } -- -- /** -- * Returns the object id, corresponding to the ?id= of the URL. -- * -- * @deprecated -- */ -- public static String getObjectId() -- { -- ServiceContext context = (ServiceContext) _localContext.get(); -- -- if (context != null) -- return context._objectId; -- else -- return null; -- } --} -+/* -+ * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. -+ * -+ * The Apache Software License, Version 1.1 -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, if -+ * any, must include the following acknowlegement: -+ * "This product includes software developed by the -+ * Caucho Technology (http://www.caucho.com/)." -+ * Alternately, this acknowlegement may appear in the software itself, -+ * if and wherever such third-party acknowlegements normally appear. -+ * -+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to -+ * endorse or promote products derived from this software without prior -+ * written permission. For written permission, please contact -+ * info@caucho.com. -+ * -+ * 5. Products derived from this software may not be called "Resin" -+ * nor may "Resin" appear in their names without prior written -+ * permission of Caucho Technology. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS -+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * @author Scott Ferguson -+ */ -+ -+package com.caucho.services.server; -+ -+import javax.servlet.ServletException; -+import javax.servlet.ServletRequest; -+import javax.servlet.ServletResponse; -+ -+import java.util.HashMap; -+ -+/** -+ * Context for a service, to handle request-specific information. -+ * -+ * Applications can use the ServiceContext to get servlet session ids or -+ * HTTP headers. -+ * -+ *
-+ * ServletRequest req = ServiceContext.getContext().getRequest();
-+ * 
-+ */ -+public class ServiceContext { -+ private static final ThreadLocal _localContext -+ = new ThreadLocal(); -+ -+ private ServletRequest _request; -+ private ServletResponse _response; -+ private String _serviceName; -+ private String _objectId; -+ private int _count; -+ private HashMap _headers = new HashMap(); -+ -+ private ServiceContext() -+ { -+ } -+ -+ /** -+ * Sets the request object prior to calling the service's method. -+ * -+ * @param request the calling servlet request -+ * @param serviceId the service identifier -+ * @param objectId the object identifier -+ */ -+ public static void begin(ServletRequest request, -+ ServletResponse response, -+ String serviceName, -+ String objectId) -+ throws ServletException -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context == null) { -+ context = new ServiceContext(); -+ _localContext.set(context); -+ } -+ -+ context._request = request; -+ context._response = response; -+ context._serviceName = serviceName; -+ context._objectId = objectId; -+ context._count++; -+ } -+ -+ public static void begin(ServletRequest request, String serviceName, -+ String objectId) throws ServletException { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context == null) { -+ context = new ServiceContext(); -+ _localContext.set(context); -+ } -+ -+ context._request = request; -+ context._serviceName = serviceName; -+ context._objectId = objectId; -+ context._count++; -+ } -+ -+ /** -+ * Returns the service request. -+ */ -+ public static ServiceContext getContext() -+ { -+ return (ServiceContext) _localContext.get(); -+ } -+ -+ /** -+ * Adds a header. -+ */ -+ public void addHeader(String header, Object value) -+ { -+ _headers.put(header, value); -+ } -+ -+ /** -+ * Gets a header. -+ */ -+ public Object getHeader(String header) -+ { -+ return _headers.get(header); -+ } -+ -+ /** -+ * Gets a header from the context. -+ */ -+ public static Object getContextHeader(String header) -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context.getHeader(header); -+ else -+ return null; -+ } -+ -+ /** -+ * Returns the service request. -+ */ -+ public static ServletRequest getContextRequest() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context._request; -+ else -+ return null; -+ } -+ -+ /** -+ * Returns the service request. -+ */ -+ public static ServletResponse getContextResponse() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context._response; -+ else -+ return null; -+ } -+ -+ /** -+ * Returns the service id, corresponding to the pathInfo of the URL. -+ */ -+ public static String getContextServiceName() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context._serviceName; -+ else -+ return null; -+ } -+ -+ /** -+ * Returns the object id, corresponding to the ?id= of the URL. -+ */ -+ public static String getContextObjectId() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context._objectId; -+ else -+ return null; -+ } -+ -+ /** -+ * Cleanup at the end of a request. -+ */ -+ public static void end() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null && --context._count == 0) { -+ context._request = null; -+ context._response = null; -+ -+ context._headers.clear(); -+ -+ _localContext.set(null); -+ } -+ } -+ -+ /** -+ * Returns the service request. -+ * -+ * @deprecated -+ */ -+ public static ServletRequest getRequest() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context._request; -+ else -+ return null; -+ } -+ -+ /** -+ * Returns the service id, corresponding to the pathInfo of the URL. -+ * -+ * @deprecated -+ */ -+ public static String getServiceName() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context._serviceName; -+ else -+ return null; -+ } -+ -+ /** -+ * Returns the object id, corresponding to the ?id= of the URL. -+ * -+ * @deprecated -+ */ -+ public static String getObjectId() -+ { -+ ServiceContext context = (ServiceContext) _localContext.get(); -+ -+ if (context != null) -+ return context._objectId; -+ else -+ return null; -+ } -+} diff --git a/hessian-20230907.patch b/hessian-20230907.patch new file mode 100644 index 0000000..8be2098 --- /dev/null +++ b/hessian-20230907.patch @@ -0,0 +1,1798 @@ +diff -Npur hessian-4.0.65-src/META-INF/hessian/deserializers hessian-4.0.65-fix/META-INF/hessian/deserializers +--- hessian-4.0.65-src/META-INF/hessian/deserializers 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/META-INF/hessian/deserializers 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,3 @@ ++java.io.File=com.caucho.hessian.io.FileDeserializer ++java.math.BigDecimal=com.caucho.hessian.io.BigDecimalDeserializer ++javax.management.ObjectName=com.caucho.hessian.io.ObjectNameDeserializer +diff -Npur hessian-4.0.65-src/META-INF/hessian/serializers hessian-4.0.65-fix/META-INF/hessian/serializers +--- hessian-4.0.65-src/META-INF/hessian/serializers 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/META-INF/hessian/serializers 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,6 @@ ++com.caucho.hessian.io.HessianRemoteObject=com.caucho.hessian.io.RemoteSerializer ++com.caucho.burlap.io.BurlapRemoteObject=com.caucho.hessian.io.RemoteSerializer ++java.io.File=com.caucho.hessian.io.StringValueSerializer ++java.math.BigDecimal=com.caucho.hessian.io.StringValueSerializer ++java.util.Locale=com.caucho.hessian.io.LocaleSerializer ++javax.management.ObjectName=com.caucho.hessian.io.StringValueSerializer +diff -Npur hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianDeserializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,85 @@ ++package com.caucho.hessian.io; ++import com.caucho.hessian.io.AbstractDeserializer; ++import com.caucho.hessian.io.AbstractHessianInput; ++ ++import java.io.IOException; ++import java.util.Locale; ++ ++public class LocaleHessianDeserializer extends AbstractDeserializer { ++ ++ public Class getType() { ++ return Locale.class; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException { ++ int ref = in.addRef(null); ++ ++ String languageValue = null; ++ String countryValue = null; ++ String variantValue = null; ++ ++ while (!in.isEnd()) { ++ String key = in.readString(); ++ ++ if (key.equals("language")) ++ languageValue = in.readString(); ++ else if (key.equals("country")) ++ countryValue = in.readString(); ++ else if (key.equals("variant")) ++ variantValue = in.readString(); ++ else ++ in.readString(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object value = getObject(languageValue, countryValue, variantValue); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, Object[] fields) throws IOException { ++ int ref = in.addRef(null); ++ ++ String languageValue = null; ++ String countryValue = null; ++ String variantValue = null; ++ ++ for (Object key : fields) { ++ if (key.equals("language")) ++ languageValue = in.readString(); ++ else if (key.equals("country")) ++ countryValue = in.readString(); ++ else if (key.equals("variant")) ++ variantValue = in.readString(); ++ else ++ in.readObject(); ++ ++ } ++ ++ Object value = getObject(languageValue, countryValue, variantValue); ++ ++ in.setRef(ref, value); ++ ++ return value; ++ } ++ ++ private Object getObject(String languageValue, String countryValue, String variantValue) { ++ Object value = null; ++ if (languageValue != null && countryValue != null && variantValue != null) { ++ value = new Locale(languageValue, countryValue, variantValue); ++ } else if (languageValue != null && countryValue != null) { ++ value = new Locale(languageValue, countryValue); ++ } else if (languageValue != null) { ++ value = new Locale(languageValue); ++ } else { ++ value = Locale.getDefault(); ++ } ++ return value; ++ } ++ ++} +\ No newline at end of file +diff -Npur hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/LocaleHessianSerializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/LocaleHessianSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,64 @@ ++package com.caucho.hessian.io; ++import com.caucho.hessian.io.AbstractHessianOutput; ++import com.caucho.hessian.io.AbstractSerializer; ++ ++import java.io.IOException; ++import java.util.Locale; ++ ++public class LocaleHessianSerializer extends AbstractSerializer ++{ ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ ++ if (obj == null) ++ out.writeNull(); ++ else ++ { ++ Class cl = obj.getClass(); ++ ++ if (out.addRef(obj)) ++ return; ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ Locale loc = (Locale) obj; ++ ++ if (ref < -1) ++ { ++ if (loc.getLanguage() != null) ++ { ++ out.writeString("language"); ++ out.writeString(loc.getLanguage()); ++ } ++ if (loc.getCountry() != null) ++ { ++ out.writeString("country"); ++ out.writeString(loc.getCountry()); ++ } ++ if (loc.getVariant() != null) ++ { ++ out.writeString("variant"); ++ out.writeString(loc.getVariant()); ++ } ++ ++ out.writeMapEnd(); ++ } ++ else ++ { ++ if (ref == -1) ++ { ++ out.writeInt(3); ++ out.writeString("language"); ++ out.writeString("country"); ++ out.writeString("variant"); ++ out.writeObjectBegin(cl.getName()); ++ } ++ ++ out.writeString(loc.getLanguage()); ++ out.writeString(loc.getCountry()); ++ out.writeString(loc.getVariant()); ++ } ++ } ++ } ++} +\ No newline at end of file +diff -Npur hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeDeserializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,755 @@ ++/** ++ * ++ */ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.reflect.Field; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.HashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import sun.misc.Unsafe; ++ ++/** ++ * @author l65882 ++ * ++ */ ++public class NonTransientUnsafeDeserializer extends AbstractMapDeserializer { ++ private static final Logger log ++ = Logger.getLogger(JavaDeserializer.class.getName()); ++ ++ private static boolean _isEnabled; ++ @SuppressWarnings("restriction") ++ private static Unsafe _unsafe; ++ ++ private Class _type; ++ private HashMap _fieldMap; ++ private Method _readResolve; ++ ++ public NonTransientUnsafeDeserializer(Class cl) ++ { ++ _type = cl; ++ _fieldMap = getFieldMap(cl); ++ ++ _readResolve = getReadResolve(cl); ++ ++ if (_readResolve != null) { ++ _readResolve.setAccessible(true); ++ } ++ } ++ ++ public static boolean isEnabled() ++ { ++ return _isEnabled; ++ } ++ ++ @Override ++ public Class getType() ++ { ++ return _type; ++ } ++ ++ @Override ++ public boolean isReadResolve() ++ { ++ return _readResolve != null; ++ } ++ ++ public Object readMap(AbstractHessianInput in) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readMap(in, obj); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object []createFields(int len) ++ { ++ return new FieldDeserializer[len]; ++ } ++ ++ public Object createField(String name) ++ { ++ Object reader = _fieldMap.get(name); ++ ++ if (reader == null) ++ reader = NullFieldDeserializer.DESER; ++ ++ return reader; ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ Object []fields) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, (FieldDeserializer []) fields); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ @Override ++ public Object readObject(AbstractHessianInput in, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ Object obj = instantiate(); ++ ++ return readObject(in, obj, fieldNames); ++ } catch (IOException e) { ++ throw e; ++ } catch (RuntimeException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e); ++ } ++ } ++ ++ /** ++ * Returns the readResolve method ++ */ ++ protected Method getReadResolve(Class cl) ++ { ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Method []methods = cl.getDeclaredMethods(); ++ ++ for (int i = 0; i < methods.length; i++) { ++ Method method = methods[i]; ++ ++ if (method.getName().equals("readResolve") ++ && method.getParameterTypes().length == 0) ++ return method; ++ } ++ } ++ ++ return null; ++ } ++ ++ public Object readMap(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ while (! in.isEnd()) { ++ Object key = in.readObject(); ++ ++ FieldDeserializer deser = (FieldDeserializer) _fieldMap.get(key); ++ ++ if (deser != null) ++ deser.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ in.readMapEnd(); ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object obj, ++ FieldDeserializer []fields) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (FieldDeserializer reader : fields) { ++ reader.deserialize(in, obj); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ public Object readObject(AbstractHessianInput in, ++ Object obj, ++ String []fieldNames) ++ throws IOException ++ { ++ try { ++ int ref = in.addRef(obj); ++ ++ for (String fieldName : fieldNames) { ++ FieldDeserializer reader = _fieldMap.get(fieldName); ++ ++ if (reader != null) ++ reader.deserialize(in, obj); ++ else ++ in.readObject(); ++ } ++ ++ Object resolve = resolve(in, obj); ++ ++ if (obj != resolve) ++ in.setRef(ref, resolve); ++ ++ return resolve; ++ } catch (IOException e) { ++ throw e; ++ } catch (Exception e) { ++ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e); ++ } ++ } ++ ++ protected Object resolve(AbstractHessianInput in, Object obj) ++ throws Exception ++ { ++ // if there's a readResolve method, call it ++ try { ++ if (_readResolve != null) ++ return _readResolve.invoke(obj, new Object[0]); ++ } catch (InvocationTargetException e) { ++ if (e.getCause() instanceof Exception) ++ throw (Exception) e.getCause(); ++ else ++ throw e; ++ } ++ ++ return obj; ++ } ++ ++ @SuppressWarnings("restriction") ++ protected Object instantiate() ++ throws Exception ++ { ++ return _unsafe.allocateInstance(_type); ++ } ++ ++ /** ++ * Creates a map of the classes fields. ++ */ ++ protected HashMap getFieldMap(Class cl) ++ { ++ HashMap fieldMap ++ = new HashMap(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isStatic(field.getModifiers())) ++ continue; ++ else if (fieldMap.get(field.getName()) != null) ++ continue; ++ // XXX: could parameterize the handler to only deal with public ++ try { ++ field.setAccessible(true); ++ } catch (Throwable e) { ++ e.printStackTrace(); ++ } ++ ++ Class type = field.getType(); ++ FieldDeserializer deser; ++ ++ if (String.class.equals(type)) { ++ deser = new StringFieldDeserializer(field); ++ } ++ else if (byte.class.equals(type)) { ++ deser = new ByteFieldDeserializer(field); ++ } ++ else if (char.class.equals(type)) { ++ deser = new CharFieldDeserializer(field); ++ } ++ else if (short.class.equals(type)) { ++ deser = new ShortFieldDeserializer(field); ++ } ++ else if (int.class.equals(type)) { ++ deser = new IntFieldDeserializer(field); ++ } ++ else if (long.class.equals(type)) { ++ deser = new LongFieldDeserializer(field); ++ } ++ else if (float.class.equals(type)) { ++ deser = new FloatFieldDeserializer(field); ++ } ++ else if (double.class.equals(type)) { ++ deser = new DoubleFieldDeserializer(field); ++ } ++ else if (boolean.class.equals(type)) { ++ deser = new BooleanFieldDeserializer(field); ++ } ++ else if (java.sql.Date.class.equals(type)) { ++ deser = new SqlDateFieldDeserializer(field); ++ } ++ else if (java.sql.Timestamp.class.equals(type)) { ++ deser = new SqlTimestampFieldDeserializer(field); ++ } ++ else if (java.sql.Time.class.equals(type)) { ++ deser = new SqlTimeFieldDeserializer(field); ++ } ++ else { ++ deser = new ObjectFieldDeserializer(field); ++ } ++ ++ fieldMap.put(field.getName(), deser); ++ } ++ } ++ ++ return fieldMap; ++ } ++ ++ abstract static class FieldDeserializer { ++ abstract void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException; ++ } ++ ++ static class NullFieldDeserializer extends FieldDeserializer { ++ static NullFieldDeserializer DESER = new NullFieldDeserializer(); ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ in.readObject(); ++ } ++ } ++ ++ static class ObjectFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ObjectFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ Object value = null; ++ ++ try { ++ value = in.readObject(_field.getType()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class BooleanFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ BooleanFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ boolean value = false; ++ ++ try { ++ value = in.readBoolean(); ++ ++ _unsafe.putBoolean(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ByteFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ByteFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putByte(obj, _offset, (byte) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class CharFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ CharFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = in.readString(); ++ ++ char ch; ++ ++ if (value != null && value.length() > 0) ++ ch = value.charAt(0); ++ else ++ ch = 0; ++ ++ _unsafe.putChar(obj, _offset, ch); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class ShortFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ ShortFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putShort(obj, _offset, (short) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class IntFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ IntFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ int value = 0; ++ ++ try { ++ value = in.readInt(); ++ ++ _unsafe.putInt(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class LongFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ LongFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ long value = 0; ++ ++ try { ++ value = in.readLong(); ++ ++ _unsafe.putLong(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class FloatFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ FloatFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _unsafe.putFloat(obj, _offset, (float) value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class DoubleFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DoubleFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ double value = 0; ++ ++ try { ++ value = in.readDouble(); ++ ++ _unsafe.putDouble(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class StringFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ StringFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ String value = null; ++ ++ try { ++ value = in.readString(); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlDateFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlDateFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Date value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ value = new java.sql.Date(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimestampFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlTimestampFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Timestamp value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ value = new java.sql.Timestamp(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static class SqlTimeFieldDeserializer extends FieldDeserializer { ++ private final Field _field; ++ private final long _offset; ++ ++ @SuppressWarnings("restriction") ++ SqlTimeFieldDeserializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(_field); ++ } ++ ++ @SuppressWarnings("restriction") ++ void deserialize(AbstractHessianInput in, Object obj) ++ throws IOException ++ { ++ java.sql.Time value = null; ++ ++ try { ++ java.util.Date date = (java.util.Date) in.readObject(); ++ value = new java.sql.Time(date.getTime()); ++ ++ _unsafe.putObject(obj, _offset, value); ++ } catch (Exception e) { ++ logDeserializeError(_field, obj, value, e); ++ } ++ } ++ } ++ ++ static void logDeserializeError(Field field, Object obj, Object value, ++ Throwable e) ++ throws IOException ++ { ++ String fieldName = (field.getDeclaringClass().getName() ++ + "." + field.getName()); ++ ++ if (e instanceof HessianFieldException) ++ throw (HessianFieldException) e; ++ else if (e instanceof IOException) ++ throw new HessianFieldException(fieldName + ": " + e.getMessage(), e); ++ ++ if (value != null) ++ throw new HessianFieldException(fieldName + ": " + value.getClass().getName() + " (" + value + ")" ++ + " cannot be assigned to '" + field.getType().getName() + "'", e); ++ else ++ throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); ++ } ++ ++ static { ++ boolean isEnabled = false; ++ ++ try { ++ Class unsafe = Class.forName("sun.misc.Unsafe"); ++ Field theUnsafe = null; ++ for (Field field : unsafe.getDeclaredFields()) { ++ if (field.getName().equals("theUnsafe")) ++ theUnsafe = field; ++ } ++ ++ if (theUnsafe != null) { ++ theUnsafe.setAccessible(true); ++ _unsafe = (Unsafe) theUnsafe.get(null); ++ } ++ ++ isEnabled = _unsafe != null; ++ ++ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); ++ ++ if ("false".equals(unsafeProp)) ++ isEnabled = false; ++ } catch (Throwable e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _isEnabled = isEnabled; ++ } ++} +diff -Npur hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeSerializer.java hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeSerializer.java +--- hessian-4.0.65-src/com/caucho/hessian/io/NonTransientUnsafeSerializer.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/io/NonTransientUnsafeSerializer.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,518 @@ ++/** ++ * ++ */ ++package com.caucho.hessian.io; ++ ++import java.io.IOException; ++import java.lang.ref.SoftReference; ++import java.lang.reflect.Field; ++import java.lang.reflect.Modifier; ++import java.util.ArrayList; ++import java.util.WeakHashMap; ++import java.util.logging.Level; ++import java.util.logging.Logger; ++ ++import sun.misc.Unsafe; ++ ++ ++ ++/** ++ * @author l65882 ++ * ++ */ ++public class NonTransientUnsafeSerializer extends AbstractSerializer { ++ ++ private static final Logger log ++ = Logger.getLogger(NonTransientUnsafeSerializer.class.getName()); ++ ++ private static boolean _isEnabled; ++ private static Unsafe _unsafe; ++ ++ private static final WeakHashMap,SoftReference> _serializerMap ++ = new WeakHashMap,SoftReference>(); ++ ++ private static Object []NULL_ARGS = new Object[0]; ++ ++ private Field []_fields; ++ private FieldSerializer []_fieldSerializers; ++ ++ public static boolean isEnabled() ++ { ++ return _isEnabled; ++ } ++ ++ public NonTransientUnsafeSerializer(Class cl) ++ { ++ introspect(cl); ++ } ++ ++ public static NonTransientUnsafeSerializer create(Class cl) ++ { ++ ClassLoader loader = cl.getClassLoader(); ++ ++ synchronized (_serializerMap) { ++ SoftReference baseRef ++ = _serializerMap.get(cl); ++ ++ NonTransientUnsafeSerializer base = baseRef != null ? baseRef.get() : null; ++ ++ if (base == null) { ++ base = new NonTransientUnsafeSerializer(cl); ++ baseRef = new SoftReference(base); ++ _serializerMap.put(cl, baseRef); ++ } ++ ++ return base; ++ } ++ } ++ ++ protected void introspect(Class cl) ++ { ++ ArrayList primitiveFields = new ArrayList(); ++ ArrayList compoundFields = new ArrayList(); ++ ++ for (; cl != null; cl = cl.getSuperclass()) { ++ Field []fields = cl.getDeclaredFields(); ++ for (int i = 0; i < fields.length; i++) { ++ Field field = fields[i]; ++ ++ if (Modifier.isStatic(field.getModifiers())) ++ continue; ++ ++ // XXX: could parameterize the handler to only deal with public ++ field.setAccessible(true); ++ ++ if (field.getType().isPrimitive() ++ || (field.getType().getName().startsWith("java.lang.") ++ && ! field.getType().equals(Object.class))) ++ primitiveFields.add(field); ++ else ++ compoundFields.add(field); ++ } ++ } ++ ++ ArrayList fields = new ArrayList(); ++ fields.addAll(primitiveFields); ++ fields.addAll(compoundFields); ++ ++ _fields = new Field[fields.size()]; ++ fields.toArray(_fields); ++ ++ _fieldSerializers = new FieldSerializer[_fields.length]; ++ ++ for (int i = 0; i < _fields.length; i++) { ++ _fieldSerializers[i] = getFieldSerializer(_fields[i]); ++ } ++ } ++ ++ @Override ++ public void writeObject(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ if (out.addRef(obj)) { ++ return; ++ } ++ ++ Class cl = obj.getClass(); ++ ++ int ref = out.writeObjectBegin(cl.getName()); ++ ++ if (ref >= 0) { ++ writeInstance(obj, out); ++ } ++ else if (ref == -1) { ++ writeDefinition20(out); ++ out.writeObjectBegin(cl.getName()); ++ writeInstance(obj, out); ++ } ++ else { ++ writeObject10(obj, out); ++ } ++ } ++ ++ protected void writeObject10(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ ++ _fieldSerializers[i].serialize(out, obj); ++ } ++ ++ out.writeMapEnd(); ++ } ++ ++ private void writeDefinition20(AbstractHessianOutput out) ++ throws IOException ++ { ++ out.writeClassFieldLength(_fields.length); ++ ++ for (int i = 0; i < _fields.length; i++) { ++ Field field = _fields[i]; ++ ++ out.writeString(field.getName()); ++ } ++ } ++ ++ final public void writeInstance(Object obj, AbstractHessianOutput out) ++ throws IOException ++ { ++ try { ++ FieldSerializer []fieldSerializers = _fieldSerializers; ++ int length = fieldSerializers.length; ++ ++ for (int i = 0; i < length; i++) { ++ fieldSerializers[i].serialize(out, obj); ++ } ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n class: " ++ + obj.getClass().getName() ++ + " (object=" + obj + ")", ++ e); ++ } ++ } ++ ++ private static FieldSerializer getFieldSerializer(Field field) ++ { ++ Class type = field.getType(); ++ ++ if (boolean.class.equals(type)) { ++ return new BooleanFieldSerializer(field); ++ } ++ else if (byte.class.equals(type)) { ++ return new ByteFieldSerializer(field); ++ } ++ else if (char.class.equals(type)) { ++ return new CharFieldSerializer(field); ++ } ++ else if (short.class.equals(type)) { ++ return new ShortFieldSerializer(field); ++ } ++ else if (int.class.equals(type)) { ++ return new IntFieldSerializer(field); ++ } ++ else if (long.class.equals(type)) { ++ return new LongFieldSerializer(field); ++ } ++ else if (double.class.equals(type)) { ++ return new DoubleFieldSerializer(field); ++ } ++ else if (float.class.equals(type)) { ++ return new FloatFieldSerializer(field); ++ } ++ else if (String.class.equals(type)) { ++ return new StringFieldSerializer(field); ++ } ++ else if (java.util.Date.class.equals(type) ++ || java.sql.Date.class.equals(type) ++ || java.sql.Timestamp.class.equals(type) ++ || java.sql.Time.class.equals(type)) { ++ return new DateFieldSerializer(field); ++ } ++ else ++ return new ObjectFieldSerializer(field); ++ } ++ ++ abstract static class FieldSerializer { ++ abstract void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException; ++ } ++ ++ final static class ObjectFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ObjectFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ try { ++ Object value = _unsafe.getObject(obj, _offset); ++ ++ out.writeObject(value); ++ } catch (RuntimeException e) { ++ throw new RuntimeException(e.getMessage() + "\n field: " ++ + _field.getDeclaringClass().getName() ++ + '.' + _field.getName(), ++ e); ++ } catch (IOException e) { ++ throw new IOExceptionWrapper(e.getMessage() + "\n field: " ++ + _field.getDeclaringClass().getName() ++ + '.' + _field.getName(), ++ e); ++ } ++ } ++ } ++ ++ final static class BooleanFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ BooleanFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ boolean value = _unsafe.getBoolean(obj, _offset); ++ ++ out.writeBoolean(value); ++ } ++ } ++ ++ final static class ByteFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ByteFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getByte(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class CharFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ CharFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ char value = _unsafe.getChar(obj, _offset); ++ ++ out.writeString(String.valueOf(value)); ++ } ++ } ++ ++ final static class ShortFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ ShortFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getShort(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class IntFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ IntFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ int value = _unsafe.getInt(obj, _offset); ++ ++ out.writeInt(value); ++ } ++ } ++ ++ final static class LongFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ LongFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ long value = _unsafe.getLong(obj, _offset); ++ ++ out.writeLong(value); ++ } ++ } ++ ++ final static class FloatFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ FloatFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ double value = _unsafe.getFloat(obj, _offset); ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ final static class DoubleFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DoubleFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ double value = _unsafe.getDouble(obj, _offset); ++ ++ out.writeDouble(value); ++ } ++ } ++ ++ final static class StringFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ StringFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ final void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ String value = (String) _unsafe.getObject(obj, _offset); ++ ++ out.writeString(value); ++ } ++ } ++ ++ final static class DateFieldSerializer extends FieldSerializer { ++ private final Field _field; ++ private final long _offset; ++ ++ DateFieldSerializer(Field field) ++ { ++ _field = field; ++ _offset = _unsafe.objectFieldOffset(field); ++ ++ if (_offset == Unsafe.INVALID_FIELD_OFFSET) ++ throw new IllegalStateException(); ++ } ++ ++ @Override ++ void serialize(AbstractHessianOutput out, Object obj) ++ throws IOException ++ { ++ java.util.Date value ++ = (java.util.Date) _unsafe.getObject(obj, _offset); ++ ++ if (value == null) ++ out.writeNull(); ++ else ++ out.writeUTCDate(value.getTime()); ++ } ++ } ++ ++ static { ++ boolean isEnabled = false; ++ ++ try { ++ Class unsafe = Class.forName("sun.misc.Unsafe"); ++ Field theUnsafe = null; ++ for (Field field : unsafe.getDeclaredFields()) { ++ if (field.getName().equals("theUnsafe")) ++ theUnsafe = field; ++ } ++ ++ if (theUnsafe != null) { ++ theUnsafe.setAccessible(true); ++ _unsafe = (Unsafe) theUnsafe.get(null); ++ } ++ ++ isEnabled = _unsafe != null; ++ ++ String unsafeProp = System.getProperty("com.caucho.hessian.unsafe"); ++ ++ if ("false".equals(unsafeProp)) ++ isEnabled = false; ++ } catch (Throwable e) { ++ log.log(Level.FINER, e.toString(), e); ++ } ++ ++ _isEnabled = isEnabled; ++ } ++ ++} +diff -Npur hessian-4.0.65-src/com/caucho/hessian/server/HessianDispatcher.java hessian-4.0.65-fix/com/caucho/hessian/server/HessianDispatcher.java +--- hessian-4.0.65-src/com/caucho/hessian/server/HessianDispatcher.java 1970-01-01 08:00:00.000000000 +0800 ++++ hessian-4.0.65-fix/com/caucho/hessian/server/HessianDispatcher.java 2023-08-15 18:39:22.000000000 +0800 +@@ -0,0 +1,337 @@ ++ ++package com.caucho.hessian.server; ++ ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.OutputStream; ++import java.io.PrintWriter; ++import java.io.Writer; ++import java.util.Map; ++import java.util.Properties; ++import java.util.concurrent.ConcurrentHashMap; ++import java.util.logging.Logger; ++ ++import javax.servlet.GenericServlet; ++import javax.servlet.Servlet; ++import javax.servlet.ServletConfig; ++import javax.servlet.ServletException; ++import javax.servlet.ServletRequest; ++import javax.servlet.ServletResponse; ++import javax.servlet.http.HttpServletRequest; ++import javax.servlet.http.HttpServletResponse; ++ ++import org.springframework.context.ApplicationContext; ++import org.springframework.web.context.support.WebApplicationContextUtils; ++ ++import com.caucho.hessian.io.Hessian2Input; ++import com.caucho.hessian.io.SerializerFactory; ++import com.caucho.services.server.Service; ++import com.caucho.services.server.ServiceContext; ++ ++ ++public class HessianDispatcher extends GenericServlet ++{ ++ ++ ++ private static final long serialVersionUID = -8611469561907416355L; ++ ++ private SerializerFactory _serializerFactory; ++ ++ private static final String SERVICE_FILE_PATH = "config-file"; ++ ++ private static Map registry = new ConcurrentHashMap(); ++ ++ private static Properties props = new Properties(); ++ ++ public HessianDispatcher() ++ { ++ } ++ ++ public String getServletInfo() ++ { ++ return "Hessian Dispatcher"; ++ } ++ ++ /** ++ * Sets the serializer factory. ++ */ ++ public void setSerializerFactory(SerializerFactory factory) ++ { ++ _serializerFactory = factory; ++ } ++ ++ /** ++ * Gets the serializer factory. ++ */ ++ public SerializerFactory getSerializerFactory() ++ { ++ if (_serializerFactory == null) ++ _serializerFactory = new SerializerFactory(); ++ ++ return _serializerFactory; ++ } ++ ++ /** ++ * Sets the serializer send collection java type. ++ */ ++ public void setSendCollectionType(boolean sendType) ++ { ++ getSerializerFactory().setSendCollectionType(sendType); ++ } ++ ++ /** ++ * Initialize the service, including the service object. ++ */ ++ public void init(ServletConfig config) throws ServletException ++ { ++ super.init(config); ++ ++ try ++ { ++ String serviceConfigFile = getInitParameter(SERVICE_FILE_PATH); ++ ++ if (null == serviceConfigFile) ++ { ++ throw new ServletException( ++ "Hessian service registry file path must be set in classpath when using 'HessianDispatcher'"); ++ } ++ ++ props.load(this.getClass().getClassLoader() ++ .getResourceAsStream(serviceConfigFile)); ++ } ++ ++ catch (Exception e) ++ { ++ throw new ServletException(e); ++ } ++ } ++ ++ private Class loadClass(String className) throws ClassNotFoundException ++ { ++ ClassLoader loader = getContextClassLoader(); ++ ++ if (loader != null) ++ return Class.forName(className, false, loader); ++ else ++ return Class.forName(className); ++ } ++ ++ protected ClassLoader getContextClassLoader() ++ { ++ return Thread.currentThread().getContextClassLoader(); ++ } ++ ++ private void init(Object service) throws ServletException ++ { ++ if (!this.getClass().equals(HessianDispatcher.class)) ++ { ++ } ++ else if (service instanceof Service) ++ ((Service) service).init(getServletConfig()); ++ else if (service instanceof Servlet) ++ ((Servlet) service).init(getServletConfig()); ++ } ++ ++ /** ++ * Execute a request. The path-info of the request selects the bean. Once ++ * the bean's selected, it will be applied. ++ */ ++ public void service(ServletRequest request, ServletResponse response) ++ throws IOException, ServletException ++ { ++ HttpServletRequest req = (HttpServletRequest) request; ++ HttpServletResponse res = (HttpServletResponse) response; ++ ++ if (!req.getMethod().equals("POST")) ++ { ++ res.setStatus(500, "Hessian Requires POST"); ++ PrintWriter out = res.getWriter(); ++ ++ res.setContentType("text/html"); ++ out.println("

Hessian Requires POST

"); ++ ++ return; ++ } ++ ++ String serviceInterface = req.getHeader("Interface-Name"); ++ ++ if (null == serviceInterface) ++ { ++ throw new ServletException( ++ "The service interface you reqeust is null. please check the client setting."); ++ } ++ ++ try ++ { ++ HessianSkeleton skeleton = findHessianSkeleton(serviceInterface); ++ ++ String serviceId = req.getPathInfo(); ++ ++ String objectId = req.getParameter("id"); ++ ++ if (objectId == null) ++ objectId = req.getParameter("ejbid"); ++ ++ ServiceContext.begin(req, serviceId, objectId); ++ ++ InputStream is = request.getInputStream(); ++ ++ OutputStream os = response.getOutputStream(); ++ ++ response.setContentType("application/x-hessian"); ++ ++ SerializerFactory serializerFactory = getSerializerFactory(); ++ ++ invoke(is, os, skeleton, serializerFactory); ++ } ++ catch (RuntimeException e) ++ { ++ throw e; ++ } ++ catch (ServletException e) ++ { ++ throw e; ++ } ++ catch (Throwable e) ++ { ++ throw new ServletException(e); ++ } ++ finally ++ { ++ ServiceContext.end(); ++ } ++ } ++ ++ ++ private HessianSkeleton findHessianSkeleton(String serviceInterface) ++ throws ServletException, ClassNotFoundException, ++ IllegalAccessException, InstantiationException ++ { ++ HessianSkeleton skeleton = null; ++ ++ if (registry.containsKey(serviceInterface))// find in cache first ++ { ++ skeleton = registry.get(serviceInterface); ++ } ++ else ++ // parse serviceImpl string to create skeleton. ++ { ++ String serviceImpl = (String) this.props.get(serviceInterface); ++ ++ if (null == serviceImpl) ++ { ++ throw new ServletException( ++ "Your request service of " ++ + serviceInterface ++ + " dose not exsit.please check the server configuration."); ++ } ++ if (serviceImpl.startsWith("#"))// for get bean from spring ++ { ++ skeleton = findSpringSkeleton(serviceInterface, serviceImpl); ++ } ++ else ++ { ++ skeleton = findLocalSkeleton(serviceInterface, serviceImpl); ++ } ++ ++ } ++ ++ registry.put(serviceInterface, skeleton); ++ ++ return skeleton; ++ } ++ ++ ++ private HessianSkeleton findLocalSkeleton(String serviceInterface, ++ String serviceImpl) throws ClassNotFoundException, ++ InstantiationException, IllegalAccessException, ServletException ++ { ++ HessianSkeleton skeleton; ++ Class homeClass = loadClass(serviceImpl); ++ ++ Object localBean = homeClass.newInstance(); ++ ++ init(localBean); ++ ++ skeleton = new HessianSkeleton(localBean, loadClass(serviceInterface)); ++ return skeleton; ++ } ++ ++ ++ private HessianSkeleton findSpringSkeleton(String serviceInterface, ++ String serviceImpl) throws ServletException, ClassNotFoundException ++ { ++ HessianSkeleton skeleton; ++ String beanId = serviceImpl.substring(1, serviceImpl.length()); ++ ++ ApplicationContext wac = WebApplicationContextUtils ++ .getWebApplicationContext(getServletContext()); ++ ++ Object springBean = wac.getBean(beanId.trim()); ++ ++ init(springBean); ++ ++ skeleton = new HessianSkeleton(springBean, loadClass(serviceInterface)); ++ ++ return skeleton; ++ } ++ ++ protected void invoke(InputStream is, OutputStream os, ++ HessianSkeleton skeleton, SerializerFactory serializerFactory) ++ throws Exception ++ { ++ skeleton.invoke(is, os, serializerFactory); ++ } ++ ++ protected Hessian2Input createHessian2Input(InputStream is) ++ { ++ return new Hessian2Input(is); ++ } ++ ++ static class LogWriter extends Writer ++ { ++ private Logger _log; ++ ++ private StringBuilder _sb = new StringBuilder(); ++ ++ LogWriter(Logger log) ++ { ++ _log = log; ++ } ++ ++ public void write(char ch) ++ { ++ if (ch == '\n' && _sb.length() > 0) ++ { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ ++ public void write(char[] buffer, int offset, int length) ++ { ++ for (int i = 0; i < length; i++) ++ { ++ char ch = buffer[offset + i]; ++ ++ if (ch == '\n' && _sb.length() > 0) ++ { ++ _log.fine(_sb.toString()); ++ _sb.setLength(0); ++ } ++ else ++ _sb.append((char) ch); ++ } ++ } ++ ++ public void flush() ++ { ++ } ++ ++ public void close() ++ { ++ } ++ } ++} diff --git a/hessian.spec b/hessian.spec index 9ba203a..f879e8f 100644 --- a/hessian.spec +++ b/hessian.spec @@ -11,7 +11,7 @@ Source2: https://opensource.org/licenses/Apache-1.1#/Apache-1.1.html BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) -Patch1: %{name}-202308291450.patch +Patch1: %{name}-20230907.patch BuildArch: noarch %description -- Gitee From d1ee824eb2750e4d5f5434b09ff4bb630a37464f Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Thu, 7 Sep 2023 16:15:22 +0800 Subject: [PATCH 06/16] add pom dep --- hessian.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/hessian.spec b/hessian.spec index f879e8f..c246698 100644 --- a/hessian.spec +++ b/hessian.spec @@ -33,6 +33,7 @@ rm -r src/com/caucho/hessian/test cp -p %{SOURCE1} pom.xml cp -p %{SOURCE2} apache.license.html %pom_change_dep :servlet-api javax.servlet:javax.servlet-api:3.1.0 +%pom_change_dep -r :org.springframework:org.springframework.web:3.0.5.Release %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin -- Gitee From 6b651dec3319bf63481be710893644921bb0dad4 Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Thu, 7 Sep 2023 23:01:53 +0800 Subject: [PATCH 07/16] change dep --- hessian.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hessian.spec b/hessian.spec index c246698..4c7a7fc 100644 --- a/hessian.spec +++ b/hessian.spec @@ -33,7 +33,7 @@ rm -r src/com/caucho/hessian/test cp -p %{SOURCE1} pom.xml cp -p %{SOURCE2} apache.license.html %pom_change_dep :servlet-api javax.servlet:javax.servlet-api:3.1.0 -%pom_change_dep -r :org.springframework:org.springframework.web:3.0.5.Release +%pom_change_dep :org.springframework:org.springframework.web:3.0.5.Release %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin -- Gitee From 0b92da6da4328e20e8604c1bb1427fc356c11f9b Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Thu, 7 Sep 2023 23:17:22 +0800 Subject: [PATCH 08/16] change dep --- hessian.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hessian.spec b/hessian.spec index 4c7a7fc..efac50a 100644 --- a/hessian.spec +++ b/hessian.spec @@ -33,7 +33,7 @@ rm -r src/com/caucho/hessian/test cp -p %{SOURCE1} pom.xml cp -p %{SOURCE2} apache.license.html %pom_change_dep :servlet-api javax.servlet:javax.servlet-api:3.1.0 -%pom_change_dep :org.springframework:org.springframework.web:3.0.5.Release +%pom_change_dep :springframework-web org.springframework:org.springframework.web:3.0.5.Release %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin -- Gitee From 8076d08ecea1fd2b54d98b16f62cce93f1791cdf Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Thu, 7 Sep 2023 23:32:18 +0800 Subject: [PATCH 09/16] change dep --- hessian.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/hessian.spec b/hessian.spec index efac50a..772741c 100644 --- a/hessian.spec +++ b/hessian.spec @@ -10,6 +10,7 @@ Source1: https://repo1.maven.org/maven2/com/caucho/%{name}/%{version Source2: https://opensource.org/licenses/Apache-1.1#/Apache-1.1.html#/Apache-1.1 BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) +BuildRequires: mvn(org.springframework:org.springframework.web) Patch1: %{name}-20230907.patch -- Gitee From e5d91e0c3f7ebf57538a0dc66b72a02682889e1a Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 8 Sep 2023 00:00:01 +0800 Subject: [PATCH 10/16] change dep --- hessian.spec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hessian.spec b/hessian.spec index 772741c..f9e0da5 100644 --- a/hessian.spec +++ b/hessian.spec @@ -8,9 +8,8 @@ URL: http://hessian.caucho.com/ Source0: http://caucho.com/download/%{name}-%{version}-src.jar Source1: https://repo1.maven.org/maven2/com/caucho/%{name}/%{version}/%{name}-%{version}.pom Source2: https://opensource.org/licenses/Apache-1.1#/Apache-1.1.html#/Apache-1.1 -BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) -BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) -BuildRequires: mvn(org.springframework:org.springframework.web) +BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) mvn(org.springframework:org.springframework.web) +BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) Patch1: %{name}-20230907.patch -- Gitee From af3d16801ed72b99c9f5d4465d02facf5984f2a0 Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 8 Sep 2023 22:51:05 +0800 Subject: [PATCH 11/16] change dep --- hessian-4.0.65.pom | 5 +++++ hessian.spec | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hessian-4.0.65.pom b/hessian-4.0.65.pom index 7d7d745..f9a89d7 100644 --- a/hessian-4.0.65.pom +++ b/hessian-4.0.65.pom @@ -37,6 +37,11 @@ servlet-api 2.5 provided + + + org.springframework + org.springframework.web + 3.0.5.Release diff --git a/hessian.spec b/hessian.spec index f9e0da5..02eb133 100644 --- a/hessian.spec +++ b/hessian.spec @@ -8,7 +8,7 @@ URL: http://hessian.caucho.com/ Source0: http://caucho.com/download/%{name}-%{version}-src.jar Source1: https://repo1.maven.org/maven2/com/caucho/%{name}/%{version}/%{name}-%{version}.pom Source2: https://opensource.org/licenses/Apache-1.1#/Apache-1.1.html#/Apache-1.1 -BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) mvn(org.springframework:org.springframework.web) +BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) Patch1: %{name}-20230907.patch -- Gitee From 6c11bb498c87ec848458fdaacf02bc3d297034bb Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 8 Sep 2023 23:00:19 +0800 Subject: [PATCH 12/16] change dep --- hessian.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hessian.spec b/hessian.spec index 02eb133..56fa963 100644 --- a/hessian.spec +++ b/hessian.spec @@ -33,7 +33,7 @@ rm -r src/com/caucho/hessian/test cp -p %{SOURCE1} pom.xml cp -p %{SOURCE2} apache.license.html %pom_change_dep :servlet-api javax.servlet:javax.servlet-api:3.1.0 -%pom_change_dep :springframework-web org.springframework:org.springframework.web:3.0.5.Release +%pom_change_dep :org.springframework:org.springframework.web:3.0.5.Release %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin -- Gitee From 0517e0b01e6d7c67020d2e2e9ef139c80ccc1b5d Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 8 Sep 2023 23:17:18 +0800 Subject: [PATCH 13/16] change dep --- hessian.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hessian.spec b/hessian.spec index 56fa963..41c5238 100644 --- a/hessian.spec +++ b/hessian.spec @@ -33,7 +33,7 @@ rm -r src/com/caucho/hessian/test cp -p %{SOURCE1} pom.xml cp -p %{SOURCE2} apache.license.html %pom_change_dep :servlet-api javax.servlet:javax.servlet-api:3.1.0 -%pom_change_dep :org.springframework:org.springframework.web:3.0.5.Release +%pom_change_dep :org.springframework.web org.springframework:org.springframework.web:3.0.5.Release %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin -- Gitee From 80502e62fe86ed7001aa953e870d99c094a0a95d Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 8 Sep 2023 23:43:31 +0800 Subject: [PATCH 14/16] change dep --- hessian-4.0.65.pom | 2 +- hessian.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hessian-4.0.65.pom b/hessian-4.0.65.pom index f9a89d7..c449504 100644 --- a/hessian-4.0.65.pom +++ b/hessian-4.0.65.pom @@ -40,7 +40,7 @@ org.springframework - org.springframework.web + spring-web 3.0.5.Release diff --git a/hessian.spec b/hessian.spec index 41c5238..e55a110 100644 --- a/hessian.spec +++ b/hessian.spec @@ -33,7 +33,7 @@ rm -r src/com/caucho/hessian/test cp -p %{SOURCE1} pom.xml cp -p %{SOURCE2} apache.license.html %pom_change_dep :servlet-api javax.servlet:javax.servlet-api:3.1.0 -%pom_change_dep :org.springframework.web org.springframework:org.springframework.web:3.0.5.Release +%pom_change_dep :spring-web org.springframework:spring-web:3.0.5.Release %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin -- Gitee From ecc0699a46845162bd87d3f03f43f5d8f19f9ed1 Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Fri, 8 Sep 2023 23:55:49 +0800 Subject: [PATCH 15/16] change dep --- hessian-4.0.65.pom | 6 +++--- hessian.spec | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hessian-4.0.65.pom b/hessian-4.0.65.pom index c449504..be50266 100644 --- a/hessian-4.0.65.pom +++ b/hessian-4.0.65.pom @@ -39,9 +39,9 @@ provided - org.springframework - spring-web - 3.0.5.Release + org.springframework + spring-web + 3.0.5.RELEASE diff --git a/hessian.spec b/hessian.spec index e55a110..db9a3f5 100644 --- a/hessian.spec +++ b/hessian.spec @@ -33,7 +33,7 @@ rm -r src/com/caucho/hessian/test cp -p %{SOURCE1} pom.xml cp -p %{SOURCE2} apache.license.html %pom_change_dep :servlet-api javax.servlet:javax.servlet-api:3.1.0 -%pom_change_dep :spring-web org.springframework:spring-web:3.0.5.Release +%pom_change_dep :spring-web org.springframework:spring-web:3.0.5.RELEASE %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin -- Gitee From 8bdebd9ecd4b720460ee64f1cbb233ecae32a4be Mon Sep 17 00:00:00 2001 From: xiaohuang09 Date: Mon, 11 Sep 2023 14:39:31 +0800 Subject: [PATCH 16/16] change dep --- hessian-4.0.65.pom | 2 +- hessian.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hessian-4.0.65.pom b/hessian-4.0.65.pom index be50266..27ddb9b 100644 --- a/hessian-4.0.65.pom +++ b/hessian-4.0.65.pom @@ -41,7 +41,7 @@ org.springframework spring-web - 3.0.5.RELEASE + 3.2.18.RELEASE diff --git a/hessian.spec b/hessian.spec index db9a3f5..7f91544 100644 --- a/hessian.spec +++ b/hessian.spec @@ -9,7 +9,7 @@ Source0: http://caucho.com/download/%{name}-%{version}-src.jar Source1: https://repo1.maven.org/maven2/com/caucho/%{name}/%{version}/%{name}-%{version}.pom Source2: https://opensource.org/licenses/Apache-1.1#/Apache-1.1.html#/Apache-1.1 BuildRequires: maven-local mvn(javax.servlet:javax.servlet-api) -BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) +BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) mvn(org.org.springframework:spring-web) Patch1: %{name}-20230907.patch -- Gitee