Skip to content

Serialization exception occurs when tests are generated for custom exception #2207

Closed
@EgorkaKulikov

Description

@EgorkaKulikov

Description

This problem has already tried to been fixed: look at IgnoringUidWrappingObjectInputStream class.

To Reproduce

Try to generate tests for method

    public void throwCustom() throws CustomException {
        throw new CustomException();
    }

where CustomException is

public class CustomException extends Exception {}

Actual behavior

The following error method is shown

public void testThrowCustom_errors() {
        // Couldn't generate some tests. List of errors:
        // 
        // 4715 occurrences of:
        // Default concrete execution failed

    }

There is an exception in rdEngineProcessLog showing that there is a problem in serialization:

Caused by: java.io.InvalidClassException: org.example.CustomException; local class incompatible: stream classdesc serialVersionUID = -3653684951218128165, local class serialVersionUID = -978775293481840198
	at java.base/java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:689)
	at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2014)
	at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1864)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2195)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1681)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:493)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:451)
	at org.utbot.instrumentation.util.JavaSerializerWrapper.read(JavaSerializerWrapper.kt:23)

Additional context

Current fix is taken from https://stackoverflow.com/a/1816711, but it does not work in our case.

Metadata

Metadata

Labels

comp-instrumented-processIssue is related to Instrumented processcomp-springIssue is related to Spring projects supportctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions