Skip to content

Class cast exception when partition.field.format.path is not provided #10

Open
@joelvim

Description

@joelvim

final boolean formatPath = Boolean.parseBoolean((String) config.getOrDefault(PARTITION_FIELD_FORMAT_PATH_CONFIG, PARTITION_FIELD_FORMAT_PATH_DEFAULT));

It seems that it parses a String but the default value is a boolean, and it cannot cast it.

Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted (org.apache.kafka.connect.runtime.WorkerTask)
java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
	at com.canelmas.kafka.connect.FieldAndTimeBasedPartitioner.init(FieldAndTimeBasedPartitioner.java:50)
	at io.confluent.connect.storage.partitioner.TimeBasedPartitioner.configure(TimeBasedPartitioner.java:151)
	at io.confluent.connect.s3.S3SinkTask.newPartitioner(S3SinkTask.java:207)
	at io.confluent.connect.s3.S3SinkTask.start(S3SinkTask.java:117)
	at org.apache.kafka.connect.runtime.WorkerSinkTask.initializeAndStart(WorkerSinkTask.java:308)
	at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:196)
	at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:182)
	at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:231)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

To fix it, you could change the type of the default value to String so the default value and the parsed one would be a string.
Something like this should work (I didn't test it):

    public static final String PARTITION_FIELD_FORMAT_PATH_DEFAULT = Boolean.TRUE.toString();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions