This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 29bace451de4 CAMEL-27973: camel-google-drive: unknown proxy host only 
logged, later calls fail with NullPointerException (#31281)
29bace451de4 is described below

commit 29bace451de4ec8b35028357d680d7136635e153
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Dec 2 21:36:21 2026 +0100

    CAMEL-27973: camel-google-drive: unknown proxy host only logged, later 
calls fail with NullPointerException (#31281)
    
    The BatchGoogleDriveClientFactory(String proxyHost, int proxyPort) 
constructor
    caught UnknownHostException, logged it (with a typo: 'Unknow proxy host'), 
and
    returned normally. This left transport and jsonFactory null. Any subsequent 
call
    to makeClient() reached Drive.Builder(transport, jsonFactory, credential) 
which
    calls Preconditions.checkNotNull(transport) and threw a NullPointerException
    with no hint about the actual cause.
    
    Replace the catch block with an IllegalArgumentException that fails fast at
    construction time with a clear message including the bad hostname. Remove 
the
    now-unused LOG field and its imports.
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
 .../drive/BatchGoogleDriveClientFactory.java       |  5 +---
 .../drive/BatchGoogleDriveClientFactoryTest.java   | 34 ++++++++++++++++++++++
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-google/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/BatchGoogleDriveClientFactory.java
 
b/components/camel-google/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/BatchGoogleDriveClientFactory.java
index c7126a7d4541..57c69fbb97a7 100644
--- 
a/components/camel-google/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/BatchGoogleDriveClientFactory.java
+++ 
b/components/camel-google/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/BatchGoogleDriveClientFactory.java
@@ -29,11 +29,8 @@ import com.google.api.services.drive.Drive;
 import org.apache.camel.CamelContext;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.google.common.GoogleCredentialsHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class BatchGoogleDriveClientFactory implements GoogleDriveClientFactory 
{
-    private static final Logger LOG = 
LoggerFactory.getLogger(BatchGoogleDriveClientFactory.class);
     private NetHttpTransport transport;
     private JacksonFactory jsonFactory;
 
@@ -50,7 +47,7 @@ public class BatchGoogleDriveClientFactory implements 
GoogleDriveClientFactory {
             this.transport = new 
NetHttpTransport.Builder().setProxy(proxy).build();
             this.jsonFactory = new JacksonFactory();
         } catch (UnknownHostException e) {
-            LOG.error("Unknow proxy host", e);
+            throw new IllegalArgumentException("Unknown proxy host: " + 
proxyHost, e);
         }
     }
 
diff --git 
a/components/camel-google/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/BatchGoogleDriveClientFactoryTest.java
 
b/components/camel-google/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/BatchGoogleDriveClientFactoryTest.java
new file mode 100644
index 000000000000..38666fae1b7f
--- /dev/null
+++ 
b/components/camel-google/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/BatchGoogleDriveClientFactoryTest.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.drive;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class BatchGoogleDriveClientFactoryTest {
+
+    @Test
+    void unknownProxyHostThrowsIllegalArgumentException() {
+        IllegalArgumentException ex = assertThrows(
+                IllegalArgumentException.class,
+                () -> new 
BatchGoogleDriveClientFactory("this.host.does.not.exist.invalid", 3128));
+        
assertTrue(ex.getMessage().contains("this.host.does.not.exist.invalid"),
+                "Exception message should contain the bad hostname");
+    }
+}

Reply via email to