Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:30:12+00:00 2026-05-20T06:30:12+00:00

I have some code like the following that I’m running in a debugger in

  • 0

I have some code like the following that I’m running in a debugger in Eclipse:

FileOutputStream fstream = new FileOutputStream(new File("foo"));
byte[] ba = someBytes();
fstream.write(bytes);

// tried with and without the following two lines. no difference
// fstream.flush();
// fstream.getFD().sync();

fstream.close();

When I step through this code in the Eclipse debugger, the file does not exist just after fstream.close() is called (verified via file.exists() from another File object created with the same path, as well as looking for the file in a bash shell).

I assume this is some kind of race condition, but I haven’t been able to find what’s going on. I tried adding fstream.flush() and fstream.getFD().sync(), per another StackOverflow question, but this did not help.

The ultimate symptom of this is that some test cases fail somewhat non deterministically. The behavior appears the same for consecutive identical runs, either with debugging or without, but if I change the breakpoints in the debugger, the behavior can change. I believe it usually/always works when I’m running the code outside of the debugger, but it’s troubling that the same code can fail inside of a debugger.

What could be happening here? Is there a good way to make sure the file is written when I think it is?

**UPDATE: I figured out a little of what is going on. The following hack forces the file to be written:

fstream.close();
fstream = new FileOutputStream(file, true);

This is a hack, but seems to force the OS to finish its writing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:30:13+00:00Added an answer on May 20, 2026 at 6:30 am

    This seemed to be an issue with the Eclipse debugger. The hack I mentioned in my edit is the only way I found to force the expected behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have some code like the following, and that processData gets executed
I have some code that looks like the following. First I have some domain
I have some code that is structured like the following: if (someStatement) { //...
I have some debugging code that looks like the following: #define STRINGIFY(x) #x #define
I have some code that looks like the following coming back from an XHR
Let's say I have some code like this if(isset($_GET['foo'])) //do something if(isset($_GET['bar'])) //do something
I have some code that looks like: template<unsigned int A, unsigned int B> int
I have some code that looks like this: someFunc(value) { switch(value){ case 1: case
I am new to C# (and OOP ). When I have some code like
I have some R code inside a file called analyse.r. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.