?layer will throw exception,when layer is null. "layer!=null" is ok.