Skip to content

Commit db10030

Browse files
author
Mark Hall
committed
Fixed a bug that resulted in an unhelpful NPE when the named source of training data is not present in the transformation.
1 parent 3ab3884 commit db10030

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/org/pentaho/di/trans/steps/pmi/BaseSupervisedPMIStep.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ public BaseSupervisedPMIStep( StepMeta stepMeta, StepDataInterface stepDataInter
137137
if ( infoStreams.size() == 0 ) {
138138
throw new KettleException( BaseMessages.getString( PKG, "BasePMIStep.Error.NoIncomingData" ) );
139139
}
140+
String trainingInputStepName = environmentSubstitute( m_meta.getTrainingStepInputName() );
140141
if ( infoStreams.size() > 1 ) {
141142
// check that there is a training stream named
142143
if ( Const.isEmpty( m_meta.getTrainingStepInputName() ) ) {
143144
throw new KettleException( BaseMessages.getString( PKG, "BasePMIStep.Error.NoTrainingInputStep" ) );
144145
}
145-
String trainingInputStepName = environmentSubstitute( m_meta.getTrainingStepInputName() );
146+
146147
boolean trainingMatch = false;
147148
for ( StreamInterface input : infoStreams ) {
148149
if ( input.getSubject().toString().equals( trainingInputStepName ) ) {
@@ -174,6 +175,10 @@ public BaseSupervisedPMIStep( StepMeta stepMeta, StepDataInterface stepDataInter
174175
}
175176
} else {
176177
m_data.m_trainingStream = infoStreams.get( 0 );
178+
if ( m_data.m_trainingStream == null ) {
179+
throw new KettleException( BaseMessages
180+
.getString( PKG, "BasePMIStep.Error.UnableToFindNamedTrainingSource", trainingInputStepName ) );
181+
}
177182
}
178183

179184
m_data.m_trainingRowMeta = getTransMeta().getStepFields( (String) m_data.m_trainingStream.getSubject() );

0 commit comments

Comments
 (0)