Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8202410

When using Java 8 forEach loop two times, the second time its not working

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      JDK 1.8

      A DESCRIPTION OF THE PROBLEM :
      When I use Jav8 ForEach loop 2 times. The Second time it is not working

      REGRESSION : Last worked in version 8u161

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      When I use Jav8 ForEach loop 2 times. The Second time it is not working

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Even second forEach loop also should work like the first forEach loop

      ---------- BEGIN SOURCE ----------
      List<WKFDBPojo> list = appDao.getEnrollRejectInfo();

      System.out.println(list.size()+" list.size()");

      list.forEach( t -> {
      boolean isAutoPaytrackerPresent = false;
      int startIndex = t.getRequestXml().indexOf("<VisionId>"); startIndex= startIndex+("<VisionId>".length());
      int endIndex = t.getRequestXml().indexOf("</VisionId>");
      String visionId = t.getRequestXml().substring(startIndex, endIndex);
      t.setVisionId(visionId);
      try{
      isAutoPaytrackerPresent = isAutoPaytrackerPresent(t,visionId);
      }catch(Exception e){
      System.err.println(visionId+ " Error while making isAutoPaytrackerPresent check "+e);
      }

      boolean isAutoPayDiscountAlreadyPresent = false;


      if(!isAutoPaytrackerPresent && null == t.getRootCuase()){
      t.setRootCuase("AutoPay Tracker not present on customer Profile");
      }else{
      try{
      isAutoPayDiscountAlreadyPresent = isDiscountPresentOnProfile(t, visionId);
      }catch(Exception e){
      System.err.println(visionId+ " Error while making isDiscountPresentOnProfile check "+e);
      }

      if(isAutoPayDiscountAlreadyPresent){
      t.setRootCuase("AutoPay Discount Already Present on customer Profile");
      }
      }

      });

      System.out.println("**************************************************************");
      Map<String,Integer> map = new HashMap<String,Integer>();
           list.forEach( t -> {
      int count = map.get(t.getRootCuase());
      map.put(t.getRootCuase(), ++count);
      });
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Not Sure

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal (Inactive)
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: