@@ -108,15 +108,17 @@ public synchronized void open() {
108108 closed = false ;
109109 }
110110
111- // Allocate native memory. (Checker Framework: The local variables are
112- // `@NonNull` copies of the `@Nullable` fields.)
113- var callback = this .callback = createCallback ();
114- var stream = this .stream = createFSEventStream (callback );
115- var queue = this .queue = createDispatchQueue ();
111+ // Allocate native memory
112+ callback = createCallback ();
113+ stream = createFSEventStream (callback );
114+ queue = createDispatchQueue ();
116115
117116 // Start the stream
118- FSE .FSEventStreamSetDispatchQueue (stream , queue );
119- FSE .FSEventStreamStart (stream );
117+ var streamNonNull = stream ;
118+ if (streamNonNull != null ) {
119+ FSE .FSEventStreamSetDispatchQueue (streamNonNull , queue );
120+ FSE .FSEventStreamStart (streamNonNull );
121+ }
120122 }
121123
122124 private FSEventStreamCallback createCallback () {
@@ -187,24 +189,22 @@ public synchronized void close() {
187189 closed = true ;
188190 }
189191
190- // Stop the stream
191- if (stream != null ) {
192- var streamNonNull = stream ; // Checker Framework: `@NonNull` copy of `@Nullable` field
192+ var streamNonNull = stream ;
193+ var queueNonNull = queue ;
194+ if (streamNonNull != null && queueNonNull != null ) {
195+
196+ // Stop the stream
193197 FSE .FSEventStreamStop (streamNonNull );
194198 FSE .FSEventStreamSetDispatchQueue (streamNonNull , Pointer .NULL );
195199 FSE .FSEventStreamInvalidate (streamNonNull );
196200
197201 // Deallocate native memory
202+ DO .dispatch_release (queueNonNull );
198203 FSE .FSEventStreamRelease (streamNonNull );
204+ queue = null ;
205+ stream = null ;
206+ callback = null ;
199207 }
200- if (queue != null ) {
201- DO .dispatch_release (queue );
202- }
203-
204- // Deallocate native memory
205- callback = null ;
206- stream = null ;
207- queue = null ;
208208 }
209209}
210210
0 commit comments