Bug 213399 Exception occurs when iv generation task runs with query not changed.
reproduce steps. 1. create a report design with a table bound to some data set. 2. generate a document for the report design. 3. change the style of some item in the design. 4. run iv generation task based on the design and the document. Actual result: exceptions area thrown out. java.lang.NullPointerException at java.io.DataOutputStream.flush(DataOutputStream.java:106) at java.io.FilterOutputStream.close(FilterOutputStream.java:140) at org.eclipse.birt.data.engine.impl.document.viewing.RowIndexUtil.close(RowIndexUtil.java:89) at org.eclipse.birt.data.engine.impl.document.viewing.CachedExprResultSet.saveExprResult(CachedExprResultSet.java:175) at org.eclipse.birt.data.engine.impl.document.viewing.CachedExprResultSet.doSave(CachedExprResultSet.java:138) at org.eclipse.birt.data.engine.impl.document.RDSaveUtil.saveForUpdate(RDSaveUtil.java:152) at org.eclipse.birt.data.engine.impl.document.RDSaveUtil.saveResultIterator(RDSaveUtil.java:63) at org.eclipse.birt.data.engine.impl.document.RDSave.saveResultIterator(RDSave.java:221) at org.eclipse.birt.data.engine.impl.ResultIterator$RDSaveHelper.doSave(ResultIterator.java:1111) at org.eclipse.birt.data.engine.impl.ResultIterator$RDSaveHelper.doSaveExpr(ResultIterator.java:1076) at org.eclipse.birt.data.engine.impl.BindingColumnsEvalUtil.getColumnsValue(BindingColumnsEvalUtil.java:184) at org.eclipse.birt.data.engine.impl.ResultIterator.prepareCurrentRow(ResultIterator.java:631) at org.eclipse.birt.data.engine.impl.ResultIterator.next(ResultIterator.java:366) at org.eclipse.birt.report.engine.data.dte.QueryResultSet.next(QueryResultSet.java:173) at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:81) at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62) at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:45) at org.eclipse.birt.report.engine.internal.executor.emitter.ReportItemEmitterExecutor.execute(ReportItemEmitterExecutor.java:45) at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:42) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:63) at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:85) at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:106) at org.eclipse.birt.report.engine.presentation.ReportDocumentBuilder.build(ReportDocumentBuilder.java:189) at org.eclipse.birt.report.engine.api.impl.RunTask.doRun(RunTask.java:223) at org.eclipse.birt.report.engine.api.impl.RunTask.run(RunTask.java:112) at org.eclipse.birt.report.engine.api.iv.IVTest.ivRun(IVTest.java:69) at org.eclipse.birt.report.engine.api.iv.IVTest.doTestIV(IVTest.java:56) at org.eclipse.birt.report.engine.api.iv.IVTest.testIV(IVTest.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:58) at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethod(EclipseAppContainer.java:570) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:515) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:455) at org.eclipse.equinox.launcher.Main.run(Main.java:1193) at org.eclipse.equinox.launcher.Main.main(Main.java:1169)
data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/document/RDSaveUtil.java
saveForGeneration( odiResult, groupLevel, subQueryInfo );
		else
			saveForUpdate( odiResult, groupLevel, subQueryInfo );
	}
	
	/**
	 * @param odiResult
	 * @param groupLevel
	 * @param subQueryInfo
	 * @throws DataException
	 */
	private void saveForGeneration( IResultIterator odiResult, int groupLevel,
			int[] subQueryInfo ) throws DataException
	{
		try
		{
			
			OutputStream streamForResultClass = null;			
			OutputStream streamForGroupInfo = null;		
						
			boolean isSubQuery = streamManager.isSubquery( );
			if ( isSubQuery == false )
			{
				streamForResultClass = streamManager.getOutStream( DataEngineContext.DATASET_META_STREAM,
						StreamManager.ROOT_STREAM,
						StreamManager.SELF_SCOPE );
			}
			streamForGroupInfo = streamManager.getOutStream( DataEngineContext.GROUP_INFO_STREAM,
					StreamManager.ROOT_STREAM,
					StreamManager.SELF_SCOPE );