HHH-16549 - Fix potential NPE in LoadQueryInfluencers
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
f3d55de560
commit
527338d71a
|
@ -97,12 +97,7 @@ public class LoadQueryInfluencers implements Serializable {
|
||||||
* Set the effective {@linkplain #getEnabledCascadingFetchProfile() cascading fetch-profile}
|
* Set the effective {@linkplain #getEnabledCascadingFetchProfile() cascading fetch-profile}
|
||||||
*/
|
*/
|
||||||
public void setEnabledCascadingFetchProfile(CascadingFetchProfile enabledCascadingFetchProfile) {
|
public void setEnabledCascadingFetchProfile(CascadingFetchProfile enabledCascadingFetchProfile) {
|
||||||
if ( sessionFactory == null ) {
|
checkMutability();
|
||||||
// that's the signal that this is the immutable, context-less
|
|
||||||
// variety
|
|
||||||
throw new IllegalStateException( "Cannot modify context-less LoadQueryInfluencers" );
|
|
||||||
}
|
|
||||||
|
|
||||||
this.enabledCascadingFetchProfile = enabledCascadingFetchProfile;
|
this.enabledCascadingFetchProfile = enabledCascadingFetchProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +161,7 @@ public class LoadQueryInfluencers implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Filter enableFilter(String filterName) {
|
public Filter enableFilter(String filterName) {
|
||||||
|
checkMutability();
|
||||||
FilterImpl filter = new FilterImpl( sessionFactory.getFilterDefinition( filterName ) );
|
FilterImpl filter = new FilterImpl( sessionFactory.getFilterDefinition( filterName ) );
|
||||||
if ( enabledFilters == null ) {
|
if ( enabledFilters == null ) {
|
||||||
this.enabledFilters = new HashMap<>();
|
this.enabledFilters = new HashMap<>();
|
||||||
|
@ -216,7 +212,7 @@ public class LoadQueryInfluencers implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkFetchProfileName(String name) {
|
private void checkFetchProfileName(String name) {
|
||||||
if ( !sessionFactory.containsFetchProfileDefinition( name ) ) {
|
if ( sessionFactory != null && !sessionFactory.containsFetchProfileDefinition( name ) ) {
|
||||||
throw new UnknownProfileException( name );
|
throw new UnknownProfileException( name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,6 +223,7 @@ public class LoadQueryInfluencers implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableFetchProfile(String name) throws UnknownProfileException {
|
public void enableFetchProfile(String name) throws UnknownProfileException {
|
||||||
|
checkMutability();
|
||||||
checkFetchProfileName( name );
|
checkFetchProfileName( name );
|
||||||
if ( enabledFetchProfileNames == null ) {
|
if ( enabledFetchProfileNames == null ) {
|
||||||
this.enabledFetchProfileNames = new HashSet<>();
|
this.enabledFetchProfileNames = new HashSet<>();
|
||||||
|
@ -252,4 +249,12 @@ public class LoadQueryInfluencers implements Serializable {
|
||||||
public void setReadOnly(Boolean readOnly) {
|
public void setReadOnly(Boolean readOnly) {
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkMutability() {
|
||||||
|
if ( sessionFactory == null ) {
|
||||||
|
// that's the signal that this is the immutable, context-less
|
||||||
|
// variety
|
||||||
|
throw new IllegalStateException( "Cannot modify context-less LoadQueryInfluencers" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue