For Loop Will Not Execute

I have been a software engineer for a number of years now, and thus far I have never come across any coding issues that truly merit a post such as this. Someone has almost always run across the issue before, so there is no need to reinvent the wheel, or solution as it were.
However, a number of times I have run across instances where the JRE simply... does not execute parts of my code, and throws no exceptions.
The sample code is a simple logging application, watered down to the bare minimum for the purposes of this forum:
public class Log {
public static void main(String[] args)    {Log log = new Log();}
public Log() {Logger.log("Hello World");}
import java.util.*;*
import java.io.*;
import java.text.SimpleDateFormat;
public abstract class Logger {
private static final int SIZE = 2;
private static final SimpleDateFormat DAY = new SimpleDateFormat("EEEE");
private static final String
  DIR = "logs/",
  EXT = ".log",
  FILTER = ".*log\\z",
  DNE = "DNE";
private static int i,oldest;
private static long previous = 0;
private static FileFilter filter = new LogFilter();
private static FileWriter out;
private static File file,directory;
private static File[] list;
public synchronized static void log(String param) {
  try {
   directory = new File(DIR);
   file = new File(DIR + getDay() + EXT);
   list = directory.listFiles(filter);
   if (file.createNewFile()) {
    readOnly();
    reconcile();
   write(param);
  catch (Exception exception) {}
private static void write(String param) throws Exception {
  out = new FileWriter(file, true);
  out.write(param);
  out.close();
private static void readOnly() throws Exception {
  for (i=0;i<list.length;i++) {list.setReadOnly();}
private static void reconcile() {
try {
previous = list[SIZE].lastModified();
oldest = SIZE;
for (i=SIZE;i<=0;i--) {
if (list[i].lastModified() <= previous) {
previous = list[i].lastModified();
oldest = i;
list[oldest].delete();
catch (Exception exception) {System.out.println("Skipping reconciliation...");}
private static String getDay() throws Exception {
return DAY.format(Calendar.getInstance().getTime());
private static class LogFilter implements FileFilter {
public LogFilter() {}
public boolean accept(File param) {
try {
if ((param.getName()).matches(FILTER)) {return true;}
else {return false;}
catch (Exception exception) {return false;}
*The problem*:
Ok, easy visual, this is the "log/" directory as I run the Log.java application repeatedly and iterate the date on my computer as I do so.
Thursday
*log/*
+Thursday.log+
Friday
*log/*
+Thursday.log+
+Friday.log+
Saturday
*log/*
+Thursday.log+
+Friday.log+
+Saturday.log+
Sunday
*log/*
+Friday.log+
+Saturday.log+
+Sunday.log+
Monday
*log/*
+Friday.log+
+Saturday.log+
+Monday.log+
This is the point at which I go ???
Turns out, the JRE skips the execution of my for loop in the *reconcile()* method when the date rolls over to Monday, and from then on it simply deletes the previous day's log instead of the oldest log.
Why?  Who knows.
Things I have tried:
- Using another variable integer for the *readOnly()* method
- Removing the synchronized keyword from the *log(String param)* method
- Second call to *directory.listFiles(filter)* and setting *SIZE* to *3* after the old files have been set to read-only
- Removing the call to *readOnly()*
- Verified that the call to *readOnly()* does not alter the +modified+ date on the log files
- Changed Logger.java from a +static+ class to a +local+ class
Things I cannot do:
This log application stores privy information about end-users at locations across the country in the event that there are support issues that need to be resolved, and the agreement is that we store this information no more than three days.  Just wanted to make sure, that the hopefully informed respondants to this issue, know that the obvious solution (storing seven day records), is unfortunately not available to me.
Edited by: Threadstorm on Jan 8, 2009 8:24 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

HA! Most excellent. The last place I would ever look.
Yes, seems like Java sorts the files in such a way that everything works fine without the loop until Monday rolls over.
Now I can have a better appreciation for that second set of eyes.
I use for loops so frequently that I never look at them (though I did stare at this one myself prior to this post, much to my chagrin now) but the subtracting iteration (which I use once in a blue moon) was necessary for the nature of the code.
But ok, up and running! (whew) was going to be a long day until now.
To answer your question though, the Logger is static so I don't have to pass it around to dozens and dozens of other modules but rather just include the package on the fly as I develop new modules that need to log information, and I like to write most mundane things myself if I can, that way I have the freedom to modify them at will.
Thanks again! I'm now a happy camper once more.
I'm also thankful that I don't have to chalk up another notch on the wall of cases where the JRE behaves magically and truly ignores code which I have definitely run into before. Something about listCellRenderers and the order of calls made to them, or some such and JRE doesn't read one of the lines. It's been a year or two.
Edited by: Threadstorm on Jan 8, 2009 8:47 AM

Similar Messages

  • When debugging, a for loop is not entered even though the number 6 is passed to "N".

    I cannot figure out why a for loop is not entered when I debug it. When debugging a value of 6 is clearly passed to "N", the number of iterations the loop is supposed to execute. So when I debug, execution highlighting just parses right over the loop, even though I request to enter the loop. Everything inside of the loop is not executed. Have you experienced this before? - Any ideas?

    As mentioned by "eh" auto-indexed arrays that are empty will cause this.
    A "FOR loop" will itereate as many times as is indicated by the smallest number elements in any of its auto-indexed inputs.
    When you watch it in execution-highlighting, you probably will see a "0" coming in on an auto-indexed input.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • FOR LOOP EXCEPTION not working !!! please help

    Hi,
    Why is the NO_DATA_FOUND execption not getting executed. ????
    Hereis the code....
    CURSOR newreccur IS
    SELECT * from emp_table;
    BEGIN
    v_file_handle := UTL_FILE.FOPEN('out','new.dat','W');
    BEGIN
    FOR emp_rec IN newreccur LOOP
    -- Write procurement records
    UTL_FILE.PUT(v_file_handle,'emp_rec.num');
    END LOOP;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    dbms_output.put_line ('No data found ')
    END;
    EXCEPTION
    WHEN UTL_FILE.INVALID_PATH
    THEN
    DBMS_OUTPUT.PUT_LINE ( 'Invalid Path ' || TO_CHAR (SQLCODE) );
    UTL_FILE.FCLOSE_ALL;
    END;

    cursor for loops do not raise no_DatA_found - they simply stop looping when they run out of data. you can set a variable within the loop, and then check it after the loop if you need to know if data was returned or not.

  • Service stack update 2871777 to enable installation of RDP Connection Broker on 2012 domain controller - downloaded file will not execute.

    service stack update 2871777 to enable installation of RDP Connection Broker on 2012 domain controller - downloaded file will not execute.
    Downloaded x64 update for server 2012 R2 (KB2871777) -  file downloaded is named Windows8-RT-KB2871777-x64.msu
    When downloaded to server 2012 R2, upon launching the files, the message reads "Windows Update Standalone Installer"
    "The update is not applicable t your computer"
    If this is the wrong update please point me to the correct one - I cannot find another instance of this update anywhere.
    I am unable to remove the active directory from this server, so I need to use this fix if at all possible, in order to use RDP.
    I have tried every workaround I can find.  The goal is to have remote users access RDP to run a remote session and access apps and files
    on the server.  we have Hyper-V enabled and have successfully deployed 10 RDP licenses to the license server) also on the PDC.
    I read one post that suggested installing RD Connection Broker in one instance of a VM and AD DS in the other - not sure if that means we remove
    AD DS from physical server.  We only have one 2012 server (plus a server 2008 with Ad DS) and  a server 2003.  Trying to make this all work so we can deploy 10 remote desktop users.

    KB2871777 appears to be for 2012 (non R2) only.
     As to the other problem maybe this one helps.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/bbf47aa2-8ae5-4f22-9827-afee5a11417a/install-remote-desktop-services-failed-on-windows-2012-server?forum=winserverTS
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Adobe Encore CS4: End action will not execute because of end action on the final chapter point

    Error screen:
    Error I’m getting for section titled Notes (PP 45 second video): “End action will not execute because of end action on the final chapter point.”
    The icon that shows error is in top line second from end.  I’m trying to 'end action' that portion of the video by going back to 'menu default'; also tried end action w/ ‘Stop’ and neither work.
    I saw a post about checking timeline.  Not sure what I’m looking for there.  I have nothing in Orphanage area.  I also tried building despite Check Project error and it will not build project.  Any suggestions on how to fix: “End action will not execute because of end action on the final chapter point.”?

    Select chapter one on that timelne. Look in the properties panel. Does it have an end action? You do not want an end action on the chapter; just on the timeline itself.
    That will not generally prevent a build, however. So you may have other issues.

  • End action will not execute because of end action on the final chapter point

    I will be referring to this video:
    http://tv.adobe.com/watch/learn-encore-cs4/creating-an-event-dvd/
    I followed this exactly, except for the slide show (and I made a DVD instead of flash), but when I checked the project, I get the error message "End action will not execute because of end action on the final chapter point".
    I don't understand.  I did not change any end points except for the one specified in this tutorial.  (About the Max footage for the very beginning, before the menu).  If anything was added, it was Adobe's doing.
    I do notice that in 00:04 in the tutorial, there's a downward arrow on the very end of the timeline.  My timeline does not have this.  How was this done?
    In the Encore software, after the timeline is loaded, there is no arrow at the very end.  Mine doesn't have that either.
    I'm finding Adobe/Encore's way of making menus rather difficult.  With Pinnacle Studios (at least through 8-12), making menus was easy, and it set up the chapters for you.  Why can't there be an automated menu feature in Encore?
    Anyway, here's my project:
    Main time line has 9 chapters. When clicking on their chapter points, all say End Action: not set.
    When I click on the white bar above the lite purple footage of the time line, where the chapter point's bottom rest, it says, End Action: Not Set AND Menu Remote: Return to Last Menu.
    All 9 chapter points are white.
    In the flowcart, there is the DVD icon --> my few seconds opening credits --> menu that has a Play All and Scene Selection button
    Play All goes to first chapter of video
    Scene Selection (submenu #1) goes to 6 scenes, a next, previous, main menu.  All seem to be linked properly.
    Scene Selection for scenes 7-9 are in the #2 submenu.  Has a previous button and a main menu button.   All seem to be linked properly.
    Can anyone offer any advice?  Help?  I need to make this DVD and two others by the end of the week!
    If you need more information, please let me know that too.

    If I make a change in the timeline in Premiere, will that new change be reflected in the timeline of Encore?
    If you used Adobe Dynamic Link, then yes, the Timeline will be updated. If you did not, then you will need to Export again, then Import into Encore. Watch out if you have already Transcoded, etc., and I'd name the new Timeline Export differently, Import that, use Replace Asset. When a Project is very new, and nothing much has been done, it will not be so picky. After a couple of links, etc., it gets VERY picky, and Replace Asset will help.
    Is there a way to reload the project without having to redo all the menus and links?
    If you did a Save_As, or still have your original Project, i.e. you started a completely new Project with a unique name, you can go back to the original.
    Hope that helps,
    Hunt

  • Query button will not execute on form portal (9.0.4)

    I have a master-detail form that will not execute the query or reset buttons. The query will work if I use a link to execute the form. It was working ok. If I create a new form the query button still won't execute.

    There was a plugin that was causing the problem. Went to Internet Options.
    Click the Advanced tab.
    Under Browsing, click to clear the Enable third-party browser extensions (requires restart) check box.
    Restarted Internet Explorer.
    It works. Thanks for the help!

  • F-Secure SAFE installer will not execute (Windows 10)

    I just combated through Windows 10 upgrade from Windows 7 (64bit). However, now after upgrading F-Secure SAFE installer that I downloaded from mysafe-portal, will not execute. It simply appears to be doing nothing. Download looks successful and I re-downloaded the installer as well. What to do? Suggestions?

    Yes, I did reboot  Will the uninstall tool work for Windows 10 as well? It is not mentioned, or I am blind I will try it though.. The story is that I first started Win10 upgrade without removing anything. Then I ended up in a situation where explorer.exe crashed right after login. After some struggling with task manager and command line without being able to fix the crash, I reverted back to Windows 7. While back in Windows 7, I uninstalled F-Secure and some other software I thought might affect and re-upgraded. Then Windows 10 appeared to be working like a charm. Now, back in Windows 10, I installed my Dropbox app and then have been trying to re-install F-Secure SAFE. Thanks for all tips and ideas.

  • Photoshop CC 2014 for PC will not copy or paste

    Running:
    Photoshop CC 2014 for PC
    Windows 8.1 Pro, R2 64 bit, AMD FX3 8350 with 16GB RAM. 75% of RAM free
    Photoshop CC 2014 for PC will not copy or paste.
    When I create a line of text and want to copy and paste the text in the same document, the copy and paste functions are not working. The commands on the Edit menu are grayed out. CTL+C and CTL+X and CTL+V do not work.
    I have the correct layer selected.
    There is nothing else selected, just the text.
    Copy and paste fail on new documents, existing documents, documents with backgrounds, documents without backgrounds.
    I deleted all my Photoshop settings in Roaming>Adobe>Photoshop CC 2014
    I uninstalled Photoshop without saving preferences, removed all files and folders and then reinstalled.
    Photoshop will still not copy and paste.

    I honestly don't know what may be wrong on your system to cause what you're seeing, but I can confirm that on my fully updated Windows 8.1 Pro x64 system equipped with ATI 7850 I can do cut/copy/pastes as you would like to do, so it's not a basic incompatibility.
    Are you selecting the characters by dragging the mouse across them, then copying?
    When pasting, have you set an insertion point first?
    -Noel

  • I have an iMac with OS Lion. The Smartart feature for Office for Mac will not work when I am logged on to my personal user account. It works with other user accounts on the same computer, and it works after "safe start". How can I fix the problem?

    The Smartart feature of Office for Mac will not work in my user account. It works for all other user accounts on the same computer, and it works after a "safe start". How can I fix the problem?

    You may also want to search/ask in the forums run by the people who make the product which is causing you problems:
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011

  • HT204053 I recently changed ny Apple ID but it did not transfer over to my iCloud account. How do I change my iCloud ID? The login popup for iCloud will not go away so I cannot get into my iPad since it pops up as soon as I turn the device on.

    I recently changed my Apple ID but it did not transfer over to my iCloud account. How do I change my iCloud ID? The password for the new Apple ID does not work since the iCloud default user name is imbedded in the login box. The login popup for iCloud will not go away so I cannot get into my iPad since it pops up as soon as I turn the device on and re-occurs every few seconds.

    You have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iPhone, then sign back in with the ID you wish to use.  If you don't know the password for your old ID, or if it isn't accepted, go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPad on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iPad when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • New CS6 on disk for Mac will not take my valid serial number; do I need to register the product before it will accept serial number and load on my Mac Book Pro?

    New CS6 on disk for Mac will not take my valid serial number; do I need to register the product before it will accept serial number and load on my Mac Book Pro?

    Hi Erwin,
    Please go through the below forum link and check.
    https://forums.adobe.com/thread/1079210
    Regards,
    Anand

  • Illustrator for PC will not download. All other apps, no problem

    Illustrator for PC will not download. All other apps, no problem

    Buttonsandbows and Alayne I would recommend reviewing the installation logs to determine the specific error that you are experiencing.  You can find details on how to locate and interpret the installation log files at Troubleshoot install issues with log files | CC - http://helpx.adobe.com/creative-cloud/kb/troubleshoot-install-logs-cc.html.  You are welcome to post any specific error messages to this discussion.

  • DM for Mac will not sync groups from my address book

    After spending 40 minutes with BB tech support, I was told that the new DM for Mac will not sync the groups in addressbook. They say maybe in the next version of DM. 
    Blackberry Pearl 8100
    Intel Mac
    OSX 10.6.1

    Neither does DM for the PC... I wish it would also (and since DM for the PC has been through many upgrades, I don't know that you will see that added so soon.
    Here's hoping!
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Safari for Windows will not log into IIS sites with Windows Authentication

    Safari for Windows will not log into IIS sites with Windows Authentication enabled. The IIS log has thousands of login attempts from Safari that result in 401 errors.
    I disable Windows Authentication on IIS and it works fine. The problem with that is that my Windows clients stop working properly with seemless logins when I disable this.
    The expected behavior is that Safari will work with basic authentication when NTLM does not work. That would result in a password prompt followed by a successful login instead of Safari stopping at "Loading" while hammering the IIS logs.
    It does this on all machines that I have tried.
    Any ideas or is this a bug?

    I noticed that as well. I have to wonder if it's due to not making note of the the different end of line characters between Mac OS X and Windows in code.

Maybe you are looking for