Program: 105112
Project: 105112
Buggy source:
@SuppressWarnings("String_Node_Str") private void updateSystemVmTemplates(final Connection conn){
  LOG.debug("String_Node_Str");
  final Set<Hypervisor.HypervisorType> hypervisorsListInUse=new HashSet<Hypervisor.HypervisorType>();
  try (PreparedStatement pstmt=conn.prepareStatement("String_Node_Str");ResultSet rs=pstmt.executeQuery()){
    while (rs.next()) {
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
case XenServer:
        hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
      break;
case KVM:
    hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
  break;
case VMware:
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
break;
case Hyperv:
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
break;
default :
break;
}
}
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
final Map<Hypervisor.HypervisorType,String> NewTemplateNameList=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
final Map<Hypervisor.HypervisorType,String> routerTemplateConfigurationNames=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
final Map<Hypervisor.HypervisorType,String> newTemplateUrl=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
final Map<Hypervisor.HypervisorType,String> newTemplateChecksum=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
for (final Map.Entry<Hypervisor.HypervisorType,String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
LOG.debug("String_Node_Str" + hypervisorAndTemplateName.getKey() + "String_Node_Str");
try (PreparedStatement pstmt=conn.prepareStatement("String_Node_Str")){
long templateId=-1;
pstmt.setString(1,hypervisorAndTemplateName.getValue());
try (ResultSet rs=pstmt.executeQuery()){
if (rs.next()) {
templateId=rs.getLong(1);
}
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
if (templateId != -1) {
try (PreparedStatement templ_type_pstmt=conn.prepareStatement("String_Node_Str")){
templ_type_pstmt.setLong(1,templateId);
templ_type_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + templateId + "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + templateId + "String_Node_Str",e);
}
try (PreparedStatement update_templ_id_pstmt=conn.prepareStatement("String_Node_Str")){
update_templ_id_pstmt.setLong(1,templateId);
update_templ_id_pstmt.setString(2,hypervisorAndTemplateName.getKey().toString());
update_templ_id_pstmt.executeUpdate();
}
 catch (final Exception e) {
LOG.error("String_Node_Str" + hypervisorAndTemplateName.getKey().toString() + "String_Node_Str"+ templateId+ "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + hypervisorAndTemplateName.getKey().toString() + "String_Node_Str"+ templateId,e);
}
try (PreparedStatement update_pstmt=conn.prepareStatement("String_Node_Str")){
update_pstmt.setString(1,hypervisorAndTemplateName.getValue());
update_pstmt.setString(2,routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
update_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + "String_Node_Str"+ hypervisorAndTemplateName.getValue()+ "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + "String_Node_Str"+ hypervisorAndTemplateName.getValue(),e);
}
try (PreparedStatement update_pstmt=conn.prepareStatement("String_Node_Str")){
update_pstmt.setString(1,getUpgradedVersion());
update_pstmt.setString(2,"String_Node_Str");
update_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
}
 else {
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + "String_Node_Str");
}
 else {
LOG.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + "String_Node_Str"+ hypervisorAndTemplateName.getKey()+ "String_Node_Str");
try (PreparedStatement update_templ_url_pstmt=conn.prepareStatement("String_Node_Str")){
update_templ_url_pstmt.setString(1,newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
update_templ_url_pstmt.setString(2,newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
update_templ_url_pstmt.setString(3,hypervisorAndTemplateName.getKey().toString());
update_templ_url_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + hypervisorAndTemplateName.getKey().toString() + "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + hypervisorAndTemplateName.getKey().toString(),e);
}
}
}
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
}
LOG.debug("String_Node_Str");
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void updateSystemVmTemplates(final Connection conn){
  LOG.debug("String_Node_Str");
  final Set<Hypervisor.HypervisorType> hypervisorsListInUse=new HashSet<Hypervisor.HypervisorType>();
  try (PreparedStatement pstmt=conn.prepareStatement("String_Node_Str");ResultSet rs=pstmt.executeQuery()){
    while (rs.next()) {
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
case XenServer:
        hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
      break;
case KVM:
    hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
  break;
case VMware:
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
break;
case Hyperv:
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
break;
default :
break;
}
}
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
final Map<Hypervisor.HypervisorType,String> NewTemplateNameList=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
final Map<Hypervisor.HypervisorType,String> routerTemplateConfigurationNames=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
final Map<Hypervisor.HypervisorType,String> newTemplateUrl=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
final Map<Hypervisor.HypervisorType,String> newTemplateChecksum=new HashMap<Hypervisor.HypervisorType,String>(){
{
put(Hypervisor.HypervisorType.XenServer,"String_Node_Str");
put(Hypervisor.HypervisorType.VMware,"String_Node_Str");
put(Hypervisor.HypervisorType.KVM,"String_Node_Str");
put(Hypervisor.HypervisorType.Hyperv,"String_Node_Str");
}
}
;
for (final Map.Entry<Hypervisor.HypervisorType,String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
LOG.debug("String_Node_Str" + hypervisorAndTemplateName.getKey() + "String_Node_Str");
try (PreparedStatement pstmt=conn.prepareStatement("String_Node_Str")){
long templateId=-1;
pstmt.setString(1,hypervisorAndTemplateName.getValue());
try (ResultSet rs=pstmt.executeQuery()){
if (rs.next()) {
templateId=rs.getLong(1);
}
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
if (templateId != -1) {
try (PreparedStatement templ_type_pstmt=conn.prepareStatement("String_Node_Str")){
templ_type_pstmt.setLong(1,templateId);
templ_type_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + templateId + "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + templateId + "String_Node_Str",e);
}
try (PreparedStatement update_templ_id_pstmt=conn.prepareStatement("String_Node_Str")){
update_templ_id_pstmt.setLong(1,templateId);
update_templ_id_pstmt.setString(2,hypervisorAndTemplateName.getKey().toString());
update_templ_id_pstmt.executeUpdate();
}
 catch (final Exception e) {
LOG.error("String_Node_Str" + hypervisorAndTemplateName.getKey().toString() + "String_Node_Str"+ templateId+ "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + hypervisorAndTemplateName.getKey().toString() + "String_Node_Str"+ templateId,e);
}
try (PreparedStatement update_pstmt=conn.prepareStatement("String_Node_Str")){
update_pstmt.setString(1,hypervisorAndTemplateName.getValue());
update_pstmt.setString(2,routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
update_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + "String_Node_Str"+ hypervisorAndTemplateName.getValue()+ "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + "String_Node_Str"+ hypervisorAndTemplateName.getValue(),e);
}
try (PreparedStatement update_pstmt=conn.prepareStatement("String_Node_Str")){
update_pstmt.setString(1,"String_Node_Str");
update_pstmt.setString(2,"String_Node_Str");
update_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
}
 else {
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + "String_Node_Str");
}
 else {
LOG.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + "String_Node_Str"+ hypervisorAndTemplateName.getKey()+ "String_Node_Str");
try (PreparedStatement update_templ_url_pstmt=conn.prepareStatement("String_Node_Str")){
update_templ_url_pstmt.setString(1,newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
update_templ_url_pstmt.setString(2,newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
update_templ_url_pstmt.setString(3,hypervisorAndTemplateName.getKey().toString());
update_templ_url_pstmt.executeUpdate();
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + hypervisorAndTemplateName.getKey().toString() + "String_Node_Str"+ e.getMessage());
throw new CloudRuntimeException("String_Node_Str" + hypervisorAndTemplateName.getKey().toString(),e);
}
}
}
}
 catch (final SQLException e) {
LOG.error("String_Node_Str" + e.getMessage());
throw new CloudRuntimeException("String_Node_Str",e);
}
}
LOG.debug("String_Node_Str");
}