Repository: googleapis/google-http-java-client
Pull request #1816 (2023-02-11 13:12:06)

deps: update project.appengine.version to v2.0.12
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.appengine:appengine-api-stubs](https://togithub.com/GoogleCloudPlatform/appengine-java-standard) | `2.0.10` -> `2.0.12` | [![age](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-stubs/2.0.12/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-stubs/2.0.12/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-stubs/2.0.12/compatibility-slim/2.0.10)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-stubs/2.0.12/confidence-slim/2.0.10)](https://docs.renovatebot.com/merge-confidence/) |
| [com.google.appengine:appengine-testing](https://togithub.com/GoogleCloudPlatform/appengine-java-standard) | `2.0.10` -> `2.0.12` | [![age](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-testing/2.0.12/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-testing/2.0.12/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-testing/2.0.12/compatibility-slim/2.0.10)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-testing/2.0.12/confidence-slim/2.0.10)](https://docs.renovatebot.com/merge-confidence/) |
| [com.google.appengine:appengine-api-1.0-sdk](https://togithub.com/GoogleCloudPlatform/appengine-java-standard) | `2.0.10` -> `2.0.12` | [![age](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.12/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.12/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.12/compatibility-slim/2.0.10)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.12/confidence-slim/2.0.10)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>GoogleCloudPlatform/appengine-java-standard</summary>

### [`v2.0.12`](https://togithub.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.11...v2.0.12)

[Compare Source](https://togithub.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.11...v2.0.12)

### [`v2.0.11`](https://togithub.com/GoogleCloudPlatform/appengine-java-standard/releases/tag/v2.0.11)

[Compare Source](https://togithub.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.10...v2.0.11)

Release version 2.0.11

**Full Changelog**: https://github.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.9...v2.0.11

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/google-http-java-client).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMTQuMCIsInVwZGF0ZWRJblZlciI6IjM0LjE1OS4xIn0=-->



Patch:
diff --git a/google-http-client/src/main/java/com/google/api/client/util/FieldInfo.java b/google-http-client/src/main/java/com/google/api/client/util/FieldInfo.java
index 3830a866..36d0dc9d 100644
--- a/google-http-client/src/main/java/com/google/api/client/util/FieldInfo.java
+++ b/google-http-client/src/main/java/com/google/api/client/util/FieldInfo.java
@@ -134,12 +134,20 @@ public class FieldInfo {
   }
 
   /** Creates list of setter methods for a field only in declaring class. */
-  private Method[] settersMethodForField(Field field) {
+  private Method[] settersMethodForField(final Field field) {
     List<Method> methods = new ArrayList<>();
+    String fieldSetter = "set" + Ascii.toUpperCase(field.getName().substring(0, 1));
+    if (field.getName().length() > 1) {
+      fieldSetter += field.getName().substring(1);
+    }
     for (Method method : field.getDeclaringClass().getDeclaredMethods()) {
-      if (Ascii.toLowerCase(method.getName()).equals("set" + Ascii.toLowerCase(field.getName()))
-          && method.getParameterTypes().length == 1) {
-        methods.add(method);
+      if (method.getParameterTypes().length == 1) {
+        // add case-sensitive matches first in the list
+        if (method.getName().equals(fieldSetter)) {
+          methods.add(0, method);
+        } else if (Ascii.toLowerCase(method.getName()).equals(Ascii.toLowerCase(fieldSetter))) {
+          methods.add(method);
+        }
       }
     }
     return methods.toArray(new Method[0]);
@@ -216,15 +224,13 @@ public class FieldInfo {
    * value.
    */
   public void setValue(Object obj, Object value) {
-    if (setters.length > 0) {
-      for (Method method : setters) {
-        if (value == null || method.getParameterTypes()[0].isAssignableFrom(value.getClass())) {
-          try {
-            method.invoke(obj, value);
-            return;
-          } catch (IllegalAccessException | InvocationTargetException e) {
-            // try to set field directly
-          }
+    for (Method method : setters) {
+      if (value == null || method.getParameterTypes()[0].isAssignableFrom(value.getClass())) {
+        try {
+          method.invoke(obj, value);
+          return;
+        } catch (IllegalAccessException | InvocationTargetException e) {
+          // try to set field directly
         }
       }
     }
diff --git a/pom.xml b/pom.xml
index 66e1a27d..fb17f6b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -569,7 +569,7 @@
       - Internally, update the default features.json file
     -->
     <project.http-client.version>1.43.1-SNAPSHOT</project.http-client.version><!-- {x-version-update:google-http-client-parent:current} -->
-    <project.appengine.version>2.0.10</project.appengine.version>
+    <project.appengine.version>2.0.12</project.appengine.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.jsr305.version>3.0.2</project.jsr305.version>
     <project.gson.version>2.10.1</project.gson.version>


Test patch:
diff --git a/google-http-client/src/test/java/com/google/api/client/util/FieldInfoTest.java b/google-http-client/src/test/java/com/google/api/client/util/FieldInfoTest.java
index c000a90d..0cd1c17d 100644
--- a/google-http-client/src/test/java/com/google/api/client/util/FieldInfoTest.java
+++ b/google-http-client/src/test/java/com/google/api/client/util/FieldInfoTest.java
@@ -14,6 +14,7 @@
 
 package com.google.api.client.util;
 
+import com.google.api.client.json.GenericJson;
 import junit.framework.TestCase;
 
 /**
@@ -49,4 +50,36 @@ public class FieldInfoTest extends TestCase {
     assertEquals(E.OTHER_VALUE, FieldInfo.of(E.OTHER_VALUE).<E>enumValue());
     assertEquals(E.NULL, FieldInfo.of(E.NULL).<E>enumValue());
   }
+
+  public static final class Data extends GenericJson {
+    @Key String passcode;
+    @Key String passCode;
+
+    public Data setPasscode(String passcode) {
+      this.passcode = passcode;
+      return this;
+    }
+
+    public Data setPassCode(String passCode) {
+      this.passCode = passCode;
+      return this;
+    }
+  }
+
+  public void testSetValueCaseSensitivityPriority() {
+    Data data = new Data();
+    data.setPasscode("pass1");
+    data.setPassCode("pass2");
+    data.set("passCode", "passX");
+
+    assertEquals(data.passcode, "pass1");
+    assertEquals(data.passCode, "passX");
+
+    data.setPasscode("pass1");
+    data.setPassCode("pass2");
+    data.set("passcode", "passX");
+
+    assertEquals(data.passcode, "passX");
+    assertEquals(data.passCode, "pass2");
+  }
 }