-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IPROTO-273 Elements in collections are not properly limited
- Loading branch information
Showing
8 changed files
with
586 additions
and
195 deletions.
There are no files selected for viewing
462 changes: 297 additions & 165 deletions
462
core/src/main/java/org/infinispan/protostream/WrappedMessage.java
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,28 +1,28 @@ | ||
package org.infinispan.protostream.config.impl; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.infinispan.protostream.config.AnnotationConfiguration; | ||
import org.infinispan.protostream.config.Configuration; | ||
import org.infinispan.protostream.descriptors.AnnotationElement; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author [email protected] | ||
* @since 2.0 | ||
*/ | ||
public final class ConfigurationImpl implements Configuration { | ||
private final boolean logOutOfSequenceReads; | ||
private final boolean logOutOfSequenceWrites; | ||
private final boolean lenient; | ||
private final AnnotationsConfigImpl annotationsConfig; | ||
private final int maxNestedMessageDepth; | ||
private final boolean wrapCollectionElements; | ||
|
||
private ConfigurationImpl(BuilderImpl builder, Map<String, AnnotationConfigurationImpl> annotations) { | ||
this.logOutOfSequenceReads = builder.logOutOfSequenceReads; | ||
this.logOutOfSequenceWrites = builder.logOutOfSequenceWrites; | ||
this.lenient = builder.lenient; | ||
this.maxNestedMessageDepth = builder.maxNestedMessageDepth; | ||
this.wrapCollectionElements = builder.wrapCollectionElements; | ||
this.annotationsConfig = new AnnotationsConfigImpl(annotations, builder.logUndefinedAnnotations); | ||
} | ||
|
||
|
@@ -41,6 +41,11 @@ public int maxNestedMessageDepth() { | |
return maxNestedMessageDepth; | ||
} | ||
|
||
@Override | ||
public boolean wrapCollectionElements() { | ||
return wrapCollectionElements; | ||
} | ||
|
||
@Override | ||
public AnnotationsConfig annotationsConfig() { | ||
return annotationsConfig; | ||
|
@@ -85,10 +90,10 @@ public String toString() { | |
public static final class BuilderImpl implements Builder { | ||
private boolean logOutOfSequenceReads = true; | ||
private boolean logOutOfSequenceWrites = true; | ||
private boolean lenient = true; | ||
private int maxNestedMessageDepth = Configuration.DEFAULT_MAX_NESTED_DEPTH; | ||
private AnnotationsConfigBuilderImpl annotationsConfigBuilder = null; | ||
private Boolean logUndefinedAnnotations; | ||
private boolean wrapCollectionElements; | ||
|
||
final class AnnotationsConfigBuilderImpl implements AnnotationsConfig.Builder { | ||
|
||
|
@@ -138,7 +143,6 @@ public Builder setLogOutOfSequenceWrites(boolean logOutOfSequenceWrites) { | |
|
||
@Override | ||
public Builder setLenient(boolean lenient) { | ||
this.lenient = lenient; | ||
return this; | ||
} | ||
|
||
|
@@ -148,6 +152,12 @@ public Builder maxNestedMessageDepth(int maxNestedMessageDepth) { | |
return this; | ||
} | ||
|
||
@Override | ||
public Builder wrapCollectionElements(boolean wrapCollectionElements) { | ||
this.wrapCollectionElements = wrapCollectionElements; | ||
return this; | ||
} | ||
|
||
@Override | ||
public AnnotationsConfig.Builder annotationsConfig() { | ||
if (annotationsConfigBuilder == null) { | ||
|
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
60 changes: 60 additions & 0 deletions
60
types/src/test/java/org/infinispan/protostream/types/java/Book.java
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.infinispan.protostream.types.java; | ||
|
||
import org.infinispan.protostream.annotations.ProtoFactory; | ||
import org.infinispan.protostream.annotations.ProtoField; | ||
|
||
import java.util.Objects; | ||
|
||
public class Book implements Comparable<Book> { | ||
|
||
@ProtoField(number = 1) | ||
String title; | ||
|
||
@ProtoField(number = 2) | ||
String description; | ||
|
||
@ProtoField(number = 3, defaultValue = "2023") | ||
int publicationYear; | ||
|
||
@ProtoFactory | ||
public Book(String title, String description, int publicationYear) { | ||
this.title = title; | ||
this.description = description; | ||
this.publicationYear = publicationYear; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Book book = (Book) o; | ||
return publicationYear == book.publicationYear && Objects.equals(title, book.title) && Objects.equals(description, book.description); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(title, description, publicationYear); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Book{" + | ||
"title='" + title + '\'' + | ||
", description='" + description + '\'' + | ||
", publicationYear=" + publicationYear + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public int compareTo(Book o) { | ||
int cmp = Integer.compare(this.publicationYear, o.publicationYear); | ||
if (cmp != 0) { | ||
return cmp; | ||
} | ||
cmp = title.compareTo(o.title); | ||
if (cmp != 0) { | ||
return cmp; | ||
} | ||
return description.compareTo(o.description); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
types/src/test/java/org/infinispan/protostream/types/java/BookSchema.java
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.infinispan.protostream.types.java; | ||
|
||
import org.infinispan.protostream.GeneratedSchema; | ||
import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder; | ||
|
||
@AutoProtoSchemaBuilder( | ||
includeClasses = { | ||
Book.class | ||
}, | ||
schemaFileName = "book.proto", | ||
schemaFilePath = "proto/", | ||
schemaPackageName = "library") | ||
public interface BookSchema extends GeneratedSchema { | ||
} |
Oops, something went wrong.