Repository: quarkusio/quarkus
Issue: NPE thrown when trying to connect to existing Keycloak devservice

### Describe the bug

We have a setup where we got multiple Quarkus apps working together. As such, when starting it locally in development mode, we rely on devservices provided by Quarkus and share the Keycloak instance. We do not really configure anything on the devservice except fixing the port and this was working fine before Quarkus 2.14.0.Final. After the update, we keep getting the following error:

> Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "java.util.List.isEmpty()" because "realmReps" is null
	at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startKeycloakContainer(KeycloakDevServicesProcessor.java:247)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:833)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.isEmpty()" because "realmReps" is null
	at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.prepareConfiguration(KeycloakDevServicesProcessor.java:262)
	at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.lambda$startContainer$5(KeycloakDevServicesProcessor.java:389)
	at java.base/java.util.Optional.map(Optional.java:260)
	at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startContainer(KeycloakDevServicesProcessor.java:387)
	at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startKeycloakContainer(KeycloakDevServicesProcessor.java:195)
	... 11 more

Looking at the code history we determined that the bug was introduced by the following PR: https://github.com/quarkusio/quarkus/pull/28327/files#diff-67404a43520250b1ebd5a0c945e070e60d70d4a3ba06b15e3fac747f820320cc in KeycloakDevServicesProcessor.java, line 259. 
Previously, there was a check if `realmRep` is `null` (which is always the case when dev service is shared - [check the call](https://github.com/quarkusio/quarkus/blob/c9e00898b30be0ed710087522da58b294bed6834/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java#L389)).

This is blocking us to update to new version and for now have reverted to the old one.

### Expected behavior

Multiple Quarkus apps should be able to share the same Keycloak instance in dev mode.

### Actual behavior

NPE occurs when existing Keycloak instance is detected.

### How to Reproduce?

Start two separate Quarkus Apps in dev mode that both make use of Keycloak devservice.

### Output of `uname -a` or `ver`

Linux-ubuntu 5.15.0-52-generic 

### Output of `java -version`

openjdk version "17.0.5" 2022-10-18

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.14.0.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Gradle 7.5.1

### Additional information

_No response_

Changed files:
extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java

diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java
index a37d73eb4be..c7c1674c8f2 100644
--- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java
+++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java
@@ -259,7 +259,8 @@ private Map<String, String> prepareConfiguration(
             BuildProducer<KeycloakDevServicesConfigBuildItem> keycloakBuildItemBuildProducer, String internalURL,
             String hostURL, List<RealmRepresentation> realmReps,
             boolean keycloakX, List<String> errors) {
-        final String realmName = !realmReps.isEmpty() ? realmReps.iterator().next().getRealm() : getDefaultRealmName();
+        final String realmName = realmReps != null && !realmReps.isEmpty() ? realmReps.iterator().next().getRealm()
+                : getDefaultRealmName();
         final String authServerInternalUrl = realmsURL(internalURL, realmName);
 
         String clientAuthServerBaseUrl = hostURL != null ? hostURL : internalURL;