You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To reproduce:
Eclipse development env:
SpotBugs
Expected Behavior:
the file open the stream and without a close stream, which will make the application memory leaking and crash
try
{
File f = new File("backup");
if(f.exists())
{
FileInputStream fin=new FileInputStream(f);
ObjectInputStream ois=new ObjectInputStream(fin);
Hotel.hotel_ob=(holder)ois.readObject();
}
Scanner sc = new Scanner(System.in);
int ch,ch2;
char wish;
x:
do{
System.out.println("\nEnter your choice :\n1.Display room details\n2.Display room availability \n3.Book\n4.Order food\n5.Checkout\n6.Exit\n");
ch = sc.nextInt();
switch(ch){
case 1: System.out.println("\nChoose room type :\n1.Luxury Double Room \n2.Deluxe Double Room \n3.Luxury Single Room \n4.Deluxe Single Room\n");
ch2 = sc.nextInt();
Hotel.features(ch2);
break;
case 2:System.out.println("\nChoose room type :\n1.Luxury Double Room \n2.Deluxe Double Room \n3.Luxury Single Room\n4.Deluxe Single Room\n");
ch2 = sc.nextInt();
Hotel.availability(ch2);
break;
case 3:System.out.println("\nChoose room type :\n1.Luxury Double Room \n2.Deluxe Double Room \n3.Luxury Single Room\n4.Deluxe Single Room\n");
ch2 = sc.nextInt();
Hotel.bookroom(ch2);
break;
case 4:
System.out.print("Room Number -");
ch2 = sc.nextInt();
if(ch2>60)
System.out.println("Room doesn't exist");
else if(ch2>40)
Hotel.order(ch2-41,4);
else if(ch2>30)
Hotel.order(ch2-31,3);
else if(ch2>10)
Hotel.order(ch2-11,2);
else if(ch2>0)
Hotel.order(ch2-1,1);
else
System.out.println("Room doesn't exist");
break;
case 5:
System.out.print("Room Number -");
ch2 = sc.nextInt();
if(ch2>60)
System.out.println("Room doesn't exist");
else if(ch2>40)
Hotel.deallocate(ch2-41,4);
else if(ch2>30)
Hotel.deallocate(ch2-31,3);
else if(ch2>10)
Hotel.deallocate(ch2-11,2);
else if(ch2>0)
Hotel.deallocate(ch2-1,1);
else
System.out.println("Room doesn't exist");
break;
case 6:break x;
}
System.out.println("\nContinue : (y/n)");
wish=sc.next().charAt(0);
if(!(wish=='y'||wish=='Y'||wish=='n'||wish=='N'))
{
System.out.println("Invalid Option");
System.out.println("\nContinue : (y/n)");
wish=sc.next().charAt(0);
}
}while(wish=='y'||wish=='Y');
Thread t=new Thread(new write(Hotel.hotel_ob));
t.start();
}
catch(Exception e)
{
System.out.println("Not a valid input");
}
}
}
enviorment:
eclipse env:
Possible solution: should close the file stream without making the application crash
Impact: high
Severity: high
The text was updated successfully, but these errors were encountered:
report name: OS_OPEN_STREAM
To reproduce:
Eclipse development env:
SpotBugs
Expected Behavior:
the file open the stream and without a close stream, which will make the application memory leaking and crash
}
enviorment:
eclipse env:
Possible solution: should close the file stream without making the application crash
Impact: high
Severity: high
The text was updated successfully, but these errors were encountered: