diff --git a/hessian-20230907.patch b/hessian-20230907.patch new file mode 100644 index 0000000000000000000000000000000000000000..8be209802355327c9f777cd7544347bee976d241 --- /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-4.0.65.pom b/hessian-4.0.65.pom index 7d7d745394aacf1df4d9426d844be0f3f5116a2c..27ddb9bed43df465e43c2af393af3db56758b41a 100644 --- a/hessian-4.0.65.pom +++ b/hessian-4.0.65.pom @@ -37,6 +37,11 @@ servlet-api 2.5 provided + + + org.springframework + spring-web + 3.2.18.RELEASE diff --git a/hessian.spec b/hessian.spec index 8f9337204a50d252375f8756c17cf67185336d01..ff5e8f688f48aa1a9c0b4d6c58fb978b5905a81b 100644 --- a/hessian.spec +++ b/hessian.spec @@ -1,15 +1,18 @@ 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/ 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: maven-local mvn(javax.servlet:javax.servlet-api) mvn(org.springframework:spring-web) +BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) + +Patch1: %{name}-20230907.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 -c -p1 + mkdir src mv com src/ rm -r META-INF @@ -29,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 :spring-web org.springframework:spring-web:3.2.18.RELEASE %pom_remove_plugin :maven-gpg-plugin %pom_remove_plugin :maven-javadoc-plugin %pom_remove_plugin :maven-source-plugin @@ -69,6 +74,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