@@ -177,9 +177,6 @@ protected boolean readSize() {
177177 read ();
178178 }
179179 }
180- else {
181- throwLazyInitializationExceptionIfNotConnected ();
182- }
183180 return false ;
184181 }
185182 );
@@ -193,9 +190,9 @@ public int getSize() {
193190 return cachedSize ;
194191 }
195192 else {
193+ throwLazyInitializationExceptionIfNotConnected ();
196194 final var entry = getCollectionEntry ();
197195 if ( entry == null ) {
198- throwLazyInitializationExceptionIfNotConnected ();
199196 throwLazyInitializationException ( "collection not associated with session" );
200197 throw new AssertionFailure ( "impossible" );
201198 }
@@ -373,9 +370,9 @@ protected Boolean readElementExistence(final Object element) {
373370
374371 @ Override
375372 public boolean elementExists (Object element ) {
373+ throwLazyInitializationExceptionIfNotConnected ();
376374 final var entry = getCollectionEntry ();
377375 if ( entry == null ) {
378- throwLazyInitializationExceptionIfNotConnected ();
379376 throwLazyInitializationException ( "collection not associated with session" );
380377 throw new AssertionFailure ( "impossible" );
381378 }
@@ -413,9 +410,9 @@ protected Object readElementByIndex(final Object index) {
413410
414411 @ Override
415412 public Object elementByIndex (Object index ) {
413+ throwLazyInitializationExceptionIfNotConnected ();
416414 final var entry = getCollectionEntry ();
417415 if ( entry == null ) {
418- throwLazyInitializationExceptionIfNotConnected ();
419416 throwLazyInitializationException ( "collection not associated with session" );
420417 throw new AssertionFailure ( "impossible" );
421418 }
0 commit comments