mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	prevent an NPE on an uninitialised TemplateObject (#8898)
* prevent an NPE on an uninitialised TemplateObject * move npe handler up-stack * Update engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/store/TemplateObject.java * catch yet one level up * Update engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java * Update engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/store/TemplateObject.java * extra guard * Revert "prevent an NPE on an uninitialised TemplateObject" This reverts commit e602a65ea62e4707828483a4ddea288d81ff06f5.
This commit is contained in:
		
							parent
							
								
									351de5fabd
								
							
						
					
					
						commit
						6b25ed7a02
					
				@ -99,6 +99,9 @@ public class TemplateDataFactoryImpl implements TemplateDataFactory {
 | 
			
		||||
    @Override
 | 
			
		||||
    public TemplateInfo getTemplate(long templateId, DataStore store) {
 | 
			
		||||
        VMTemplateVO templ = imageDataDao.findById(templateId);
 | 
			
		||||
        if (templ == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (store == null && !templ.isDirectDownload()) {
 | 
			
		||||
            TemplateObject tmpl = TemplateObject.getTemplate(templ, null, null);
 | 
			
		||||
            return tmpl;
 | 
			
		||||
 | 
			
		||||
@ -81,6 +81,10 @@ public class TemplateObject implements TemplateInfo {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void configure(VMTemplateVO template, DataStore dataStore) {
 | 
			
		||||
        if (template == null) {
 | 
			
		||||
            String msg = String.format("Template Object is not properly initialised %s", this.toString());
 | 
			
		||||
            s_logger.warn(msg);
 | 
			
		||||
        }
 | 
			
		||||
        imageVO = template;
 | 
			
		||||
        this.dataStore = dataStore;
 | 
			
		||||
    }
 | 
			
		||||
@ -97,6 +101,10 @@ public class TemplateObject implements TemplateInfo {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public VMTemplateVO getImage() {
 | 
			
		||||
        if (imageVO == null) {
 | 
			
		||||
            String msg = String.format("Template Object is not properly initialised %s", this.toString());
 | 
			
		||||
            s_logger.error(msg);
 | 
			
		||||
        } // somehow the nullpointer is needed : refacter needed!?!
 | 
			
		||||
        return imageVO;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user