Skip to content

Caused by: org.infinispan.protostream.DescriptorParserException: IPROTO000013: Error while parsing 'SimpleEntitySchema.proto': Error: 2,1: illegal character:  #383

@emelyanovkr

Description

@emelyanovkr

Hello,
I saw simillar issue #196 where it was fixed, however, there is a simillar issue, where other symbols aren't covered with provided solution in #196.

Used Kotlin and JDK 17, and this dependencies:

    implementation("org.infinispan.protostream:protostream:5.0.12.Final")
    compileOnly("org.infinispan.protostream:protostream-processor:5.0.12.Final")
    kapt("org.infinispan.protostream:protostream-processor:5.0.12.Final")

For example.
SImpleEntity

import org.infinispan.protostream.annotations.ProtoField

data class SimpleEntity(
    @get:ProtoField(number = 1) var name: String? = null,
    @get:ProtoField(number = 2) var message: String? = null
)

SimpleEntitySchema

@ProtoSchema(includeClasses = [SimpleEntity::class], schemaPackageName = "proto")
interface SimpleEntitySchema : GeneratedSchema

Generated SimpleEntitySchemaImpl.java

public class SimpleEntitySchemaImpl implements proto.SimpleEntitySchema {

   private static final String PROTO_SCHEMA = """
// File name: SimpleEntitySchema.proto
// Generated from : SimpleEntitySchema.proto
syntax = "proto2";
package proto;



/**
 * @Metadata(mv={1, 9, 0}, k=1, xi=48, d1={"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000e\n\u0002\b\f\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\b\u0086\b\u0018\u00002\u00020\u0001B\u001d\u0012\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0003\u00a2\u0006\u0002\u0010\u0005J\u000b\u0010\f\u001a\u0004\u0018\u00010\u0003H\u00c6\u0003J\u000b\u0010\r\u001a\u0004\u0018\u00010\u0003H\u00c6\u0003J!\u0010\u000e\u001a\u00020\u00002\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u00032\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0003H\u00c6\u0001J\u0013\u0010\u000f\u001a\u00020\u00102\b\u0010\u0011\u001a\u0004\u0018\u00010\u0001H\u00d6\u0003J\t\u0010\u0012\u001a\u00020\u0013H\u00d6\u0001J\t\u0010\u0014\u001a\u00020\u0003H\u00d6\u0001R\u001e\u0010\u0004\u001a\u0004\u0018\u00010\u00038\u0007X\u0086\u000e\u00a2\u0006\u000e\n\u0000\u001a\u0004\b\u0006\u0010\u0007\"\u0004\b\b\u0010\tR\u001e\u0010\u0002\u001a\u0004\u0018\u00010\u00038\u0007X\u0086\u000e\u00a2\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u0007\"\u0004\b\u000b\u0010\t\u00a8\u0006\u0015"}, d2={"Lproto/SimpleEntity;", "", "name", "", "message", "(Ljava/lang/String;Ljava/lang/String;)V", "getMessage", "()Ljava/lang/String;", "setMessage", "(Ljava/lang/String;)V", "getName", "setName", "component1", "component2", "copy", "equals", "", "other", "hashCode", "", "toString", "api-quarkus"})
 */
message SimpleEntity {
   
   /**
    * @Nullable
    */
   optional string name = 1;
   
   /**
    * @Nullable
    */
   optional string message = 2;
}

""";

   @Override
public String getProtoFileName() { return "SimpleEntitySchema.proto"; }

   @Override
public String getProtoFile() { return PROTO_SCHEMA; }

   @Override
   public void registerSchema(org.infinispan.protostream.SerializationContext serCtx) {
      serCtx.registerProtoFiles(org.infinispan.protostream.FileDescriptorSource.fromString(getProtoFileName(), getProtoFile()));
   }

   @Override
   public void registerMarshallers(org.infinispan.protostream.SerializationContext serCtx) {
      serCtx.registerMarshaller(new proto.SimpleEntity$___Marshaller_4f3e7dce92faed34c3d7bb610b4b830d4b6a80ba2cbe67131793b5b4936fce4a());
   }
}

I am using Embedded Infinispan cache with Quarkus, if it does matter.

@ApplicationScoped
class EmbeddedCache {

    private val cacheManager = DefaultCacheManager(
        GlobalConfigurationBuilder().clusteredDefault().serialization().addContextInitializer(
            SimpleEntitySchemaImpl()
        ).build()
    ).apply {
        defineConfiguration(
            "embedded-cache", ConfigurationBuilder().encoding().mediaType(MediaType.APPLICATION_PROTOSTREAM).build()
        )
    }

    private val keyCounter = AtomicLong(1)

    private val cache: Cache<Long, SimpleEntity> = cacheManager.getCache("embedded-cache")

    fun put(entity: SimpleEntity): String {
        val generatedKey = keyCounter.getAndIncrement()
        cache.put(generatedKey, entity)
        return "Successfully created new entity: $generatedKey | ${entity.name}"
    }

    fun get(key: Long): SimpleEntity? = cache[key]

    fun getAllEntities(): Map<Long, SimpleEntity> = cache

    fun updateEntity(key: Long, entity: SimpleEntity): String {
        if (cache[key] != null) {
            cache.put(key, entity)
            return "Successfully updated entity: $key | ${entity.name}"
        }
        return "No entity with this id: $key"
    }

    fun remove(key: Long): String {
        if (cache[key] != null) {
            cache.remove(key)
            return "Successfully removed entity: $key"
        }
        return "No entity with this id: $key"
    }

    @PreDestroy
    fun destroy() {
        cacheManager.stop()
    }
}

Exception StackTrace

Caused by: org.infinispan.protostream.DescriptorParserException: IPROTO000013: Error while parsing 'SimpleEntitySchema.proto': Error: 2,1: illegal character: �
	at org.infinispan.protostream.impl.parser.ProtostreamProtoParser.parse(ProtostreamProtoParser.java:53)
	at org.infinispan.protostream.impl.SerializationContextImpl.registerProtoFiles(SerializationContextImpl.java:105)

If i remove d1 values from Metadata annotation or write SimpleEntity and SimpleEntitySchema in Java, everything works fine, as it should.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions