Skip to content

Commit 0a459d2

Browse files
authored
Make the example a bit more Groovy idiomatic (GoogleCloudPlatform#2953)
1 parent ecf8c33 commit 0a459d2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

functions/helloworld/groovy-hello-pubsub/src/main/groovy/functions/GroovyHelloPubSub.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.google.cloud.functions.BackgroundFunction
55
import com.google.cloud.functions.Context
66
import functions.eventpojos.PubSubMessage
77
import java.nio.charset.StandardCharsets
8-
import java.util.logging.Logger;
8+
import java.util.logging.Logger
99

1010
class GroovyHelloPubSub implements BackgroundFunction<PubSubMessage> {
1111
private static final Logger LOGGER = Logger.getLogger(GroovyHelloPubSub.class.name)
@@ -15,11 +15,11 @@ class GroovyHelloPubSub implements BackgroundFunction<PubSubMessage> {
1515
// name's default value is "world"
1616
String name = "world"
1717

18-
if (message?.data != null) {
19-
name = new String(Base64.getDecoder().decode(message.data), StandardCharsets.UTF_8)
18+
if (message?.data) {
19+
name = new String(Base64.decoder.decode(message.data), StandardCharsets.UTF_8)
2020
}
2121

22-
LOGGER.info(String.format("Hello %s!", name))
22+
LOGGER.info("Hello ${name}!")
2323
return
2424
}
2525
}

0 commit comments

Comments
 (0)