[pigeon] Adds missing @NonNull annotations to some methods. (#2630)

diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md
index 6f7531c..583a625 100644
--- a/packages/pigeon/CHANGELOG.md
+++ b/packages/pigeon/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 4.1.1
+
+* [java] Adds missing `@NonNull` annotations to some methods.
+
 ## 4.1.0
 
 * Adds documentation comment support for all currently supported languages.
diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart
index 0e6e659..53a0aac 100644
--- a/packages/pigeon/lib/generator_tools.dart
+++ b/packages/pigeon/lib/generator_tools.dart
@@ -9,7 +9,7 @@
 import 'ast.dart';
 
 /// The current version of pigeon. This must match the version in pubspec.yaml.
-const String pigeonVersion = '4.1.0';
+const String pigeonVersion = '4.1.1';
 
 /// Read all the content from [stdin] to a String.
 String readStdin() {
diff --git a/packages/pigeon/lib/java_generator.dart b/packages/pigeon/lib/java_generator.dart
index f820036..d0f65bd 100644
--- a/packages/pigeon/lib/java_generator.dart
+++ b/packages/pigeon/lib/java_generator.dart
@@ -102,7 +102,7 @@
     if (getCodecClasses(api, root).isNotEmpty) {
       indent.writeln('@Override');
       indent.write(
-          'protected Object readValueOfType(byte type, ByteBuffer buffer) ');
+          'protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) ');
       indent.scoped('{', '}', () {
         indent.write('switch (type) ');
         indent.scoped('{', '}', () {
@@ -122,7 +122,7 @@
       });
       indent.writeln('@Override');
       indent.write(
-          'protected void writeValue(ByteArrayOutputStream stream, Object value) ');
+          'protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) ');
       indent.writeScoped('{', '}', () {
         for (final EnumeratedClass customClass in getCodecClasses(api, root)) {
           indent.write('if (value instanceof ${customClass.name}) ');
@@ -721,7 +721,7 @@
 
   void writeWrapError() {
     indent.format('''
-private static Map<String, Object> wrapError(Throwable exception) {
+@NonNull private static Map<String, Object> wrapError(@NonNull Throwable exception) {
 \tMap<String, Object> errorMap = new HashMap<>();
 \terrorMap.put("${Keys.errorMessage}", exception.toString());
 \terrorMap.put("${Keys.errorCode}", exception.getClass().getSimpleName());
diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml
index 72f260d..3dcef2b 100644
--- a/packages/pigeon/pubspec.yaml
+++ b/packages/pigeon/pubspec.yaml
@@ -2,7 +2,7 @@
 description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
 repository: https://github.com/flutter/packages/tree/main/packages/pigeon
 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
-version: 4.1.0 # This must match the version in lib/generator_tools.dart
+version: 4.1.1 # This must match the version in lib/generator_tools.dart
 
 environment:
   sdk: ">=2.12.0 <3.0.0"
diff --git a/packages/pigeon/test/java_generator_test.dart b/packages/pigeon/test/java_generator_test.dart
index da68603..7621eec 100644
--- a/packages/pigeon/test/java_generator_test.dart
+++ b/packages/pigeon/test/java_generator_test.dart
@@ -33,6 +33,10 @@
     expect(code, contains('public static class Foobar'));
     expect(code, contains('public static final class Builder'));
     expect(code, contains('private @Nullable Long field1;'));
+    expect(
+        code,
+        contains(
+            '@NonNull private static Map<String, Object> wrapError(@NonNull Throwable exception)'));
   });
 
   test('gen one enum', () {
@@ -130,6 +134,14 @@
     expect(code, contains('public interface Api'));
     expect(code, matches('Output.*doSomething.*Input'));
     expect(code, contains('channel.setMessageHandler(null)'));
+    expect(
+        code,
+        contains(
+            'protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer)'));
+    expect(
+        code,
+        contains(
+            'protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value)'));
   });
 
   test('all the simple datatypes header', () {