Details
-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
Description
----Original Message----
From: Biernath, Jutta
Sent: Monday, May 23, 2016 4:24 AM
To: Hyzer, Chris; grouper-users
Subject: AW: [grouper-users] Bug found in GrouperLoaderResultSet.bulkLookupSubjects()
Hi, Chris,
Grouper Version 2.2
Source File: grouper.edu.internet2.middleware.grouper.app.loader.db.GrouperLoaderResultset
=========================================================================
Assignment of sourceIdCol:
------------------------------------
(line 99)
String sourceIdCol = null;
(line 130-134)
String subjectSourceId = (String) row.getCell(
GrouperLoaderResultset.SUBJECT_SOURCE_ID_COL, false);
if (!StringUtils.isBlank(subjectSourceId))
-
-
- --> sourceIdCol stays null
-
Assignment of sourceId:
-------------------------------
(line 136)
String sourceId = null;
(line 138-143)
if (!StringUtils.isBlank(sourceIdCol))
//default this to what is in the config file
sourceId = StringUtils.defaultString(sourceId, defaultSubjectSourceId);
-
-
- -->sourceId gets default value
-
subjectIdsOrIdentifiers does not get any value:
---------------------------------------------------------
(line 93)
Set<String> subjectIdsOrIdentifiers = new HashSet<String>();
(line 146-157)
if (!StringUtils.isBlank(sourceId)) {
Set<String> subjectIdsOrIdentifiersForSource = sourceToSubjectIdsOrIdentifiers.get(sourceId);
//lazy load for source
if (subjectIdsOrIdentifiersForSource == null)
subjectIdsOrIdentifiersForSource.add(subjectIdOrIdentifer);
} else
-
-
- --> sourceId has a value, so I never get into else branch --> subjectIdsOrIdentifiers will never get any values; It stays an empty HashMap
-
subjectIdOrIdentifierToSubject does not get any value:
--------------------------------------------------------------------
(line 194)
Map<String, Subject> subjectIdOrIdentifierToSubject = null;
(line 196-207)
if (GrouperUtil.length(subjectIdsOrIdentifiers) > 0) {
//what are they?
if (StringUtils.equals(subjectIdCol, GrouperLoaderResultset.SUBJECT_ID_COL))
else if (StringUtils.equals(subjectIdCol, GrouperLoaderResultset.SUBJECT_IDENTIFIER_COL))
{ subjectIdOrIdentifierToSubject = SubjectFinder.findByIdentifiers(subjectIdsOrIdentifiers); }else if (StringUtils.equals(subjectIdCol, GrouperLoaderResultset.SUBJECT_ID_OR_IDENTIFIER_COL))
{ subjectIdOrIdentifierToSubject = SubjectFinder.findByIdsOrIdentifiers(subjectIdsOrIdentifiers); }else
{ throw new RuntimeException("Not expecting subjectIdCol: " + subjectIdCol); }}
-
-
- --> subjectIdsOrIdentifiers is still empty, so I don't get into if-clause. But just here in this if-clause the values are assigned to subjectIdOrIdentifierToSubject --> there are never values assigned to subjectIdOrIdentifierToSubject; It stays null.
-
Null pointer exception
----------------------------
(line 215-226)
if (!StringUtils.isBlank(sourceIdCol)) {
String sourceId = (String)row.getCell(sourceIdCol, false);
if (!StringUtils.isBlank(sourceId)) {
Map<String, Subject> localSubjectIdOrIdentifierToSubject = sourceToSubjectIdOrIdentifierToSubject.get(sourceId);
if (localSubjectIdOrIdentifierToSubject != null)
}
} else
-
-
- --> StringUtils.isBlank(sourceIdCol) is true if sourceIdCol is null or empty. My sourceIdCol is still null, see above, so I get into the else branch here. But in the else branch the get-Method tries to get a value from subjectIdOrIdentifierToSubject, which is still null --> a null pointer exception occurs.
-
Regards,
Jutta
--------------------
Jutta Biernath
Freie Universität Berlin
Zentraleinrichtung für Datenverarbeitung (ZEDAT)
Identity & Customer Management, FUDIS
Fabeckstr. 32
14195 Berlin
----Ursprüngliche Nachricht----
Von: Hyzer, Chris Hyzer
Gesendet: Freitag, 20. Mai 2016 18:27
An: Biernath, Jutta; grouper-users
Betreff: RE: [grouper-users] Bug found in GrouperLoaderResultSet.bulkLookupSubjects()
Can you please give source file names and when referencing a source line give the line number and copy the source line too? Thanks, Chris
----Original Message----
From: grouper-users-request
On Behalf Of Jutta Biernath
Sent: Friday, May 20, 2016 7:04 AM
To: grouper-users
Subject: [grouper-users] Bug found in GrouperLoaderResultSet.bulkLookupSubjects()
Hi,
after upgrading Grouper from 2.1.5 to 2.2.2 I have encountered several NullPointerExceptions when running loadergroups. I have carefully analysed the source code because I wanted to understand the cause. This is what I found:
I have several loadergroups, each one with another view as resultset. Some of the views have a source_id column, others haven't (those which don't build a group hierarchy).
Now the NullPointerException occured with the loadergroups with resultsets without source_id column. This is what happened:
- I have a default source id set in the loader properties file, so this is <> null; this value is assigned to the variable sourceId
- However I don't have a source column in the resultset, what means that the variable sourceIdCol stays null
- Because sourceId has a valid value, the variable subjectIdsOrIdentifiers stays null; there are no values assigned to it.
- Because subjectIdsOrIdentifiers is null, also subjectIdOrIdentifierToSubject is null.
- In ln. 218 however there is an if/else command that checks if sourceIdCol is blank or not. My sourceIdCol is still null, so i get into the the else branch.
But there is a get()-Method on subjectIdOrIdentifierToSubject, which was never filled, see above --> a NullPointerException happens. Probably you wanted to check if sourceId was blank, not sourceIdCol.
Until this is fixed I will work with a workaround, giving all of my views a column for the subject source. I just wanted to inform you, I think this is relevant.
Regards,
Jutta Biernath
Freie Universität Berlin