Skip to content

Commit

Permalink
Fix UserConfigFunction example (apache#15240)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet authored May 30, 2022
1 parent 29308e4 commit b367b91
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.pulsar.functions.api.examples;

import java.util.Optional;
import org.apache.pulsar.functions.api.Context;
import org.apache.pulsar.functions.api.Function;

Expand All @@ -29,12 +28,7 @@ public class UserConfigFunction implements Function<String, String> {

@Override
public String process(String input, Context context) {
Optional<Object> whatToWrite = context.getUserConfigValue("WhatToWrite");
if (whatToWrite.get() != null) {
return (String) whatToWrite.get();
} else {
return "Not a nice way";
}
return (String) context.getUserConfigValue("WhatToWrite").orElse("Not a nice way");
}
}

0 comments on commit b367b91

Please sign in to comment.