Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 103908 Details for
Bug 235368
[table] ArrayIndexOutOfBoundsException in virtual TableViewer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Adjusted version of 'Patch' (3rd attachment)
clipboard.txt (text/plain), 9.89 KB, created by
RĂ¼diger Herrmann
on 2008-06-06 05:15:54 EDT
(
hide
)
Description:
Adjusted version of 'Patch' (3rd attachment)
Filename:
MIME Type:
Creator:
RĂ¼diger Herrmann
Created:
2008-06-06 05:15:54 EDT
Size:
9.89 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/widgets/Table.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java,v >retrieving revision 1.38 >diff -u -r1.38 Table.java >--- src/org/eclipse/swt/widgets/Table.java 2 Jun 2008 17:03:34 -0000 1.38 >+++ src/org/eclipse/swt/widgets/Table.java 6 Jun 2008 09:09:05 -0000 >@@ -127,7 +127,9 @@ > } > > public void checkData( final int index ) { >- Table.this.checkData( Table.this._getItem( index ), index ); >+ if( index >= 0 && index < Table.this.itemCount ) { >+ Table.this.checkData( Table.this._getItem( index ), index ); >+ } > } > > public int getDefaultColumnWidth() { >@@ -1920,7 +1922,7 @@ > checkWidget(); > SelectionEvent.removeListener( this, listener ); > } >- >+ > ///////////////////////////// > // Create and destroy columns > >@@ -2134,12 +2136,14 @@ > if( ( style & SWT.VIRTUAL ) != 0 && !item.cached ) { > ProcessActionRunner.add( new Runnable() { > public void run() { >- item.cached = true; >- SetDataEvent event = new SetDataEvent( Table.this, item, index ); >- event.processEvent(); >- // widget could be disposed at this point >- if( isDisposed() || item.isDisposed() ) { >- SWT.error( SWT.ERROR_WIDGET_DISPOSED ); >+ if( index >= 0 && index < itemCount ) { >+ item.cached = true; >+ SetDataEvent event = new SetDataEvent( Table.this, item, index ); >+ event.processEvent(); >+ // widget could be disposed at this point >+ if( isDisposed() || item.isDisposed() ) { >+ SWT.error( SWT.ERROR_WIDGET_DISPOSED ); >+ } > } > } > } ); >#P org.eclipse.rap.rwt.q07 >Index: src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java,v >retrieving revision 1.2 >diff -u -r1.2 TableLCA.java >--- src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java 2 Jun 2008 17:03:37 -0000 1.2 >+++ src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java 6 Jun 2008 09:09:06 -0000 >@@ -83,7 +83,7 @@ > Table table = ( Table )widget; > readTopIndex( table ); // topIndex MUST be read *before* processSetData > readSelection( table ); >- processSetData( table ); >+ readSetData( table ); > readWidgetSelected( table ); > readWidgetDefaultSelected( table ); > ControlLCAUtil.processMouseEvents( table ); >@@ -169,7 +169,7 @@ > } > } > >- private static void processSetData( final Table table ) { >+ private static void readSetData( final Table table ) { > if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_SET_DATA ) ) { > HttpServletRequest request = ContextProvider.getRequest(); > String value = request.getParameter( JSConst.EVENT_SET_DATA_INDEX ); >@@ -178,7 +178,9 @@ > ITableAdapter tableAdapter = ( ITableAdapter )adapter; > for( int i = 0; i < indices.length; i++ ) { > int index = Integer.parseInt( indices[ i ] ); >- tableAdapter.checkData( index ); >+ if (index >-1 && index < table.getItemCount()) { >+ tableAdapter.checkData( index ); >+ } > } > } > } >@@ -186,17 +188,21 @@ > private void readWidgetSelected( final Table table ) { > if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_WIDGET_SELECTED ) ) { > // TODO [rh] do something about when index points to unresolved item! >- TableItem item = table.getItem( getWidgetSelectedIndex() ); >- int detail = getWidgetSelectedDetail(); >- int id = SelectionEvent.WIDGET_SELECTED; >- SelectionEvent event = new SelectionEvent( table, >- item, >- id, >- new Rectangle( 0, 0, 0, 0 ), >- "", >- true, >- detail ); >- event.processEvent(); >+ final int widgetSelectedIndex = getWidgetSelectedIndex(); >+ // Bugfix: check if index is valid before firing event to avoid problems with fast scrolling >+ if (widgetSelectedIndex > -1 && widgetSelectedIndex < table.getItemCount()) { >+ TableItem item = table.getItem( widgetSelectedIndex ); >+ int detail = getWidgetSelectedDetail(); >+ int id = SelectionEvent.WIDGET_SELECTED; >+ SelectionEvent event = new SelectionEvent( table, >+ item, >+ id, >+ new Rectangle( 0, 0, 0, 0 ), >+ "", >+ true, >+ detail ); >+ event.processEvent(); >+ } > } > } > >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/swt/widgets/Table_Test.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Table_Test.java,v >retrieving revision 1.27 >diff -u -r1.27 Table_Test.java >--- src/org/eclipse/swt/widgets/Table_Test.java 2 Jun 2008 17:03:40 -0000 1.27 >+++ src/org/eclipse/swt/widgets/Table_Test.java 6 Jun 2008 09:09:07 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2002-2006 Innoopract Informationssysteme GmbH. >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -8,7 +8,6 @@ > * Contributors: > * Innoopract Informationssysteme GmbH - initial API and implementation > ******************************************************************************/ >- > package org.eclipse.swt.widgets; > > import junit.framework.TestCase; >@@ -424,10 +423,6 @@ > Object adapter = table.getAdapter( ITableAdapter.class ); > ITableAdapter tableAdapter = ( ITableAdapter )adapter; > >-// table.setItemCount( 100 ); >-// table.setSelection( 90 ); >-// table.setSize( 501, 501 ); >-// table.setItemCount( 10 ); > table.setItemCount( 100 ); > table.setSelection( 99 ); > table.setSize( 501, 501 ); >@@ -1447,6 +1442,27 @@ > assertNotNull( item ); > assertEquals( 0, table.indexOf( item ) ); > } >+ >+ /* >+ * Ensures that checkData calls with an invalid index are silently ignored. >+ * This may happen, when the itemCount is reduced during a SetData event. >+ * Queued SetData events may then have stale (out-of-bounds) indices. >+ * See 235368: [table] [table] ArrayIndexOutOfBoundsException in virtual >+ * TableViewer >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=235368 >+ */ >+ public void testCheckDataWithInvalidIndex() { >+ RWTFixture.fakePhase( PhaseId.PROCESS_ACTION ); >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ Table table = new Table( shell, SWT.VIRTUAL ); >+ table.setItemCount( 10 ); >+ ITableAdapter adapter >+ = ( ITableAdapter )table.getAdapter( ITableAdapter.class ); >+ adapter.checkData( 99 ); >+ // No assert - the purpose of this test is to ensure that no >+ // ArrayIndexOutOfBoundsException is thrown >+ } > > private static void clearColumns( final Table table ) { > while( table.getColumnCount() > 0 ) { >#P org.eclipse.rap.rwt.q07.test >Index: src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java,v >retrieving revision 1.2 >diff -u -r1.2 TableLCA_Test.java >--- src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java 2 Jun 2008 17:03:30 -0000 1.2 >+++ src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java 6 Jun 2008 09:09:08 -0000 >@@ -516,6 +516,44 @@ > assertTrue( Fixture.getAllMarkup().indexOf( "Item 500" ) != -1 ); > } > >+ /* >+ * Ensures that checkData calls with an invalid index are silently ignored. >+ * This may happen, when the itemCount is reduced during a SetData event. >+ * Queued SetData events may then have stale (out-of-bounds) indices. >+ * See 235368: [table] [table] ArrayIndexOutOfBoundsException in virtual >+ * TableViewer >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=235368 >+ */ >+ public void testReduceItemCountInSetData() { >+ RWTFixture.fakePhase( PhaseId.PROCESS_ACTION ); >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ shell.setSize( 100, 100 ); >+ Table table = new Table( shell, SWT.VIRTUAL ); >+ table.addListener( SWT.SetData, new Listener() { >+ public void handleEvent( Event event ) { >+ fail( "Must not trigger SetData event" ); >+ } >+ } ); >+ >+ RWTFixture.fakePhase( PhaseId.READ_DATA ); >+ table.setItemCount( 1 ); >+ ITableAdapter adapter >+ = ( ITableAdapter )table.getAdapter( ITableAdapter.class ); >+ adapter.checkData( 0 ); >+ >+ RWTFixture.fakePhase( PhaseId.PROCESS_ACTION ); >+ table.setItemCount( 0 ); >+ int eventCount = 0; >+ while( ProcessActionRunner.executeNext() ) { >+ eventCount++; >+ } >+ while( SetDataEvent.executeNext() ) { >+ eventCount++; >+ } >+ assertEquals( 1, eventCount ); >+ } >+ > private static int countResolvedItems( final Table table ) { > Object adapter = table.getAdapter( ITableAdapter.class ); > ITableAdapter tableAdapter = ( ITableAdapter )adapter;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 235368
:
103345
|
103552
|
103757
| 103908 |
104115