Uploaded image for project: 'Lucee Development'
  1. LDEV-270

Static constructor inappropriately suppresses output

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.0.43
    • Fix Version/s: 5.0.0.84
    • Labels:

      Description

      Consider this code:

      // Baseline.cfc
      component {
      
      	logger = new Logger()
      	echo("statement in the pseudo-constructor<br>")
      	logger.writeToLog(file="Baseline", text="statement in the pseudo-constructor")
      
      	static {
      		echo("statement in the static constructor<br>")
      		static.logger = new Logger()
      		static.logger.writeToLog(file="Baseline", text="statement in the static constructor")
      		static.myVar = 17
      	}
      
      	static function f(){
      		echo("statement in the static method<br>")
      		static.logger.writeToLog(file="Baseline", text="statement in the static method")
      	}
      
      	function init(){
      		echo("statement in the object constructor<br>")
      		logger.writeToLog(file="Baseline", text="statement in the object constructor")
      	}
      
      }
      
      // baselineCreatingObject.cfm
      baseline = new Baseline();	
      

      (Logger is just a wrapper for `<cflog>`, to work around 273 and 275)

      On the screen this outputs:

      statement in the pseudo-constructor
      statement in the object constructor
      

      However in the logs I see:

      "INFO","http-nio-8888-exec-6","04/10/2015","13:28:40","","statement in the static constructor"
      "INFO","http-nio-8888-exec-6","04/10/2015","13:28:40","","statement in the pseudo-constructor"
      "INFO","http-nio-8888-exec-6","04/10/2015","13:28:40","","statement in the object constructor"
      

      So clearly the code in the `static{}` block is being executed, but its output is being suppressed. This should not happen.

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                michaeloffner Michael Offner
                Reporter:
                da_cameron Adam Cameron
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: