Ignore:
Timestamp:
07/09/15 13:50:59 (9 years ago)
Author:
sherbold
Message:
  • fixed bug in the serialization of SimpleSOAPEventType. It is a workaround around a JDK bug ... who would have thought that HashMaps? have a serialization bug?!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java

    r1993 r1994  
    1717import java.io.ByteArrayInputStream; 
    1818import java.io.IOException; 
     19import java.io.InvalidObjectException; 
     20import java.io.ObjectInputStream; 
     21import java.io.ObjectOutputStream; 
    1922 
    2023import javax.xml.parsers.DocumentBuilderFactory; 
     
    9194     * reference to the {@link EqualSOAPDataMap} associated with the sequence this event belongs to. 
    9295     */ 
    93     private final EqualSOAPDataMap equalBodyMap; 
    94  
    95     /** 
    96      * <p> 
    97      * Constructor. Creates a new SimpleSOAPEventType. 
    98      * </p> 
    99      *  
    100      */ 
    101     public SimpleSOAPEventType(String calledMethod, 
    102                                String serviceName, 
    103                                String clientName, 
    104                                Element soapMsgBody) 
    105     { 
    106         this(calledMethod, serviceName, clientName, soapMsgBody, null, CallType.REQUEST); 
    107     } 
    108  
    109     /** 
    110      * <p> 
    111      * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 
    112      * </p> 
    113      *  
    114      */ 
    115     public SimpleSOAPEventType(String calledMethod, 
    116                                String serviceName, 
    117                                String clientName, 
    118                                Element soapMsgBody, 
    119                                EqualSOAPDataMap equalRequestsMap) 
    120     { 
    121         this(calledMethod, serviceName, clientName, soapMsgBody, equalRequestsMap, 
    122              CallType.REQUEST); 
    123     } 
    124  
    125     /** 
    126      * <p> 
    127      * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 
     96    private transient EqualSOAPDataMap equalBodyMap; 
     97 
     98    /** 
     99     * <p> 
     100     * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. Should always call 
     101     * initEqualBodyMap afterwards. 
    128102     * </p> 
    129103     *  
     
    151125        this.soapMsgBody = SOAPUtils.getSerialization(soapMsgBody); 
    152126        this.callType = callType; 
    153  
    154         // this must be the last part of the constructor and only be called after all variables are 
    155         // initialized 
    156         if (equalRequestsMap != null) { 
    157             equalRequestsMap.add(this, this.soapMsgBody); 
     127         
     128        if (equalBodyMap != null) { 
     129            equalBodyMap.add(this, this.soapMsgBody); 
    158130        } 
    159131    } 
     
    256228        } 
    257229        else if (obj instanceof SimpleSOAPEventType) { 
    258             return callType.equals(((SimpleSOAPEventType) obj).callType) && 
     230            boolean callTypesEqual = true; 
     231            if (callType == null) { 
     232                if (((SimpleSOAPEventType) obj).callType == null) { 
     233                    callTypesEqual = true; 
     234                } 
     235                else { 
     236                    callTypesEqual = false; 
     237                } 
     238            } 
     239            else { 
     240                callTypesEqual = callType.equals(((SimpleSOAPEventType) obj).callType); 
     241            } 
     242            return callTypesEqual && 
    259243                HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) && 
    260244                HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName) && 
     
    273257    @Override 
    274258    public int hashCode() { 
    275         return callType.hashCode() + calledMethod.hashCode() + serviceName.hashCode() + 
    276             clientName.hashCode(); 
     259        int hashCode = 13; 
     260        if (callType != null) { 
     261            hashCode += callType.hashCode(); 
     262        } 
     263        if (calledMethod == null || serviceName == null || clientName == null) { 
     264            System.out.print("fu!"); 
     265        } 
     266        return hashCode + calledMethod.hashCode() + serviceName.hashCode() + clientName.hashCode(); 
    277267    } 
    278268 
     
    296286        } 
    297287    } 
     288     
     289    private void writeObject(ObjectOutputStream out) throws IOException { 
     290        out.defaultWriteObject(); 
     291        out.writeObject(equalBodyMap); 
     292    } 
     293 
     294    private void readObject(ObjectInputStream in) 
     295        throws ClassNotFoundException, IOException 
     296    { 
     297        in.defaultReadObject(); 
     298        equalBodyMap = (EqualSOAPDataMap) in.readObject(); 
     299        if ( equalBodyMap == null) { 
     300            throw new InvalidObjectException("null"); 
     301        } 
     302    } 
    298303} 
Note: See TracChangeset for help on using the changeset viewer.