-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
copyTransient is not global #375
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
|
||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this file header touched at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line no: 18, 19 and EOF was missing CRLF. IntelliJ inserted the line feed automatically. |
||
package com.esotericsoftware.kryo; | ||
|
||
import java.util.ArrayList; | ||
|
@@ -26,22 +26,19 @@ | |
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
|
||
import org.objenesis.strategy.StdInstantiatorStrategy; | ||
|
||
import com.esotericsoftware.kryo.io.Input; | ||
import com.esotericsoftware.kryo.io.Output; | ||
import com.esotericsoftware.kryo.serializers.CollectionSerializer; | ||
import com.esotericsoftware.kryo.serializers.CollectionSerializer.BindCollection; | ||
import com.esotericsoftware.kryo.serializers.DefaultArraySerializers.IntArraySerializer; | ||
import com.esotericsoftware.kryo.serializers.DefaultArraySerializers.LongArraySerializer; | ||
import com.esotericsoftware.kryo.serializers.DefaultArraySerializers.ObjectArraySerializer; | ||
import com.esotericsoftware.kryo.serializers.DefaultSerializers.StringSerializer; | ||
import com.esotericsoftware.kryo.serializers.FieldSerializer; | ||
import com.esotericsoftware.kryo.serializers.FieldSerializer.Bind; | ||
import com.esotericsoftware.kryo.serializers.FieldSerializer.Optional; | ||
import com.esotericsoftware.kryo.serializers.MapSerializer; | ||
import com.esotericsoftware.kryo.serializers.CollectionSerializer; | ||
import com.esotericsoftware.kryo.serializers.MapSerializer.BindMap; | ||
|
||
/** @author Nathan Sweet <misc@n4te.com> */ | ||
|
@@ -462,7 +459,26 @@ public void testTransients () { | |
HasTransients objectWithTransients2 = kryo.copy(objectWithTransients1); | ||
assertEquals("Objects should be equal if copy includes transient fields", objectWithTransients2, objectWithTransients1); | ||
} | ||
|
||
|
||
public void testTransientsUsingGlobalConfig () { | ||
kryo.setCopyTransient(false); | ||
kryo.register(HasTransients.class); | ||
HasTransients objectWithTransients1 = new HasTransients(); | ||
objectWithTransients1.transientField1 = "Test"; | ||
objectWithTransients1.anotherField2 = 5; | ||
objectWithTransients1.anotherField3 = "Field2"; | ||
|
||
FieldSerializer<HasTransients> ser = (FieldSerializer<HasTransients>)kryo.getSerializer(HasTransients.class); | ||
HasTransients objectWithTransients3 = kryo.copy(objectWithTransients1); | ||
assertTrue("Objects should be different if copy does not include transient fields", | ||
!objectWithTransients3.equals(objectWithTransients1)); | ||
assertEquals("transient fields should be null", objectWithTransients3.transientField1, null); | ||
|
||
ser.setCopyTransient(true); | ||
HasTransients objectWithTransients2 = kryo.copy(objectWithTransients1); | ||
assertEquals("Objects should be equal if copy includes transient fields", objectWithTransients2, objectWithTransients1); | ||
} | ||
|
||
public void testCorrectlyAnnotatedFields () { | ||
kryo.register(int[].class); | ||
kryo.register(long[].class); | ||
|
@@ -1043,4 +1059,4 @@ public boolean equals(Object o) { | |
return true; | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem with indentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it in the latest commit.