Allow null Protostream fields
Closes #30761 Co-authored-by: Pedro Ruivo <pruivo@redhat.com> Signed-off-by: Ryan Emerson <remerson@redhat.com>
This commit is contained in:
parent
bbe05e729f
commit
bf26d3364c
16 changed files with 40 additions and 40 deletions
|
@ -66,21 +66,6 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.infinispan.protostream</groupId>
|
|
||||||
<artifactId>protostream</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.infinispan.protostream</groupId>
|
|
||||||
<artifactId>protostream-types</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.infinispan.protostream</groupId>
|
|
||||||
<artifactId>protostream-processor</artifactId>
|
|
||||||
<!-- compile-only dependency -->
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -98,7 +83,7 @@
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.infinispan.maven-plugins</groupId>
|
<groupId>org.infinispan.protostream</groupId>
|
||||||
<artifactId>proto-schema-compatibility-maven-plugin</artifactId>
|
<artifactId>proto-schema-compatibility-maven-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class WrapperClusterEvent implements ClusterEvent {
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static WrapperClusterEvent protoFactory(String eventKey, String senderAddress, String senderSite, SiteFilter siteFilter, List<WrappedMessage> eventPS) {
|
static WrapperClusterEvent protoFactory(String eventKey, String senderAddress, String senderSite, SiteFilter siteFilter, List<WrappedMessage> eventPS) {
|
||||||
var events = eventPS.stream().map(WrappedMessage::getValue).map(ClusterEvent.class::cast).toList();
|
var events = eventPS.stream().map(WrappedMessage::getValue).map(ClusterEvent.class::cast).toList();
|
||||||
return new WrapperClusterEvent(eventKey, Marshalling.emptyStringToNull(senderAddress), Marshalling.emptyStringToNull(senderSite), siteFilter, events);
|
return new WrapperClusterEvent(eventKey, senderAddress, senderSite, siteFilter, events);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WrapperClusterEvent wrap(String eventKey, Collection<? extends ClusterEvent> events, String senderAddress, String senderSite, ClusterProvider.DCNotify dcNotify, boolean ignoreSender) {
|
public static WrapperClusterEvent wrap(String eventKey, Collection<? extends ClusterEvent> events, String senderAddress, String senderSite, ClusterProvider.DCNotify dcNotify, boolean ignoreSender) {
|
||||||
|
|
|
@ -94,6 +94,7 @@ import org.keycloak.storage.managers.UserStorageSyncManager;
|
||||||
syntax = ProtoSyntax.PROTO3,
|
syntax = ProtoSyntax.PROTO3,
|
||||||
schemaPackageName = "keycloak",
|
schemaPackageName = "keycloak",
|
||||||
schemaFilePath = "proto/generated",
|
schemaFilePath = "proto/generated",
|
||||||
|
allowNullFields = true,
|
||||||
|
|
||||||
// common-types for UUID
|
// common-types for UUID
|
||||||
dependsOn = CommonTypes.class,
|
dependsOn = CommonTypes.class,
|
||||||
|
|
|
@ -155,9 +155,4 @@ public final class Marshalling {
|
||||||
public static void configure(ConfigurationBuilder builder) {
|
public static void configure(ConfigurationBuilder builder) {
|
||||||
builder.addContextInitializer(KeycloakModelSchema.INSTANCE);
|
builder.addContextInitializer(KeycloakModelSchema.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String emptyStringToNull(String value) {
|
|
||||||
return value == null || value.isEmpty() ? null : value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ResourceRemovedEvent extends BaseResourceEvent {
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static ResourceRemovedEvent protoFactory(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
static ResourceRemovedEvent protoFactory(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
||||||
return new ResourceRemovedEvent(id, name, owner, serverId, Marshalling.emptyStringToNull(type), uris, scopes);
|
return new ResourceRemovedEvent(id, name, owner, serverId, type, uris, scopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceRemovedEvent(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
private ResourceRemovedEvent(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ResourceUpdatedEvent extends BaseResourceEvent {
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static ResourceUpdatedEvent protoFactory(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
static ResourceUpdatedEvent protoFactory(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
||||||
return new ResourceUpdatedEvent(id, name, owner, serverId, Marshalling.emptyStringToNull(type), uris, scopes);
|
return new ResourceUpdatedEvent(id, name, owner, serverId, type, uris, scopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceUpdatedEvent(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
private ResourceUpdatedEvent(String id, String name, String owner, String serverId, String type, Set<String> uris, Set<String> scopes) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class GroupAddedEvent extends InvalidationEvent implements RealmCacheInva
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static GroupAddedEvent protoFactory(String id, String realmId, String parentId) {
|
static GroupAddedEvent protoFactory(String id, String realmId, String parentId) {
|
||||||
return new GroupAddedEvent(id, realmId, Marshalling.emptyStringToNull(parentId));
|
return new GroupAddedEvent(id, realmId, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GroupAddedEvent create(String groupId, String parentId, String realmId) {
|
public static GroupAddedEvent create(String groupId, String parentId, String realmId) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class GroupMovedEvent extends InvalidationEvent implements RealmCacheInva
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static GroupMovedEvent protoFactory(String id, String newParentId, String oldParentId, String realmId) {
|
static GroupMovedEvent protoFactory(String id, String newParentId, String oldParentId, String realmId) {
|
||||||
return new GroupMovedEvent(id, Marshalling.emptyStringToNull(newParentId), Marshalling.emptyStringToNull(oldParentId), realmId);
|
return new GroupMovedEvent(id, newParentId, oldParentId, realmId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GroupMovedEvent create(GroupModel group, GroupModel toParent, String realmId) {
|
public static GroupMovedEvent create(GroupModel group, GroupModel toParent, String realmId) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class GroupRemovedEvent extends InvalidationEvent implements RealmCacheIn
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static GroupRemovedEvent protoFactory(String id, String realmId, String parentId) {
|
static GroupRemovedEvent protoFactory(String id, String realmId, String parentId) {
|
||||||
return new GroupRemovedEvent(id, realmId, Marshalling.emptyStringToNull(parentId));
|
return new GroupRemovedEvent(id, realmId, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GroupRemovedEvent create(GroupModel group, String realmId) {
|
public static GroupRemovedEvent create(GroupModel group, String realmId) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class UserFederationLinkRemovedEvent extends InvalidationEvent implements
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static UserFederationLinkRemovedEvent protoFactory(String id, String realmId, String identityProviderId, String socialUserId) {
|
static UserFederationLinkRemovedEvent protoFactory(String id, String realmId, String identityProviderId, String socialUserId) {
|
||||||
return new UserFederationLinkRemovedEvent(id, realmId, Marshalling.emptyStringToNull(identityProviderId), Marshalling.emptyStringToNull(socialUserId));
|
return new UserFederationLinkRemovedEvent(id, realmId, identityProviderId, socialUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ProtoField(2)
|
@ProtoField(2)
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class UserFullInvalidationEvent extends InvalidationEvent implements User
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static UserFullInvalidationEvent protoFactory(String id, String username, String email, String realmId, boolean identityFederationEnabled, Map<String, String> federatedIdentities) {
|
static UserFullInvalidationEvent protoFactory(String id, String username, String email, String realmId, boolean identityFederationEnabled, Map<String, String> federatedIdentities) {
|
||||||
return new UserFullInvalidationEvent(id, username, Marshalling.emptyStringToNull(email), realmId, identityFederationEnabled, federatedIdentities);
|
return new UserFullInvalidationEvent(id, username, email, realmId, identityFederationEnabled, federatedIdentities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getFederatedIdentities() {
|
public Map<String, String> getFederatedIdentities() {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class UserUpdatedEvent extends InvalidationEvent implements UserCacheInva
|
||||||
|
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static UserUpdatedEvent protoFactory(String id, String username, String email, String realmId) {
|
static UserUpdatedEvent protoFactory(String id, String username, String email, String realmId) {
|
||||||
return new UserUpdatedEvent(id, username, Marshalling.emptyStringToNull(email), realmId);
|
return new UserUpdatedEvent(id, username, email, realmId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -156,9 +156,9 @@ public class AuthenticatedClientSessionEntity extends SessionEntity {
|
||||||
AuthenticatedClientSessionEntity(String realmId, String authMethod, String redirectUri, int timestamp, String action, Map<String, String> notes, UUID id) {
|
AuthenticatedClientSessionEntity(String realmId, String authMethod, String redirectUri, int timestamp, String action, Map<String, String> notes, UUID id) {
|
||||||
super(realmId);
|
super(realmId);
|
||||||
this.authMethod = authMethod;
|
this.authMethod = authMethod;
|
||||||
this.redirectUri = Marshalling.emptyStringToNull(redirectUri);
|
this.redirectUri = redirectUri;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.action = Marshalling.emptyStringToNull(action);
|
this.action = action;
|
||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class LoginFailureEntity extends SessionEntity {
|
||||||
this.numFailures = numFailures;
|
this.numFailures = numFailures;
|
||||||
this.numTemporaryLockouts = numTemporaryLockouts;
|
this.numTemporaryLockouts = numTemporaryLockouts;
|
||||||
this.lastFailure = lastFailure;
|
this.lastFailure = lastFailure;
|
||||||
this.lastIPFailure = Marshalling.emptyStringToNull(lastIPFailure);
|
this.lastIPFailure = lastIPFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ProtoField(2)
|
@ProtoField(2)
|
||||||
|
|
|
@ -118,10 +118,10 @@ public class UserSessionPredicate implements Predicate<Map.Entry<String, Session
|
||||||
@ProtoFactory
|
@ProtoFactory
|
||||||
static UserSessionPredicate create(String userId, String brokerSessionId, String brokerUserId, String realm, String client) {
|
static UserSessionPredicate create(String userId, String brokerSessionId, String brokerUserId, String realm, String client) {
|
||||||
return create(realm)
|
return create(realm)
|
||||||
.user(Marshalling.emptyStringToNull(userId))
|
.user(userId)
|
||||||
.client(Marshalling.emptyStringToNull(client))
|
.client(client)
|
||||||
.brokerSessionId(Marshalling.emptyStringToNull(brokerSessionId))
|
.brokerSessionId(brokerSessionId)
|
||||||
.brokerUserId(Marshalling.emptyStringToNull(brokerUserId));
|
.brokerUserId(brokerUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
25
pom.xml
25
pom.xml
|
@ -100,6 +100,7 @@
|
||||||
<hibernate-orm.plugin.version>6.2.13.Final</hibernate-orm.plugin.version>
|
<hibernate-orm.plugin.version>6.2.13.Final</hibernate-orm.plugin.version>
|
||||||
<hibernate.c3p0.version>6.2.13.Final</hibernate.c3p0.version>
|
<hibernate.c3p0.version>6.2.13.Final</hibernate.c3p0.version>
|
||||||
<infinispan.version>15.0.5.Final</infinispan.version>
|
<infinispan.version>15.0.5.Final</infinispan.version>
|
||||||
|
<protostream.version>5.0.7.Final</protostream.version>
|
||||||
|
|
||||||
<!--JAKARTA-->
|
<!--JAKARTA-->
|
||||||
<jakarta.mail.version>2.1.1</jakarta.mail.version>
|
<jakarta.mail.version>2.1.1</jakarta.mail.version>
|
||||||
|
@ -199,7 +200,6 @@
|
||||||
<smallrye.openapi.generator.plugin.version>3.6.2</smallrye.openapi.generator.plugin.version>
|
<smallrye.openapi.generator.plugin.version>3.6.2</smallrye.openapi.generator.plugin.version>
|
||||||
<openapi.generator.plugin.version>6.3.0</openapi.generator.plugin.version>
|
<openapi.generator.plugin.version>6.3.0</openapi.generator.plugin.version>
|
||||||
<build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>
|
<build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>
|
||||||
<infinispan.maven-plugins.version>1.0.5.Final</infinispan.maven-plugins.version>
|
|
||||||
|
|
||||||
<!-- Surefire Settings -->
|
<!-- Surefire Settings -->
|
||||||
<surefire.memory.Xms>512m</surefire.memory.Xms>
|
<surefire.memory.Xms>512m</surefire.memory.Xms>
|
||||||
|
@ -1439,6 +1439,25 @@
|
||||||
<artifactId>rdf-urdna</artifactId>
|
<artifactId>rdf-urdna</artifactId>
|
||||||
<version>${io.setl.rdf-urdna.version}</version>
|
<version>${io.setl.rdf-urdna.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.infinispan.protostream</groupId>
|
||||||
|
<artifactId>protostream</artifactId>
|
||||||
|
<version>${protostream.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.infinispan.protostream</groupId>
|
||||||
|
<artifactId>protostream-types</artifactId>
|
||||||
|
<version>${protostream.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.infinispan.protostream</groupId>
|
||||||
|
<artifactId>protostream-processor</artifactId>
|
||||||
|
<version>${protostream.version}</version>
|
||||||
|
<!-- compile-only dependency -->
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -1695,9 +1714,9 @@
|
||||||
<version>${build-helper-maven-plugin.version}</version>
|
<version>${build-helper-maven-plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.infinispan.maven-plugins</groupId>
|
<groupId>org.infinispan.protostream</groupId>
|
||||||
<artifactId>proto-schema-compatibility-maven-plugin</artifactId>
|
<artifactId>proto-schema-compatibility-maven-plugin</artifactId>
|
||||||
<version>${infinispan.maven-plugins.version}</version>
|
<version>${protostream.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<commitProtoLock>${commitProtoLockChanges}</commitProtoLock>
|
<commitProtoLock>${commitProtoLockChanges}</commitProtoLock>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in a new issue